Skip to content

Commit

Permalink
refactor: 💡 get_env
Browse files Browse the repository at this point in the history
  • Loading branch information
ThaddeusJiang committed Oct 29, 2024
1 parent 6a97220 commit d268df3
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/small_sdk/telegram.ex
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ defmodule SmallSdk.Telegram do
plug(Tesla.Middleware.BaseUrl, "https://api.telegram.org")

def download_file_content(file_path) when is_binary(file_path) do
url = "/file/bot#{Application.fetch_env!(:save_it, :telegram_bot_token)}/#{file_path}"
bot_token = get_env()
url = "/file/bot#{bot_token}/#{file_path}"

case get(url) do
{:ok, response} ->
Expand All @@ -23,4 +24,10 @@ defmodule SmallSdk.Telegram do
{:error, error} -> raise "Error: #{inspect(error)}"
end
end

defp get_env() do
bot_token = Application.fetch_env!(:save_it, :telegram_bot_token)

bot_token
end
end

0 comments on commit d268df3

Please sign in to comment.