From 38f1cd93883e18f6eb42f9726beb7ea9806cd8fa Mon Sep 17 00:00:00 2001 From: Alex Bramley Date: Sat, 19 Dec 2009 18:33:54 +0000 Subject: [PATCH] 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. --- irc/handlers.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/irc/handlers.go b/irc/handlers.go index 7d77877..dec82fd 100644 --- a/irc/handlers.go +++ b/irc/handlers.go @@ -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, " ")) + } } })