diff options
author | Jordan Bracco <href@random.sh> | 2025-06-25 19:22:59 +0200 |
---|---|---|
committer | Jordan Bracco <href@random.sh> | 2025-06-25 19:22:59 +0200 |
commit | c934e79e5852e05f714b2d542cc2678e287c49b8 (patch) | |
tree | 55779a0168260fce03e4775eacdd613ffc945588 /lib/plugins/user_mention.ex | |
parent | updates (diff) |
format.
Diffstat (limited to 'lib/plugins/user_mention.ex')
-rw-r--r-- | lib/plugins/user_mention.ex | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/lib/plugins/user_mention.ex b/lib/plugins/user_mention.ex index 634167e..1a9881c 100644 --- a/lib/plugins/user_mention.ex +++ b/lib/plugins/user_mention.ex @@ -19,11 +19,24 @@ defmodule Nola.Plugins.UserMention do {:ok, nil} end - def handle_info({:irc, :trigger, nick, message = %Nola.Message{sender: sender, account: account, network: network, channel: channel, trigger: %Nola.Trigger{type: :at, args: content}}}, state) do - nick = nick - |> String.trim(":") - |> String.trim(",") + def handle_info( + {:irc, :trigger, nick, + message = %Nola.Message{ + sender: sender, + account: account, + network: network, + channel: channel, + trigger: %Nola.Trigger{type: :at, args: content} + }}, + state + ) do + nick = + nick + |> String.trim(":") + |> String.trim(",") + target = Nola.Account.find_always_by_nick(network, channel, nick) + if target do telegram = Nola.Account.get_meta(target, "telegram-id") sms = Nola.Account.get_meta(target, "sms-number") @@ -31,22 +44,27 @@ defmodule Nola.Plugins.UserMention do cond do telegram -> - Nola.Telegram.send_message(telegram, "`#{channel}` <**#{sender.nick}**> #{Enum.join(content, " ")}") + Nola.Telegram.send_message( + telegram, + "`#{channel}` <**#{sender.nick}**> #{Enum.join(content, " ")}" + ) + sms -> case Nola.Plugins.Sms.send_sms(sms, text) do {:error, code} -> message.replyfun("#{sender.nick}: erreur #{code} (sms)") end + true -> Nola.Plugins.Tell.tell(message, nick, content) end else false end + {:noreply, state} end def handle_info(_, state) do {:noreply, state} end - end |