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("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("17 06 * * *", cronUpdateAngryBirbs)
c.Start() c.Start()
return c return c
} }

View File

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

93
job.go
View File

@ -1693,9 +1693,6 @@ func jobGWithdraw(j Job) {
return return
} else { } else {
p.Validated = true p.Validated = true
setJobCallback(j.ID64, j.UserID64, cacheObjSubType[`msg_withdraw_code`])
setJobCallback(j.ID64, j.UserID64, cacheObjSubType[`msg_withdraw_req`])
// TODO
} }
} else { } else {
err = rescheduleJob(j.ID64, 0, time.Unix(maxUnixTimestamp, 0).UTC()) 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`]) setJobCallback(j.ID64, int64(bot.Me.ID), cacheObjSubType[`msg_job_gwithdraw_ack`])
return return
} }
return
case cacheObjSubType[`msg_withdraw_code`]: case cacheObjSubType[`msg_withdraw_code`]:
log.Printf("jobGWithdraw[%d] : Handling withdraw code.\n", j.ID64) log.Printf("jobGWithdraw[%d] : Handling withdraw code.\n", j.ID64)
if false /* check if it's ours */ { 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) log.Printf("jobGWithdraw[%d] : Preparing withdrawal guild link.\n", j.ID64)
var stock string var stock string
for _, i := range p.Items { for _, i := range p.Items {
@ -1753,52 +1740,64 @@ func jobGWithdraw(j Job) {
} }
if len(stock) > 0 { if len(stock) > 0 {
err := setJobPayloadJSON(j.ID64, p) if p.Validated {
logOnError(err, "jobGWithdraw : setJobPayloadJSON") 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)) setJobCallback(j.ID64, int64(bot.Me.ID), cacheObjSubType[`msg_job_gwithdraw_ack`])
sha128 := sha256[:aes.BlockSize]
c, err := aes.NewCipher(sha128)
in := make([]byte, 0) sha256 := sha256.Sum256([]byte(cfg.Telegram.Token))
buf := make([]byte, 8) sha128 := sha256[:aes.BlockSize]
binary.LittleEndian.PutUint64(buf, uint64(j.ID64)) c, err := aes.NewCipher(sha128)
in = append(in, buf...)
binary.LittleEndian.PutUint64(buf, uint64(p.UserID64))
in = append(in, buf...)
out := make([]byte, len(in))
ref := hex.EncodeToString(in) in := make([]byte, 0)
log.Printf("jobGWithdraw[%d] : in string : %s.\n", j.ID64, ref) buf := make([]byte, 8)
c.Encrypt(out, in) binary.LittleEndian.PutUint64(buf, uint64(j.ID64))
ref = hex.EncodeToString(out) in = append(in, buf...)
log.Printf("jobGWithdraw[%d] : out string : %s.\n", j.ID64, ref) 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) ref = hex.EncodeToString(out)
logOnError(err, "jobGWithdraw : getObjMsg")
p.CleanupMsg = append(p.CleanupMsg, *m) m, err := getObjMsg(j.Trigger)
logOnError(err, "jobGWithdraw : getObjMsg")
b, err = json.Marshal(p) p.CleanupMsg = append(p.CleanupMsg, *m)
log.Printf("jobGWithdraw[%d] : %s\n", j.ID64, string(b))
u, err := bot.ChatByID(fmt.Sprintf("%d", p.UserID64)) b, err = json.Marshal(p)
logOnError(err, "jobGWithdraw : ChatByID") 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{ msg := fmt.Sprintf("Click to validate @%s's withdrawal of%s\n<code>/withdraw_%s</code>", u.Username, stock, string(ref))
Type: commandSendMsg,
Text: msg, cmd := TGCommand{
ToChatID64: cfg.Bot.Mainchat, Type: commandSendMsg,
ParseMode: cmdParseModeHTML, Text: msg,
ToChatID64: cfg.Bot.Mainchat,
ParseMode: cmdParseModeHTML,
}
TGCmdQueue <- cmd
return
} }
TGCmdQueue <- cmd
return
} else { } else {
cmd := TGCommand{ cmd := TGCommand{
Type: commandReplyMsg, Type: commandReplyMsg,