update angrybirbs

This commit is contained in:
shoopea 2020-03-01 14:13:33 +08:00
parent 50794c8b1e
commit 7088bfa291
4 changed files with 22 additions and 0 deletions

19
cron.go
View File

@ -15,12 +15,14 @@ import (
func startCron() *cron.Cron { func startCron() *cron.Cron {
c := cron.New(cron.WithLocation(time.UTC)) c := cron.New(cron.WithLocation(time.UTC))
c.AddFunc("58 6,14,22 * * *", cronSetDef) 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("02 1,3,5,9,11,13,17,19,21 * * *", cronGetHammerTime)
c.AddFunc("12 7,15,23 * * *", cronGetHammerTime) c.AddFunc("12 7,15,23 * * *", cronGetHammerTime)
c.AddFunc("13 3,7,11,15,19,23 * * *", cronTribute) c.AddFunc("13 3,7,11,15,19,23 * * *", cronTribute)
c.AddFunc("14 7,15,23 * * *", cronCheckVaultLimit) c.AddFunc("14 7,15,23 * * *", cronCheckVaultLimit)
c.AddFunc("15 7,15,23 * * *", cronSendWarReport) c.AddFunc("15 7,15,23 * * *", cronSendWarReport)
c.AddFunc("@every 1m", cronSaveClients) c.AddFunc("@every 1m", cronSaveClients)
c.AddFunc("06 15 * * *", cronUpdateAngryBirbs)
c.Start() c.Start()
return c return c
} }
@ -30,6 +32,23 @@ func stopCron(c *cron.Cron) {
return 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() { func cronSendWarReport() {
muxClients.RLock() muxClients.RLock()
for _, c := range clients { for _, c := range clients {

View File

@ -24,6 +24,7 @@
"main_chat_id": 0, "main_chat_id": 0,
"deposit_chat_id": 0, "deposit_chat_id": 0,
"report_chat_id": 0, "report_chat_id": 0,
"angrybirbs_id": 833409972,
"vault_limit": [ "vault_limit": [
{ {
"item" : "01", "item" : "01",

1
def.go
View File

@ -40,6 +40,7 @@ type Config struct {
Mainchat int64 `json:"main_chat_id"` Mainchat int64 `json:"main_chat_id"`
Depositchat int64 `json:"deposit_chat_id"` Depositchat int64 `json:"deposit_chat_id"`
Reportchat int64 `json:"report_chat_id"` Reportchat int64 `json:"report_chat_id"`
AngryBirbs int64 `json:"angrybirbs_id"`
VaultLimit []struct { VaultLimit []struct {
Item string `json:"item"` Item string `json:"item"`
Min int64 `json:"min_qty"` Min int64 `json:"min_qty"`

1
job.go
View File

@ -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_skill_too_low`])
setJobCallback(j.ID64, j.UserID64, cacheObjSubType[`msg_alch_stock_ack`]) 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()) rescheduleJob(j.ID64, 0, time.Unix(maxUnixTimestamp, 0).UTC())
clientSendCWMsgDelay(j.UserID64, "/alch", 2*time.Second) clientSendCWMsgDelay(j.UserID64, "/alch", 2*time.Second)
return return