本文整理匯總了Golang中github.com/fluffle/goevent/event.EventRegistry.AddHandler方法的典型用法代碼示例。如果您正苦於以下問題:Golang EventRegistry.AddHandler方法的具體用法?Golang EventRegistry.AddHandler怎麽用?Golang EventRegistry.AddHandler使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/fluffle/goevent/event.EventRegistry
的用法示例。
在下文中一共展示了EventRegistry.AddHandler方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: RegisterHandlers
func (qd *quoteDriver) RegisterHandlers(r event.EventRegistry) {
r.AddHandler(bot.NewHandler(qd_privmsg), "bot_privmsg")
// r.AddHandler(bot.NewHandler(qd_action), "bot_action")
}
示例2: RegisterHandlers
// NOTE: Nothing but the bot should register for IRC events!
func (bot *Sp0rkle) RegisterHandlers(r event.EventRegistry) {
// Generic shim to wrap an irc event into a bot event.
forward_event := func(name string) event.Handler {
return client.NewHandler(func(irc *client.Conn, line *client.Line) {
getState(irc).Dispatch("bot_"+name, &base.Line{Line: *line.Copy()})
})
}
r.AddHandler(client.NewHandler(bot_connected), "connected")
r.AddHandler(client.NewHandler(bot_disconnected), "disconnected")
r.AddHandler(client.NewHandler(bot_privmsg), "privmsg")
r.AddHandler(forward_event("action"), "action")
// These are mostly for the seen plugin.
r.AddHandler(forward_event("join"), "join")
r.AddHandler(forward_event("part"), "part")
r.AddHandler(forward_event("kick"), "kick")
r.AddHandler(forward_event("quit"), "quit")
r.AddHandler(forward_event("nick"), "nick")
// This is a special handler that triggers a rebuild and re-exec
r.AddHandler(client.NewHandler(bot_rebuild), "notice")
// This is a special handler that triggers a shutdown and disconnect
r.AddHandler(client.NewHandler(bot_shutdown), "notice")
}