update items

This commit is contained in:
shoopea 2020-03-01 18:14:00 +08:00
parent ca5c2743e3
commit 62cd5b4501
3 changed files with 47 additions and 49 deletions

View File

@ -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
}

View File

@ -9810,7 +9810,7 @@
"quantity": 1
},
{
"code": "k98",
"code": "k94",
"quantity": 6
},
{

93
job.go
View File

@ -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<code>%s</code>\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<code>/withdraw_%s</code>", 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,