diff options
author | href <href@random.sh> | 2021-09-02 13:00:55 +0200 |
---|---|---|
committer | href <href@random.sh> | 2021-09-02 13:00:55 +0200 |
commit | 28ab854e9dbcd2e40fc4b7986f4e5dd303bf27a1 (patch) | |
tree | 62bda7f25e7d9282283fc8eca290f60d7d0d8c86 /lib/irc.ex | |
parent | lastfm: improvements, fixes (diff) |
improve puppets, fix uploads
Diffstat (limited to '')
-rw-r--r-- | lib/irc.ex | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -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 |