summaryrefslogtreecommitdiff
path: root/lib/irc.ex
diff options
context:
space:
mode:
authorhref <href@random.sh>2021-09-02 13:00:55 +0200
committerhref <href@random.sh>2021-09-02 13:00:55 +0200
commit28ab854e9dbcd2e40fc4b7986f4e5dd303bf27a1 (patch)
tree62bda7f25e7d9282283fc8eca290f60d7d0d8c86 /lib/irc.ex
parentlastfm: improvements, fixes (diff)
improve puppets, fix uploads
Diffstat (limited to '')
-rw-r--r--lib/irc.ex11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/irc.ex b/lib/irc.ex
index ee44f37..7f0d7e1 100644
--- a/lib/irc.ex
+++ b/lib/irc.ex
@@ -15,6 +15,17 @@ defmodule IRC do
defstruct [:type, :trigger, :args]
end
+ def send_message_as(account, network, channel, text, force_puppet \\ false) do
+ connection = IRC.Connection.get_network(network)
+ if connection && (force_puppet || IRC.PuppetConnection.whereis(account, connection)) do
+ IRC.PuppetConnection.start_and_send_message(account, connection, channel, text)
+ else
+ user = IRC.UserTrack.find_by_account(network, account)
+ nick = if(user, do: user.nick, else: account.name)
+ IRC.Connection.broadcast_message(network, channel, "<#{nick}> #{text}")
+ end
+ end
+
def register(key) do
case Registry.register(IRC.PubSub, key, []) do
{:ok, _} -> :ok