fix telegram messaging
This commit is contained in:
parent
031a9020f4
commit
f986a60ce3
5 changed files with 42 additions and 1 deletions
|
@ -18,6 +18,12 @@ defmodule EisromUiWeb.MorseLive do
|
|||
|
||||
Eisrom.Morse.Server.toggle_morse()
|
||||
|
||||
try do
|
||||
Task.async(fn -> post_telegram_message() end)
|
||||
rescue
|
||||
e in RuntimeError -> e
|
||||
end
|
||||
|
||||
{:noreply, socket}
|
||||
end
|
||||
|
||||
|
@ -36,4 +42,16 @@ defmodule EisromUiWeb.MorseLive do
|
|||
hints_visible: false
|
||||
]
|
||||
end
|
||||
|
||||
defp post_telegram_message do
|
||||
Tesla.post("https://api.telegram.org/bot#{telegram_bot_token()}/sendMessage?text=PUSHED&chat_id=#{telegram_chat_id()}", "")
|
||||
end
|
||||
|
||||
defp telegram_bot_token do
|
||||
Application.fetch_env!(:eisrom_ui, :telegram_bot_token)
|
||||
end
|
||||
|
||||
defp telegram_chat_id do
|
||||
Application.fetch_env!(:eisrom_ui, :telegram_chat_id)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue