From 32ab9f22592e095ee1a98fd5097ec3d7eb9c8f5e Mon Sep 17 00:00:00 2001 From: tj Date: Fri, 12 Mar 2010 21:33:20 +0100 Subject: [PATCH] Nick already in use callback --- irc_callback.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/irc_callback.go b/irc_callback.go index 259bd61..42d0f8a 100644 --- a/irc_callback.go +++ b/irc_callback.go @@ -24,7 +24,7 @@ func (irc *IRCConnection) AddCallback(eventcode string, callback func(*IRCEvent) func (irc *IRCConnection) ReplaceCallback(i uint8, eventcode string, callback func(*IRCEvent)) { eventcode = strings.ToUpper(eventcode) if event, ok := irc.events[eventcode]; ok { - event[i] = callback; + event[i] = callback } else { event = make([]func(*IRCEvent), 1, 20) event[0] = callback @@ -89,6 +89,11 @@ func (irc *IRCConnection) setupCallbacks() { irc.SendRaw(fmt.Sprintf("NICK %s", irc.nick)) }) + irc.AddCallback("433", func(e *IRCEvent) { + irc.nick = irc.nick + "_" + irc.SendRaw(fmt.Sprintf("NICK %s", irc.nick)) + }) + irc.AddCallback("PONG", func(e *IRCEvent) { ns, _ := strconv.Atoi64(e.Message) fmt.Printf("Lag: %fs\n", float((time.Nanoseconds()-ns))/1000/1000/1000)