Add ability to silence callback handler
This commit is contained in:
parent
9d322aca1a
commit
78a4c71736
1
irc.go
1
irc.go
@ -200,6 +200,7 @@ func IRC(nick, user string) *IRCConnection {
|
||||
irc.Error = make(chan os.Error)
|
||||
irc.nick = nick
|
||||
irc.user = user
|
||||
irc.VerboseCallbackHandler = true
|
||||
irc.setupCallbacks()
|
||||
return irc
|
||||
}
|
||||
|
@ -49,11 +49,14 @@ func (irc *IRCConnection) RunCallbacks(event *IRCEvent) {
|
||||
}
|
||||
}
|
||||
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 {
|
||||
go callback(event)
|
||||
}
|
||||
} else {
|
||||
fmt.Printf("No callback for: %#v\n", event)
|
||||
} else if irc.VerboseCallbackHandler {
|
||||
fmt.Printf("%v (0) >> %#v\n", event.Code, event)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,8 @@ type IRCConnection struct {
|
||||
ticker <-chan int64
|
||||
ticker2 <-chan int64
|
||||
|
||||
VerboseCallbackHandler bool
|
||||
|
||||
quitting bool
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user