本文整理匯總了Golang中github.com/nickvanw/ircx.Bot類的典型用法代碼示例。如果您正苦於以下問題:Golang Bot類的具體用法?Golang Bot怎麽用?Golang Bot使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Bot類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: RegisterHandlers
func RegisterHandlers(bot *ircx.Bot) {
bot.HandleFunc(irc.RPL_WELCOME, RegisterConnect)
bot.HandleFunc(irc.PING, PingHandler)
bot.HandleFunc(irc.PRIVMSG, MsgHandler)
bot.HandleFunc(irc.JOIN, JoinHandler)
bot.HandleFunc(irc.PART, PartHandler)
}
示例2: main
func main() {
conf = configure()
var bot *ircx.Bot
if len(serverpass) > 0 {
bot = ircx.WithLoginTLS(server, name, name, serverpass, nil)
} else {
bot = ircx.Classic(server, name)
}
performRegistrations(bot)
if err := bot.Connect(); err != nil {
log.Fatal(err)
}
messages.WriteLoop()
fmt.Printf("Connecting...\n")
bot.HandleLoop()
}
示例3: RegisterHandlers
func RegisterHandlers(bot *ircx.Bot) {
bot.AddCallback(irc.RPL_WELCOME, ircx.Callback{Handler: ircx.HandlerFunc(RegisterConnect)})
bot.AddCallback(irc.PING, ircx.Callback{Handler: ircx.HandlerFunc(PingHandler)})
maildirproxy := NewMaildirproxy(*server)
bot.AddCallback(irc.PRIVMSG, ircx.Callback{Handler: ircx.HandlerFunc(maildirproxy.PrivmsgHandler)})
}
示例4: RegisterHandlers
func RegisterHandlers(bot *ircx.Bot) {
bot.HandleFunc(irc.RPL_WELCOME, RegisterConnect)
bot.HandleFunc(irc.PING, PingHandler)
}
示例5: registerHandlers
func registerHandlers(bot *ircx.Bot) {
bot.HandleFunc(irc.RPL_WELCOME, onWelcome)
bot.HandleFunc(irc.PING, onPing)
bot.HandleFunc(irc.PRIVMSG, onPrivmsg)
}
示例6: performRegistrations
func performRegistrations(bot *ircx.Bot) {
bot.HandleFunc(irc.RPL_WELCOME, registerConnect)
bot.HandleFunc(irc.PING, pingHandler)
bot.HandleFunc(irc.PRIVMSG, MessageHandler)
bot.HandleFunc(irc.NOTICE, MessageHandler)
bot.HandleFunc(irc.JOIN, JoinHandler)
bot.HandleFunc(irc.QUIT, LeaveHandler)
bot.HandleFunc(irc.PART, LeaveHandler)
bot.HandleFunc(irc.NICK, NickHandler)
bot.HandleFunc(irc.ERR_UNKNOWNCOMMAND, unknownCommandHandler)
bot.HandleFunc(irc.RPL_WHOREPLY, WhoisHandler)
// non standard RPL_WHOISACCOUNT
bot.HandleFunc("330", WhoisHandler)
bot.HandleFunc("354", WhoisHandler)
bot.HandleFunc("353", WhoisHandler)
bot.HandleFunc(irc.ERR_NOLOGIN, loginErrHandler)
// ACCOUNT-NOTIFY
bot.HandleFunc("ACCOUNT", AccountHandler)
registerCommand(commands.CommandStruct{
Name: "google",
Usage: "<query>",
Summary: "Queries google for search results.",
Handle: commands.Search,
})
registerCommand(commands.CommandStruct{
Name: "yt",
Usage: "<query>",
Summary: "Queries Youtube for videos.",
Handle: commands.SearchYoutube,
})
registerCommand(commands.CommandStruct{
Name: "quit",
Usage: "",
Summary: "Forces the bot to quit (SEE ALSO: restart)",
Handle: commands.Quit,
})
registerCommand(commands.CommandStruct{
Name: "trust",
Usage: "<nick>",
Summary: "Makes the bot trust a nick (SEE ALSO: doubt, trusted)",
Handle: commands.Trust,
})
registerCommand(commands.CommandStruct{
Name: "doubt",
Usage: "<nick>",
Summary: "Makes the bot no longer trust a nick (SEE ALSO: trust, trusted",
Handle: commands.Doubt,
})
registerCommand(commands.CommandStruct{
Name: "alias",
Usage: "<command>",
Summary: "Creates an alias which can be used to run a command",
Handle: commands.Alias,
})
registerCommand(commands.CommandStruct{
Name: "join",
Usage: "<channel>",
Summary: "Makes the bot join a channel (SEE ALSO: leave)",
Handle: commands.Join,
})
registerCommand(commands.CommandStruct{
Name: "leave",
Usage: "<channel>",
Summary: "Makes the bot leave a channel (SEE ALSO: join)",
Handle: commands.Leave,
})
registerCommand(commands.CommandStruct{
Name: "restart",
Usage: "",
Summary: "Forces the bot to restart (SEE ALSO: quit)",
Handle: commands.Restart,
})
registerCommand(commands.CommandStruct{
Name: "trusted",
Usage: "",
Summary: "Displays a list of trusted users (SEE ALSO: trust, doubt)",
Handle: commands.Trusted,
})
registerCommand(commands.CommandStruct{
Name: "weather",
Usage: "<city>, [state]",
Summary: "Queries for weather in a given city (SEE ALSO: temp)",
Handle: commands.Weather,
})
registerCommand(commands.CommandStruct{
Name: "temperature",
Usage: "<city>, state",
Summary: "Queries for temperature in a given city (SEE ALSO: weather)",
Handle: commands.Temperature,
})
registerCommand(commands.CommandStruct{
Name: "raw",
Usage: "<numeric> <recipient>:[message]",
Summary: "Forces the bot to perform the given raw command",
Handle: commands.Raw,
})
registerCommand(commands.CommandStruct{
Name: "topic",
Usage: "<message>",
//.........這裏部分代碼省略.........
示例7: RegisterHandlers
func RegisterHandlers(bot *ircx.Bot) {
bot.AddCallback(irc.RPL_WELCOME, ircx.Callback{Handler: ircx.HandlerFunc(RegisterConnect)})
bot.AddCallback(irc.PING, ircx.Callback{Handler: ircx.HandlerFunc(PingHandler)})
}