summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/exirc/channels.ex10
-rw-r--r--lib/exirc/client.ex9
2 files changed, 19 insertions, 0 deletions
diff --git a/lib/exirc/channels.ex b/lib/exirc/channels.ex
index b7a6d4c..b108de9 100644
--- a/lib/exirc/channels.ex
+++ b/lib/exirc/channels.ex
@@ -118,6 +118,16 @@ defmodule ExIrc.Channels do
users_manip(channel_tree, channel_name, manipfn)
end
+ def user_quit(channel_tree, nick) do
+ pnick = strip_rank([nick])
+ manipfn = fn(channel_nicks) -> :lists.usort(channel_nicks -- pnick) end
+ foldl = fn(channel_name, new_channel_tree) ->
+ name = downcase(channel_name)
+ users_manip(new_channel_tree, name, manipfn)
+ end
+ :lists.foldl(foldl, channel_tree, channels(channel_tree))
+ end
+
@doc """
Update the nick of a user in a tracked channel when they change their nick
"""
diff --git a/lib/exirc/client.ex b/lib/exirc/client.ex
index fe9168d..cde4f1a 100644
--- a/lib/exirc/client.ex
+++ b/lib/exirc/client.ex
@@ -640,6 +640,15 @@ defmodule ExIrc.Client do
send_event {:parted, channel, sender}, new_state
{:noreply, new_state}
end
+ def handle_data(%IrcMessage{cmd: "QUIT", nick: from, host: host, user: user} = msg, state) do
+ sender = %SenderInfo{nick: from, host: host, user: user}
+ reason = msg.args |> List.first
+ if state.debug?, do: debug "#{from} QUIT"
+ channels = Channels.user_quit(state.channels, from)
+ new_state = %{state | channels: channels}
+ send_event {:quit, reason, sender}, new_state
+ {:noreply, new_state}
+ end
# Called when we receive a PING
def handle_data(%IrcMessage{cmd: "PING"} = msg, %ClientState{autoping: true} = state) do
if state.debug?, do: debug "RECEIVED A PING!"