Beispiel #1
0
// run and recover from panic during bot.Stop()
// the upstream slack adapter has not implemented bot.Stop() yet
func runBot(bot victor.Robot) {
	defer func() {
		if e := recover(); e != nil {
			fmt.Println("bot.Stop() exited with panic: ", e)
			os.Exit(0)
		}
	}()

	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()
}