This commit is contained in:
shoopea 2020-01-16 23:34:21 +08:00
parent 79d0b01723
commit 109f38e470

31
job.go
View File

@ -1568,6 +1568,16 @@ func jobGWithdraw(j Job) {
}
*/
var stock string
for _, i := range p.Items {
if i.Available > i.Required {
stock = fmt.Sprintf("%s\n%d x %s", stock, i.Required, i.Name)
} else if i.Available > 0 {
stock = fmt.Sprintf("%s\n%d x %s", stock, i.Available, i.Name)
}
}
if len(stock) > 0 {
b, _ := json.Marshal(p)
id, err := createJob(cacheObjSubType[`job_gwithdraw`], objJobPriority, j.UserID64, 0, time.Unix(maxUnixTimestamp, 0).UTC(), b)
logOnError(err, "jobGWithdraw : createJob")
@ -1590,16 +1600,7 @@ func jobGWithdraw(j Job) {
b, err = json.Marshal(p)
fmt.Printf("jobGWithdraw : %s\n", string(b))
var stock string
for _, i := range p.Items {
if i.Available > i.Required {
stock = fmt.Sprintf("%s\n%d x %s", stock, i.Required, i.Name)
} else {
stock = fmt.Sprintf("%s\n%d x %s", stock, i.Available, i.Name)
}
}
msg := fmt.Sprintf("To validate @%s withdrawal of<code>%s</code>\nClick /withdraw_%s", p.User, stock, string(ref))
msg := fmt.Sprintf("Click to validate @%s's withdrawal of<code>%s</code>\n/withdraw_%s", p.User, stock, string(ref))
cmd := TGCommand{
Type: commandReplyMsg,
@ -1609,6 +1610,16 @@ func jobGWithdraw(j Job) {
ParseMode: cmdParseModeHTML,
}
TGCmdQueue <- cmd
} else {
cmd := TGCommand{
Type: commandReplyMsg,
Text: "No stock available whatsoever",
FromMsgID64: p.MsgID64,
FromChatID64: p.ChatID64,
ParseMode: cmdParseModeHTML,
}
TGCmdQueue <- cmd
}
}
err = setJobDone(j.ID64)