Changeset View
Changeset View
Standalone View
Standalone View
lib/lsg_telegram/telegram.ex
Context not available. | |||||
def send_message(id, text, md2 \\ false) do | def send_message(id, text, md2 \\ false) do | ||||
md = if md2, do: "MarkdownV2", else: "Markdown" | md = if md2, do: "MarkdownV2", else: "Markdown" | ||||
token = Keyword.get(Application.get_env(:lsg, :telegram, []), :key) | token = Keyword.get(Application.get_env(:nola, :telegram, []), :key) | ||||
Telegram.Bot.ChatBot.Chat.Session.Supervisor.start_child(Nola.Telegram, id) | Telegram.Bot.ChatBot.Chat.Session.Supervisor.start_child(Nola.Telegram, id) | ||||
Telegram.Api.request(token, "sendMessage", chat_id: id, text: text, parse_mode: "Markdown") | Telegram.Api.request(token, "sendMessage", chat_id: id, text: text, parse_mode: "Markdown") | ||||
end | end | ||||
Context not available. | |||||
{:ok, %HTTPoison.Response{status_code: 200, body: body}} <- HTTPoison.get(path), | {:ok, %HTTPoison.Response{status_code: 200, body: body}} <- HTTPoison.get(path), | ||||
<<smol_body::binary-size(20), _::binary>> = body, | <<smol_body::binary-size(20), _::binary>> = body, | ||||
{:ok, magic} <- GenMagic.Pool.perform(Nola.GenMagic, {:bytes, smol_body}), | {:ok, magic} <- GenMagic.Pool.perform(Nola.GenMagic, {:bytes, smol_body}), | ||||
bucket = Application.get_env(:lsg, :s3, []) |> Keyword.get(:bucket), | bucket = Application.get_env(:nola, :s3, []) |> Keyword.get(:bucket), | ||||
ext = Path.extname(file["file_path"]), | ext = Path.extname(file["file_path"]), | ||||
s3path = "#{account.id}/#{file_unique_id}#{ext}", | s3path = "#{account.id}/#{file_unique_id}#{ext}", | ||||
Telegram.Api.request(t, "editMessageText", chat_id: chat_id, message_id: m_id, text: "*Uploading...*", reply_markup: %{}, parse_mode: "MarkdownV2"), | Telegram.Api.request(t, "editMessageText", chat_id: chat_id, message_id: m_id, text: "*Uploading...*", reply_markup: %{}, parse_mode: "MarkdownV2"), | ||||
Context not available. |