diff options
author | Jordan Bracco <href@random.sh> | 2023-03-06 18:09:57 +0100 |
---|---|---|
committer | Jordan Bracco <href@random.sh> | 2023-03-06 18:09:57 +0100 |
commit | 5ab36499520e3dd9958c79b5c124333f1313ec5f (patch) | |
tree | 5b2d1dc806e401b31b2de3d4ef7752e3635e6fc8 /lib/telegram/room.ex | |
parent | plugin: link/image: commit py node (diff) |
hate this
Diffstat (limited to 'lib/telegram/room.ex')
-rw-r--r-- | lib/telegram/room.ex | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/telegram/room.ex b/lib/telegram/room.ex index 7a8f427..9db551b 100644 --- a/lib/telegram/room.ex +++ b/lib/telegram/room.ex @@ -53,7 +53,7 @@ defmodule Nola.TelegramRoom do %Nola.Irc.Connection{} -> {net, chan} _ -> {nil, nil} end - _ = Couch.post(@couch, %{"_id" => id, "network" => net, "channel" => chan}) + {:ok, _, _} = Couch.post(@couch, %{"_id" => id, "network" => net, "channel" => chan}) {:ok, tg_room} = room(to_string(id)) tg_room end @@ -102,14 +102,14 @@ defmodule Nola.TelegramRoom do def handle_update(%{"message" => %{"from" => from = %{"id" => user_id}, "text" => text}}, _token, state) do account = find_or_create_meta_account(from, state) #connection = Nola.Irc.Connection.get_network(state.net) - Nola.Irc.send_message_as(account, state.net, state.chan, text, true) + Nola.Irc.send_message_as(account, state.net, state.chan, text, true, origin: __MODULE__) {:ok, state} end def handle_update(data = %{"message" => %{"from" => from = %{"id" => user_id}, "location" => %{"latitude" => lat, "longitude" => lon}}}, _token, state) do account = find_or_create_meta_account(from, state) #connection = Nola.Irc.Connection.get_network(state.net) - Nola.Irc.send_message_as(account, state.net, state.chan, "@ #{lat}, #{lon}", true) + Nola.Irc.send_message_as(account, state.net, state.chan, "@ #{lat}, #{lon}", true, origin: __MODULE__) {:ok, state} end @@ -128,7 +128,7 @@ defmodule Nola.TelegramRoom do end def handle_info({:irc, _, message = %Nola.Message{sender: %{nick: nick}, text: text}}, state) do - if Map.get(message.meta, :from) == self() do + if Map.get(message.meta, :from) == self() || Map.get(message.meta, :origin) == __MODULE__ do else body = if Map.get(message.meta, :self), do: text, else: "<#{nick}> #{text}" Nola.Telegram.send_message(state.id, body) @@ -179,7 +179,7 @@ defmodule Nola.TelegramRoom do path = NolaWeb.Router.Helpers.url(NolaWeb.Endpoint) <> "/files/#{s3path}" txt = "#{type}: #{text}#{path}" #connection = Nola.Irc.Connection.get_network(state.net) - Nola.Irc.send_message_as(account, state.net, state.chan, txt, true) + Nola.Irc.send_message_as(account, state.net, state.chan, txt, true, origin: __MODULE__) else error -> Telegram.Api.request(token, "sendMessage", chat_id: chat_id, text: "File upload failed, sorry.") |