From d268df3bc7b687743a99e864d30b1059392ebbe4 Mon Sep 17 00:00:00 2001 From: TJ Date: Tue, 29 Oct 2024 11:18:12 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20=F0=9F=92=A1=20get=5Fenv?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/small_sdk/telegram.ex | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/small_sdk/telegram.ex b/lib/small_sdk/telegram.ex index ad4586c..6dcb760 100644 --- a/lib/small_sdk/telegram.ex +++ b/lib/small_sdk/telegram.ex @@ -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} -> @@ -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