diff options
author | Paul Schoenfelder <paulschoenfelder@gmail.com> | 2017-06-19 13:06:29 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-19 13:06:29 -0500 |
commit | 8c86802214dc815dc5d3a00758da80f88f429e3c (patch) | |
tree | 298d005a8ed47f243738575a71775d231fadeab5 | |
parent | Version 1.0.1 (diff) | |
parent | Add NOTICE support (and by ext, NickServ support) (diff) |
Merge pull request #66 from shymega/add-nickserv-support
Add NOTICE support (and by ext, NickServ support)
-rw-r--r-- | lib/exirc/client.ex | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/exirc/client.ex b/lib/exirc/client.ex index aad131c..9d6905b 100644 --- a/lib/exirc/client.ex +++ b/lib/exirc/client.ex @@ -728,6 +728,23 @@ defmodule ExIrc.Client do send_event {:me, message, sender, channel}, state {:noreply, state} end + # Called when a NOTICE is received by the client. + def handle_data(%IrcMessage{nick: from, cmd: "NOTICE", args: [target, message], host: host, user: user} = _msg, state) do + sender = %SenderInfo{nick: from, + host: host, + user: user} + + if String.contains?(message, "identify") do + if state.debug?, do: debug("* Told to identify by #{from}: #{message}") + send_event({:identify, message, sender}, state) + else + if state.debug?, do: debug("* #{message} from #{sender}") + send_event({:notice, message, sender}, state) + end + + {:noreply, state} + end + # Called any time we receive an unrecognized message def handle_data(msg, state) do if state.debug? do debug "UNRECOGNIZED MSG: #{msg.cmd}"; IO.inspect(msg) end |