From 48ad9bfa4ad1b7324d671b092bdc9b7af41d08bb Mon Sep 17 00:00:00 2001 From: Alex Bramley Date: Mon, 22 Aug 2011 23:21:30 +0100 Subject: [PATCH] Line parsing needs to handle CTCPREPLY too. --- client/line.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/client/line.go b/client/line.go index 8efaa1b..e9d7695 100644 --- a/client/line.go +++ b/client/line.go @@ -61,9 +61,9 @@ func parseLine(s string) *Line { } // So, I think CTCP and (in particular) CTCP ACTION are better handled as - // separate events as opposed to forcing people to have gargantuan PRIVMSG + // separate events as opposed to forcing people to have gargantuan // handlers to cope with the possibilities. - if line.Cmd == "PRIVMSG" && + if (line.Cmd == "PRIVMSG" || line.Cmd == "NOTICE") && len(line.Args[1]) > 2 && strings.HasPrefix(line.Args[1], "\001") && strings.HasSuffix(line.Args[1], "\001") { @@ -73,13 +73,17 @@ func parseLine(s string) *Line { // Replace the line with the unwrapped CTCP line.Args[1] = t[1] } - if c := strings.ToUpper(t[0]); c == "ACTION" { + if c := strings.ToUpper(t[0]); c == "ACTION" && line.Cmd == "PRIVMSG" { // make a CTCP ACTION it's own event a-la PRIVMSG line.Cmd = c } else { - // otherwise, dispatch a generic CTCP event that + // otherwise, dispatch a generic CTCP/CTCPREPLY event that // contains the type of CTCP in line.Args[0] - line.Cmd = "CTCP" + if line.Cmd == "PRIVMSG" { + line.Cmd = "CTCP" + } else { + line.Cmd = "CTCPREPLY" + } line.Args = append([]string{c}, line.Args...) } }