mirror of https://github.com/fluffle/goirc
Line parsing needs to handle CTCPREPLY too.
This commit is contained in:
parent
5c347008fb
commit
48ad9bfa4a
|
@ -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]
|
||||
if line.Cmd == "PRIVMSG" {
|
||||
line.Cmd = "CTCP"
|
||||
} else {
|
||||
line.Cmd = "CTCPREPLY"
|
||||
}
|
||||
line.Args = append([]string{c}, line.Args...)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue