func cronMessage(conf gobot.BotConf, responseChannel chan fmt.Stringer) { for _, tr := range conf.Triggers { if tr.Cron == "" { continue } next := bet.ParseCron(tr.Cron, time.Now()) <-time.After(time.Duration(next)) for { responseChannel <- message.MsgSend{tr.Dest, tr.Results[0]} <-time.After(time.Hour * 24 * 7) } } }
func cronHandler(conf BotConf, responseChannel chan fmt.Stringer) { now := time.Now() for _, tr := range conf.Triggers { if tr.Cron != "" { next := bet.ParseCron(tr.Cron, now) go func() { <-time.After(time.Duration(next)) for { responseChannel <- message.MsgSend{tr.Results[0], tr.Results[1]} <-time.After(time.Hour * 7) } }() } } }