diff options
Diffstat (limited to '')
-rw-r--r-- | lib/irc/pubsub_handler.ex | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/irc/pubsub_handler.ex b/lib/irc/pubsub_handler.ex index 450dc2f..61ae55c 100644 --- a/lib/irc/pubsub_handler.ex +++ b/lib/irc/pubsub_handler.ex @@ -23,6 +23,10 @@ defmodule IRC.PubSubHandler do GenServer.start_link(__MODULE__, [client], [name: __MODULE__]) end + def privmsg(channel, line) do + GenServer.cast(__MODULE__, {:privmsg, channel, line}) + end + def init([client]) do ExIRC.Client.add_handler(client, self()) {:ok, client} @@ -37,6 +41,11 @@ defmodule IRC.PubSubHandler do "~" => :tilde } + def handle_cast({:privmsg, channel, line}, client) do + irc_reply(client, {channel, nil}, line) + {:noreply, client} + end + def handle_info({:received, text, sender, chan}, client) do reply_fun = fn(text) -> irc_reply(client, {chan, sender}, text) end message = %IRC.Message{text: text, sender: sender, channel: chan, replyfun: reply_fun, trigger: extract_trigger(text)} |