Nick already in use callback

This commit is contained in:
tj 2010-03-12 21:33:20 +01:00
parent efcb5f679d
commit 32ab9f2259

View File

@ -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)