chirpnest/cron.go

32 lines
453 B
Go
Raw Normal View History

2019-12-12 10:42:05 +01:00
package main
import (
2019-12-12 10:45:27 +01:00
"time"
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
)
2019-12-12 10:45:27 +01:00
func startCron() *cron.Cron {
2019-12-12 10:42:05 +01:00
c := cron.New(cron.WithLocation(time.UTC))
c.AddFunc("@every 1m", cronSendReport)
c.Start()
return
}
2019-12-12 10:45:27 +01:00
func stopCron(c *cron.Cron) {
2019-12-12 10:42:05 +01:00
c.Stop()
return
}
func cronSendReport() {
muxClients.RLock()
for id, c := range clients {
if c.Active {
clientSendCWMsg(c.TGUserID64, `/report`)
}
}
muxClients.RUnlock()
return
}