diff options
author | Anne-Gwenn Kettunen <uniaika@crypto-keupone.eu> | 2016-03-07 23:27:25 +0100 |
---|---|---|
committer | Anne-Gwenn Kettunen <uniaika@crypto-keupone.eu> | 2016-03-07 23:27:25 +0100 |
commit | 29e0752dcda2562f060eeca470178d2a5f27008d (patch) | |
tree | f3b19820ae9de6aedd2ee18c9a20fc47cdfd4a25 /lib | |
parent | now fixed a little typo (diff) |
a few more corrections and a WiP on the examples
Diffstat (limited to 'lib')
-rw-r--r-- | lib/exirc/client.ex | 9 | ||||
-rw-r--r-- | lib/exirc/example_handler.ex | 24 |
2 files changed, 21 insertions, 12 deletions
diff --git a/lib/exirc/client.ex b/lib/exirc/client.ex index ebb7659..66354dc 100644 --- a/lib/exirc/client.ex +++ b/lib/exirc/client.ex @@ -627,12 +627,13 @@ defmodule ExIrc.Client do {:noreply, new_state} end # Called when someone else in our channel leaves - def handle_data(%IrcMessage{:cmd => "PART", :nick => user_nick} = msg, state) do + def handle_data(%IrcMessage{:cmd => "PART", :nick => from, :host => host, :user => user} = msg, state) do + sender = %{:nick => from, :host => host, :user => user} channel = msg.args |> List.first |> String.strip - if state.debug?, do: debug "#{user_nick} LEFT A CHANNEL: #{channel}" - channels = Channels.user_part(state.channels, channel, user_nick) + if state.debug?, do: debug "#{from} LEFT A CHANNEL: #{channel}" + channels = Channels.user_part(state.channels, channel, from) new_state = %{state | :channels => channels} - send_event {:parted, channel, user_nick}, new_state + send_event {:parted, channel, sender}, new_state {:noreply, new_state} end # Called when we receive a PING diff --git a/lib/exirc/example_handler.ex b/lib/exirc/example_handler.ex index 971e491..f7b0e48 100644 --- a/lib/exirc/example_handler.ex +++ b/lib/exirc/example_handler.ex @@ -70,35 +70,43 @@ defmodule ExampleHandler do debug "We left #{channel}" {:noreply, nil} end - def handle_info({:parted, channel, nick}, _state) do + def handle_info({:parted, channel, sender}, _state) do + nick = sender.nick debug "#{nick} left #{channel}" {:noreply, nil} end - def handle_info({:invited, by, channel}, _state) do + def handle_info({:invited, sender, channel}, _state) do + by = sender.nick debug "#{by} invited us to #{channel}" {:noreply, nil} end - def handle_info({:kicked, by, channel}, _state) do + def handle_info({:kicked, sender, channel}, _state) do + by = sender.nick debug "We were kicked from #{channel} by #{by}" {:noreply, nil} end - def handle_info({:kicked, nick, by, channel}, _state) do + def handle_info({:kicked, nick, sender, channel}, _state) do + by = sender.nick debug "#{nick} was kicked from #{channel} by #{by}" {:noreply, nil} end - def handle_info({:received, message, from}, _state) do + def handle_info({:received, message, sender}, _state) do + from = sender.nick debug "#{from} sent us a private message: #{message}" {:noreply, nil} end - def handle_info({:received, message, from, channel}, _state) do + def handle_info({:received, message, sender, channel}, _state) do + from = sender.nick debug "#{from} sent a message to #{channel}: #{message}" {:noreply, nil} end - def handle_info({:mentioned, message, from, channel}, _state) do + def handle_info({:mentioned, message, sender, channel}, _state) do + from = sender.nick debug "#{from} mentioned us in #{channel}: #{message}" {:noreply, nil} end - def handle_info({:me, message, from, channel}, _state) do + def handle_info({:me, message, sender, channel}, _state) do + from = sender.nick debug "* #{from} #{message} in #{channel}" {:noreply, nil} end |