From bc3d5b7f4f54d88a2ebf1cadbcd7e2816f07deaa Mon Sep 17 00:00:00 2001 From: Jordan Bracco Date: Sun, 11 Dec 2022 19:07:09 +0000 Subject: Fix the fixes. --- lib/lsg_telegram/room.ex | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/lsg_telegram') 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__) -- cgit v1.2.3