This commit is contained in:
shoopea 2020-06-16 17:28:28 +02:00
parent 0aa7b91f3c
commit 8f37640250

26
cron.go
View File

@ -21,6 +21,7 @@ func startCron() *cron.Cron {
c.AddFunc("13 3,7,11,15,19,23 * * *", cronTribute) c.AddFunc("13 3,7,11,15,19,23 * * *", cronTribute)
c.AddFunc("59 6,14,22 * * *", cronCheckVaultLimit) c.AddFunc("59 6,14,22 * * *", cronCheckVaultLimit)
c.AddFunc("15 7,15,23 * * *", cronSendWarReport) c.AddFunc("15 7,15,23 * * *", cronSendWarReport)
c.AddFunc("55 6,14,22 * * *", cronAutoDeposit)
c.AddFunc("@every 1m", cronSaveClients) c.AddFunc("@every 1m", cronSaveClients)
c.Start() c.Start()
return c return c
@ -155,3 +156,28 @@ func cronCheckVaultLimit() {
t := time.Now().UTC().Add(1 * time.Second) t := time.Now().UTC().Add(1 * time.Second)
_, err = createJob(cacheObjSubType[`job_check_vault_limit`], objJobPriority, clt.TGUserID64, 0, t, b) _, err = createJob(cacheObjSubType[`job_check_vault_limit`], objJobPriority, clt.TGUserID64, 0, t, b)
} }
func cronAutoDeposit() {
muxClients.RLock()
for _, c := range clients {
if c.Active && c.Config.AutoDeposit {
p := JobPayloadGDeposit{
MsgID64: 0,
ChatID64: 0,
ResObjID64: nil,
Status: 0,
}
for _, v := range c.Config.AutoDepositItems {
p.ResObjID64 = append(p.ResObjID64, cacheObjItem[v])
}
for _, v := range c.Config.AutoDepositTypes {
list := getSQLListID64(fmt.Sprintf("select o.id from obj o where o.obj_sub_type_id = %d;", cacheObjSubType[v]))
p.ResObjID64 = append(p.ResObjID64, list...)
}
b, _ := json.Marshal(p)
t := time.Now().UTC()
_, err := createJob(cacheObjSubType[`job_gdeposit`], objJobPriority, int64(c.TGUserID64), 0, t, b)
}
}
muxClients.RUnlock()
}