summaryrefslogtreecommitdiff
path: root/lib/irc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/irc')
-rw-r--r--lib/irc/pubsub_handler.ex9
-rw-r--r--lib/irc/user_track.ex6
2 files changed, 15 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)}
diff --git a/lib/irc/user_track.ex b/lib/irc/user_track.ex
index 2614d98..02d5752 100644
--- a/lib/irc/user_track.ex
+++ b/lib/irc/user_track.ex
@@ -85,6 +85,12 @@ defmodule IRC.UserTrack do
end
end
+ def channel(channel) do
+ Enum.filter(to_list(), fn({_, nick, _, _, _, _, channels}) ->
+ Map.get(channels, channel)
+ end)
+ end
+
def joined(c, s), do: joined(c,s,[])
def joined(channel, sender=%{nick: nick, user: uname, host: host}, privileges) do