From 62cd5b4501a0c6fae4f2939a301ccd6aee11991e Mon Sep 17 00:00:00 2001 From: shoopea Date: Sun, 1 Mar 2020 18:14:00 +0800 Subject: [PATCH] update items --- cron.go | 1 - data/obj_item.json | 2 +- job.go | 93 +++++++++++++++++++++++----------------------- 3 files changed, 47 insertions(+), 49 deletions(-) diff --git a/cron.go b/cron.go index adf28cf..cb7ba11 100644 --- a/cron.go +++ b/cron.go @@ -22,7 +22,6 @@ func startCron() *cron.Cron { c.AddFunc("14 7,15,23 * * *", cronCheckVaultLimit) c.AddFunc("15 7,15,23 * * *", cronSendWarReport) c.AddFunc("@every 1m", cronSaveClients) - c.AddFunc("17 06 * * *", cronUpdateAngryBirbs) c.Start() return c } diff --git a/data/obj_item.json b/data/obj_item.json index 8296a9e..01f1762 100644 --- a/data/obj_item.json +++ b/data/obj_item.json @@ -9810,7 +9810,7 @@ "quantity": 1 }, { - "code": "k98", + "code": "k94", "quantity": 6 }, { diff --git a/job.go b/job.go index c8c4935..255ee15 100644 --- a/job.go +++ b/job.go @@ -1693,9 +1693,6 @@ func jobGWithdraw(j Job) { return } else { p.Validated = true - setJobCallback(j.ID64, j.UserID64, cacheObjSubType[`msg_withdraw_code`]) - setJobCallback(j.ID64, j.UserID64, cacheObjSubType[`msg_withdraw_req`]) - // TODO } } else { err = rescheduleJob(j.ID64, 0, time.Unix(maxUnixTimestamp, 0).UTC()) @@ -1703,8 +1700,6 @@ func jobGWithdraw(j Job) { setJobCallback(j.ID64, int64(bot.Me.ID), cacheObjSubType[`msg_job_gwithdraw_ack`]) return } - - return case cacheObjSubType[`msg_withdraw_code`]: log.Printf("jobGWithdraw[%d] : Handling withdraw code.\n", j.ID64) if false /* check if it's ours */ { @@ -1734,14 +1729,6 @@ func jobGWithdraw(j Job) { } } - /* - c, err := getLockedRoleClient(`commander`) - logOnError(err, "jobGWithdraw: getLockedRoleClient(commander)") - if err == nil { - c.Mux.Unlock() - } - */ - log.Printf("jobGWithdraw[%d] : Preparing withdrawal guild link.\n", j.ID64) var stock string for _, i := range p.Items { @@ -1753,52 +1740,64 @@ func jobGWithdraw(j Job) { } if len(stock) > 0 { - err := setJobPayloadJSON(j.ID64, p) - logOnError(err, "jobGWithdraw : setJobPayloadJSON") + if p.Validated { + c, err := getLockedRoleClient(`commander`) + logOnError(err, "jobGWithdraw: getLockedRoleClient(commander)") - setJobCallback(j.ID64, int64(bot.Me.ID), cacheObjSubType[`msg_job_gwithdraw_ack`]) + if err == nil { + c.Mux.Unlock() + } + setJobCallback(j.ID64, j.UserID64, cacheObjSubType[`msg_withdraw_code`]) + setJobCallback(j.ID64, j.UserID64, cacheObjSubType[`msg_withdraw_req`]) + return + } else { + err := setJobPayloadJSON(j.ID64, p) + logOnError(err, "jobGWithdraw : setJobPayloadJSON") - sha256 := sha256.Sum256([]byte(cfg.Telegram.Token)) - sha128 := sha256[:aes.BlockSize] - c, err := aes.NewCipher(sha128) + setJobCallback(j.ID64, int64(bot.Me.ID), cacheObjSubType[`msg_job_gwithdraw_ack`]) - in := make([]byte, 0) - buf := make([]byte, 8) - binary.LittleEndian.PutUint64(buf, uint64(j.ID64)) - in = append(in, buf...) - binary.LittleEndian.PutUint64(buf, uint64(p.UserID64)) - in = append(in, buf...) - out := make([]byte, len(in)) + sha256 := sha256.Sum256([]byte(cfg.Telegram.Token)) + sha128 := sha256[:aes.BlockSize] + c, err := aes.NewCipher(sha128) - ref := hex.EncodeToString(in) - log.Printf("jobGWithdraw[%d] : in string : %s.\n", j.ID64, ref) - c.Encrypt(out, in) - ref = hex.EncodeToString(out) - log.Printf("jobGWithdraw[%d] : out string : %s.\n", j.ID64, ref) + in := make([]byte, 0) + buf := make([]byte, 8) + binary.LittleEndian.PutUint64(buf, uint64(j.ID64)) + in = append(in, buf...) + binary.LittleEndian.PutUint64(buf, uint64(p.UserID64)) + in = append(in, buf...) + out := make([]byte, len(in)) - ref = hex.EncodeToString(out) + ref := hex.EncodeToString(in) + log.Printf("jobGWithdraw[%d] : in string : %s.\n", j.ID64, ref) + c.Encrypt(out, in) + ref = hex.EncodeToString(out) + log.Printf("jobGWithdraw[%d] : out string : %s.\n", j.ID64, ref) - m, err := getObjMsg(j.Trigger) - logOnError(err, "jobGWithdraw : getObjMsg") + ref = hex.EncodeToString(out) - p.CleanupMsg = append(p.CleanupMsg, *m) + m, err := getObjMsg(j.Trigger) + logOnError(err, "jobGWithdraw : getObjMsg") - b, err = json.Marshal(p) - log.Printf("jobGWithdraw[%d] : %s\n", j.ID64, string(b)) + p.CleanupMsg = append(p.CleanupMsg, *m) - u, err := bot.ChatByID(fmt.Sprintf("%d", p.UserID64)) - logOnError(err, "jobGWithdraw : ChatByID") + b, err = json.Marshal(p) + log.Printf("jobGWithdraw[%d] : %s\n", j.ID64, string(b)) - msg := fmt.Sprintf("Click to validate @%s's withdrawal of%s\n/withdraw_%s", u.Username, stock, string(ref)) + u, err := bot.ChatByID(fmt.Sprintf("%d", p.UserID64)) + logOnError(err, "jobGWithdraw : ChatByID") - cmd := TGCommand{ - Type: commandSendMsg, - Text: msg, - ToChatID64: cfg.Bot.Mainchat, - ParseMode: cmdParseModeHTML, + msg := fmt.Sprintf("Click to validate @%s's withdrawal of%s\n/withdraw_%s", u.Username, stock, string(ref)) + + cmd := TGCommand{ + Type: commandSendMsg, + Text: msg, + ToChatID64: cfg.Bot.Mainchat, + ParseMode: cmdParseModeHTML, + } + TGCmdQueue <- cmd + return } - TGCmdQueue <- cmd - return } else { cmd := TGCommand{ Type: commandReplyMsg,