chirpnest/cron.go

30 lines
434 B
Go
Raw Normal View History

2019-12-12 10:42:05 +01:00
package main
import (
2019-12-12 10:44:18 +01:00
//"github.com/robfig/cron/v3"
"gopkg.in/robfig/cron.v3"
2019-12-12 10:42:05 +01:00
)
func startCron() *Cron {
c := cron.New(cron.WithLocation(time.UTC))
c.AddFunc("@every 1m", cronSendReport)
c.Start()
return
}
func stopCron(c *Cron) {
c.Stop()
return
}
func cronSendReport() {
muxClients.RLock()
for id, c := range clients {
if c.Active {
clientSendCWMsg(c.TGUserID64, `/report`)
}
}
muxClients.RUnlock()
return
}