summaryrefslogtreecommitdiff
path: root/lib/lsg_telegram/room.ex
diff options
context:
space:
mode:
Diffstat (limited to 'lib/lsg_telegram/room.ex')
-rw-r--r--lib/lsg_telegram/room.ex6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/lsg_telegram/room.ex b/lib/lsg_telegram/room.ex
index da774c8..4e86382 100644
--- a/lib/lsg_telegram/room.ex
+++ b/lib/lsg_telegram/room.ex
@@ -32,11 +32,13 @@ defmodule LSG.TelegramRoom do
end
def after_start() do
- for id <- room_ids(), do: Telegram.Bot.ChatBot.Chat.Session.Supervisor.start_child(LSG.Telegram, Integer.parse(id) |> elem(0))
+ for id <- room(:ids), do: Telegram.Bot.ChatBot.Chat.Session.Supervisor.start_child(LSG.Telegram, Integer.parse(id) |> elem(0))
end
@impl Telegram.ChatBot
def init(id) when is_integer(id) and id < 0 do
+ token = Keyword.get(Application.get_env(:lsg, :telegram, []), :key)
+ {:ok, chat} = Api.request(token, "getChat", chat_id: id)
Logger.metadata(transport: :telegram, id: id, telegram_room_id: id)
tg_room = case room(id) do
{:ok, tg_room = %{"network" => _net, "channel" => _chan}} -> tg_room
@@ -50,10 +52,8 @@ defmodule LSG.TelegramRoom do
{:ok, tg_room} = room(id)
tg_room
end
- token = Keyword.get(Application.get_env(:lsg, :telegram, []), :key)
%{"network" => net, "channel" => chan} = tg_room
Logger.info("Starting ChatBot for room #{id} \"#{chat["title"]}\" #{inspect tg_room}")
- {:ok, chat} = Api.request(token, "getChat", chat_id: id)
irc_plumbed = if net && chan do
{:ok, _} = Registry.register(IRC.PubSub, "#{net}/#{chan}:messages", plugin: __MODULE__)
{:ok, _} = Registry.register(IRC.PubSub, "#{net}/#{chan}:triggers", plugin: __MODULE__)