Ejemplo n.º 1
0
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)
}
Ejemplo n.º 2
0
Archivo: bot.go Proyecto: cosban/muggy
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()
}
Ejemplo n.º 3
0
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)})
}
Ejemplo n.º 4
0
func RegisterHandlers(bot *ircx.Bot) {
	bot.HandleFunc(irc.RPL_WELCOME, RegisterConnect)
	bot.HandleFunc(irc.PING, PingHandler)
}
Ejemplo n.º 5
0
Archivo: main.go Proyecto: mvdan/gibot
func registerHandlers(bot *ircx.Bot) {
	bot.HandleFunc(irc.RPL_WELCOME, onWelcome)
	bot.HandleFunc(irc.PING, onPing)
	bot.HandleFunc(irc.PRIVMSG, onPrivmsg)
}
Ejemplo n.º 6
0
Archivo: bot.go Proyecto: cosban/muggy
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>",
		Summary: "Causes the bot to set the topic",
		Handle:  commands.Topic,
	})
	registerCommand(commands.CommandStruct{
		Name:    "help",
		Usage:   "[command]",
		Summary: "Displays these words",
		Handle:  commands.Help,
	})
	registerCommand(commands.CommandStruct{
		Name:    "8ball",
		Usage:   "[question]",
		Summary: "Summons the power of the magic 8ball to answer your question",
		Handle:  commands.MagicBall,
	})
	registerCommand(commands.CommandStruct{
		Name:    "roulette",
		Usage:   "",
		Summary: "Russian roulette with a six shooter",
		Handle:  commands.Roulette,
	})
	registerCommand(commands.CommandStruct{
		Name:    "spin",
		Usage:   "",
		Summary: "Spins the six shooter before firing",
		Handle:  commands.SpinFire,
	})
	registerCommand(commands.CommandStruct{
		Name:    "taf",
		Usage:   "[station]",
		Summary: "Replies with a raw taf report for the queried station",
		Handle:  commands.Taf,
	})
	registerCommand(commands.CommandStruct{
		Name:    "metar",
		Usage:   "[station]",
		Summary: "Replies with a raw metar report for the queried station",
		Handle:  commands.Metar,
	})

	for k := range coms {
		log.Printf("Command Registered: %s", k)
	}

	for k, v := range conf["aliases"] {
		k = strings.Trim(k, " ")
		v = strings.Trim(v, " ")

		if com, ok := coms[v]; ok {
			log.Printf("Added alias %s from %s", k, v)
			registerCommand(commands.CommandStruct{
				Name:    k,
				Usage:   com.Usage,
				Summary: com.Summary,
				Handle:  com.Handle,
			})
		}
	}
}
Ejemplo n.º 7
0
Archivo: irc.go Proyecto: gloob/irc_bot
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)})
}