From 5399fc818cf821c75f9f19fd00bf7905ba7fe7e3 Mon Sep 17 00:00:00 2001 From: href Date: Fri, 3 Sep 2021 04:04:21 +0200 Subject: various fixes, web client wip, pubsub events --- lib/lsg/telegram.ex | 2 +- lib/lsg/telegram_room.ex | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'lib/lsg') diff --git a/lib/lsg/telegram.ex b/lib/lsg/telegram.ex index e8758e3..63940dc 100644 --- a/lib/lsg/telegram.ex +++ b/lib/lsg/telegram.ex @@ -206,7 +206,7 @@ defmodule LSG.Telegram do trigger: IRC.Connection.extract_trigger(trigger_text), at: nil } - IRC.Connection.publish(message, ["message:private", "message:telegram"]) + IRC.Connection.publish(message, ["messages:private", "messages:telegram", "telegram/#{account.id}:messages"]) message end diff --git a/lib/lsg/telegram_room.ex b/lib/lsg/telegram_room.ex index 9504cd4..1eeec8f 100644 --- a/lib/lsg/telegram_room.ex +++ b/lib/lsg/telegram_room.ex @@ -12,7 +12,7 @@ defmodule LSG.TelegramRoom do case IRC.Connection.get_network(net, chan) do %IRC.Connection{} -> :global.register_name({__MODULE__, net, chan}, self()) - {:ok, _} = Registry.register(IRC.PubSub, "#{net}/#{chan}:message", plugin: __MODULE__) + {:ok, _} = Registry.register(IRC.PubSub, "#{net}/#{chan}:messages", plugin: __MODULE__) {:ok, _} = Registry.register(IRC.PubSub, "#{net}/#{chan}:triggers", plugin: __MODULE__) err -> Logger.warn("Did not found telegram match for #{id} \"#{chat["title"]}\"") @@ -44,6 +44,10 @@ defmodule LSG.TelegramRoom do {:ok, state} end + def handle_info({:irc, _, _, message}, state) do + handle_info({:irc, nil, message}, state) + end + def handle_info({:irc, _, %IRC.Message{sender: %{nick: nick}, text: text}}, state) do LSG.Telegram.send_message(state.id, "<#{nick}> #{text}") {:ok, state} -- cgit v1.2.3