package background import ( "os" "strings" "github.com/go-chat-bot/bot" ) var Messages chan string = make(chan string, 100) func processMessages(channel string) (string, error) { select { case message, _ := <- Messages: return message, nil default: return "", nil } } func init() { channels := strings.Split(os.Getenv("SYSCOM_CHANNELS"), ",") if len(channels) > 0 { config := bot.PeriodicConfig{ CronSpec: "@every 3s", Channels: channels, CmdFunc: processMessages, } bot.RegisterPeriodicCommand("background_messages", config) } }