summaryrefslogtreecommitdiff
path: root/lib/irc.ex
diff options
context:
space:
mode:
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