From 8f376402507de610ec62fd6452a3e12445451f12 Mon Sep 17 00:00:00 2001 From: shoopea Date: Tue, 16 Jun 2020 17:28:28 +0200 Subject: [PATCH] test --- cron.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/cron.go b/cron.go index 9cdb005..505f8a9 100644 --- a/cron.go +++ b/cron.go @@ -21,6 +21,7 @@ func startCron() *cron.Cron { c.AddFunc("13 3,7,11,15,19,23 * * *", cronTribute) c.AddFunc("59 6,14,22 * * *", cronCheckVaultLimit) c.AddFunc("15 7,15,23 * * *", cronSendWarReport) + c.AddFunc("55 6,14,22 * * *", cronAutoDeposit) c.AddFunc("@every 1m", cronSaveClients) c.Start() return c @@ -155,3 +156,28 @@ func cronCheckVaultLimit() { t := time.Now().UTC().Add(1 * time.Second) _, 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() +}