From 7088bfa291c787bc6f4ab18eed1cfc0f56507319 Mon Sep 17 00:00:00 2001 From: shoopea Date: Sun, 1 Mar 2020 14:13:33 +0800 Subject: [PATCH] update angrybirbs --- cron.go | 19 +++++++++++++++++++ data/config.json | 1 + def.go | 1 + job.go | 1 + 4 files changed, 22 insertions(+) diff --git a/cron.go b/cron.go index 1f406d5..77e6820 100644 --- a/cron.go +++ b/cron.go @@ -15,12 +15,14 @@ import ( func startCron() *cron.Cron { c := cron.New(cron.WithLocation(time.UTC)) c.AddFunc("58 6,14,22 * * *", cronSetDef) + c.AddFunc("00 0 * * *", cronUpdateAngryBirbs) c.AddFunc("02 1,3,5,9,11,13,17,19,21 * * *", cronGetHammerTime) c.AddFunc("12 7,15,23 * * *", cronGetHammerTime) c.AddFunc("13 3,7,11,15,19,23 * * *", cronTribute) c.AddFunc("14 7,15,23 * * *", cronCheckVaultLimit) c.AddFunc("15 7,15,23 * * *", cronSendWarReport) c.AddFunc("@every 1m", cronSaveClients) + c.AddFunc("06 15 * * *", cronUpdateAngryBirbs) c.Start() return c } @@ -30,6 +32,23 @@ func stopCron(c *cron.Cron) { return } +func cronUpdateAngryBirbs() { + muxClients.RLock() + for _, c := range clients { + if c.Active { + p := JobPayloadMsgFwd{ + ChatID64: cfg.Bot.AngryBirbs, + } + b, _ := json.Marshal(&p) + err := createJobCallback(cacheObjSubType[`job_msg_fwd`], c.TGUserID64, cacheObjSubType[`msg_me_ack`], b, 1*time.Minute) + logOnError(err, "cronUpdateAngryBirbs : createJobCallback") + clientSendCWMsgDelay(c.TGUserID64, `/me`, 0) + } + } + muxClients.RUnlock() + return +} + func cronSendWarReport() { muxClients.RLock() for _, c := range clients { diff --git a/data/config.json b/data/config.json index 205c295..7ce41ac 100644 --- a/data/config.json +++ b/data/config.json @@ -24,6 +24,7 @@ "main_chat_id": 0, "deposit_chat_id": 0, "report_chat_id": 0, + "angrybirbs_id": 833409972, "vault_limit": [ { "item" : "01", diff --git a/def.go b/def.go index 8322d5c..d277a8c 100644 --- a/def.go +++ b/def.go @@ -40,6 +40,7 @@ type Config struct { Mainchat int64 `json:"main_chat_id"` Depositchat int64 `json:"deposit_chat_id"` Reportchat int64 `json:"report_chat_id"` + AngryBirbs int64 `json:"angrybirbs_id"` VaultLimit []struct { Item string `json:"item"` Min int64 `json:"min_qty"` diff --git a/job.go b/job.go index 3f36c57..c8c4935 100644 --- a/job.go +++ b/job.go @@ -2075,6 +2075,7 @@ func jobAlchAll(j Job) { setJobCallback(j.ID64, j.UserID64, cacheObjSubType[`msg_skill_too_low`]) setJobCallback(j.ID64, j.UserID64, cacheObjSubType[`msg_alch_stock_ack`]) + setJobCallback(j.ID64, j.UserID64, cacheObjSubType[`msg_busy`]) rescheduleJob(j.ID64, 0, time.Unix(maxUnixTimestamp, 0).UTC()) clientSendCWMsgDelay(j.UserID64, "/alch", 2*time.Second) return