minor handler bug fixes in 433 and MODE

* sending NICK after 433 -- but before 001 from server -- does not
  result in a confirmation NICK message back from server, so we need
  to change Conn.Me.Nick in the 433 handler in this case.
* Nick MODE changes are transmitted back to us in line.Text not
  line.Args[1], so make sure error messages use this when needed.
This commit is contained in:
Alex Bramley 2009-12-19 18:33:54 +00:00
parent 2b1d7068b1
commit 38f1cd9388
1 changed files with 12 additions and 2 deletions

View File

@ -126,6 +126,12 @@ func (conn *Conn) setupEvents() {
conn.AddHandler("433", func(conn *Conn, line *Line) {
// Args[1] is the new nick we were attempting to acquire
conn.Nick(line.Args[1] + "_")
// if this is happening before we're properly connected (i.e. the nick
// we sent in the initial NICK command is in use) we will not receive
// a NICK message to confirm our change of nick, so ReNick here...
if !conn.connected && line.Args[1] == conn.Me.Nick {
conn.Me.ReNick(line.Args[1] + "_")
}
})
// Handler NICK messages to inform us about nick changes
@ -283,7 +289,7 @@ func (conn *Conn) setupEvents() {
} else if n := conn.GetNick(line.Args[0]); n != nil {
// nick mode change, should be us
if n != conn.Me {
conn.error("irc.MODE(): buh? recieved MODE %s for (non-me) nick %s", line.Args[1], n.Nick)
conn.error("irc.MODE(): buh? recieved MODE %s for (non-me) nick %s", line.Text, n.Nick)
return
}
var modeop bool // true => add mode, false => remove mode
@ -306,7 +312,11 @@ func (conn *Conn) setupEvents() {
}
}
} else {
conn.error("irc.MODE(): buh? not sure what to do with MODE %s %s", line.Args[0], line.Args[1])
if line.Text != "" {
conn.error("irc.MODE(): buh? not sure what to do with nick MODE %s %s", line.Args[0], line.Text)
} else {
conn.error("irc.MODE(): buh? not sure what to do with chan MODE %s", strings.Join(line.Args, " "))
}
}
})