commit
726363f01f
2
irc.go
2
irc.go
@ -91,6 +91,7 @@ func pinger(i *IRCConnection) {
|
|||||||
i.SendRaw(fmt.Sprintf("PING %d", time.Nanoseconds()))
|
i.SendRaw(fmt.Sprintf("PING %d", time.Nanoseconds()))
|
||||||
//Try to recapture nickname if it's not as configured.
|
//Try to recapture nickname if it's not as configured.
|
||||||
if i.nick != i.nickcurrent {
|
if i.nick != i.nickcurrent {
|
||||||
|
i.nickcurrent = i.nick
|
||||||
i.SendRaw(fmt.Sprintf("NICK %s", i.nick))
|
i.SendRaw(fmt.Sprintf("NICK %s", i.nick))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -200,6 +201,7 @@ func IRC(nick, user string) *IRCConnection {
|
|||||||
irc.Error = make(chan os.Error)
|
irc.Error = make(chan os.Error)
|
||||||
irc.nick = nick
|
irc.nick = nick
|
||||||
irc.user = user
|
irc.user = user
|
||||||
|
irc.VerboseCallbackHandler = true
|
||||||
irc.setupCallbacks()
|
irc.setupCallbacks()
|
||||||
return irc
|
return irc
|
||||||
}
|
}
|
||||||
|
@ -49,11 +49,14 @@ func (irc *IRCConnection) RunCallbacks(event *IRCEvent) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if callbacks, ok := irc.events[event.Code]; ok {
|
if callbacks, ok := irc.events[event.Code]; ok {
|
||||||
|
if irc.VerboseCallbackHandler {
|
||||||
|
fmt.Printf("%v (%v) >> %#v\n", event.Code, len(callbacks), event)
|
||||||
|
}
|
||||||
for _, callback := range callbacks {
|
for _, callback := range callbacks {
|
||||||
go callback(event)
|
go callback(event)
|
||||||
}
|
}
|
||||||
} else {
|
} else if irc.VerboseCallbackHandler {
|
||||||
fmt.Printf("No callback for: %#v\n", event)
|
fmt.Printf("%v (0) >> %#v\n", event.Code, event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,4 +110,8 @@ func (irc *IRCConnection) setupCallbacks() {
|
|||||||
irc.nickcurrent = e.Arguments[0]
|
irc.nickcurrent = e.Arguments[0]
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
irc.AddCallback("001", func(e *IRCEvent) {
|
||||||
|
irc.nickcurrent = e.Arguments[0]
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,8 @@ type IRCConnection struct {
|
|||||||
ticker <-chan int64
|
ticker <-chan int64
|
||||||
ticker2 <-chan int64
|
ticker2 <-chan int64
|
||||||
|
|
||||||
|
VerboseCallbackHandler bool
|
||||||
|
|
||||||
quitting bool
|
quitting bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user