Example #1
0
func main() {

	defer func() {
		// this is only necessary since the slack api used by the slack adapter
		// does not currently implement a "Stop" or "Disconnect" method
		if e := recover(); e != nil {
			fmt.Println("bot.Stop() exited with panic: ", e)
			os.Exit(1)
		}
	}()

	bot := victor.New(victor.Config{
		ChatAdapter:   "slackRealtime",
		AdapterConfig: slackRealtime.NewConfig(SLACK_TOKEN),
		Name:          BOT_NAME,
	})
	addHandlers(bot)
	// optional help built in help command
	bot.EnableHelpCommand()
	bot.Run()
	go monitorErrors(bot.ChatErrors())
	go monitorEvents(bot.ChatEvents())
	// keep the process (and bot) alive
	sigs := make(chan os.Signal, 1)
	signal.Notify(sigs, os.Interrupt)
	<-sigs

	bot.Stop()
}
Example #2
0
func main() {
	flag.Parse()

	if *fVersion {
		fmt.Printf("Radigast Slack Bot - Version %s\n", Version)
		return
	}
	var (
		config *radigast.Config
		err    error
	)
	if *fConfig != "" {
		config, err = radigast.LoadConfig(*fConfig)
		if err != nil {
			log.Fatal(err)
		}
	} else {
		log.Fatal("No config file specified.")
	}

	bot := victor.New(victor.Config{
		ChatAdapter:   "slackRealtime",
		AdapterConfig: slackRealtime.NewConfig(config.SlackToken),
		Name:          config.BotName,
	})

	// load radigast plugins
	config.LoadPlugins(bot)

	// Enable in-chat help command
	bot.EnableHelpCommand()

	//  run the bot
	runBot(bot)
}
Example #3
0
func main() {
	bot := victor.New(victor.Config{
		ChatAdapter: "shell",
		Name:        BOT_NAME,
	})
	addHandlers(bot)
	// optional help built in help command
	bot.EnableHelpCommand()
	bot.Run()
	go monitorErrors(bot.ChatErrors())
	go monitorEvents(bot.ChatEvents())
	// keep the process (and bot) alive
	sigs := make(chan os.Signal, 1)
	signal.Notify(sigs, os.Interrupt)
	<-sigs

	bot.Stop()
}