chirpnest/cron.go
2019-12-12 17:49:18 +08:00

32 lines
455 B
Go

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