38 lines
727 B
Go
38 lines
727 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("15 0,8,16 * * *", cronSendWarReport)
|
|
c.Start()
|
|
return c
|
|
}
|
|
|
|
func stopCron(c *cron.Cron) {
|
|
c.Stop()
|
|
return
|
|
}
|
|
|
|
func cronSendWarReport() {
|
|
muxClients.RLock()
|
|
for _, c := range clients {
|
|
if c.Active {
|
|
p := JobPayloadFwdMsg{
|
|
ChatID64: cfg.Bot.Reportchat,
|
|
}
|
|
b, _ = json.Marshal(&p)
|
|
err := createJobCallback(objSubTypeJobFwdMsg, c.TGUserID64, objSubTypeMessageReportAck, b, 1*time.Minute)
|
|
logOnError(err, "cronSendWarReport : createJobCallback")
|
|
clientSendCWMsg(c.TGUserID64, `/report`)
|
|
}
|
|
}
|
|
muxClients.RUnlock()
|
|
return
|
|
}
|