summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDom Rodriguez <shymega@shymega.org.uk>2017-06-01 13:52:11 +0100
committerDom Rodriguez <shymega@shymega.org.uk>2017-06-01 13:52:11 +0100
commit67e1f2ff859e14f5bcaeb7ce7fe65468333a8502 (patch)
tree298d005a8ed47f243738575a71775d231fadeab5
parentVersion 1.0.1 (diff)
Add NOTICE support (and by ext, NickServ support)
This commit adds NOTICE handling support, as well as support for when the client is told to to identify by NickServ, which /usually/ comes in the form of a NOTICE. Later versions of this patch should account for other ways NickServ might ask a client to identify.
-rw-r--r--lib/exirc/client.ex17
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