test
This commit is contained in:
parent
79d0b01723
commit
109f38e470
73
job.go
73
job.go
@ -1568,47 +1568,58 @@ func jobGWithdraw(j Job) {
|
||||
}
|
||||
*/
|
||||
|
||||
b, _ := json.Marshal(p)
|
||||
id, err := createJob(cacheObjSubType[`job_gwithdraw`], objJobPriority, j.UserID64, 0, time.Unix(maxUnixTimestamp, 0).UTC(), b)
|
||||
logOnError(err, "jobGWithdraw : createJob")
|
||||
|
||||
sha256 := sha256.Sum256([]byte(cfg.Telegram.Token))
|
||||
sha128 := sha256[:aes.BlockSize]
|
||||
c, err := aes.NewCipher(sha128)
|
||||
|
||||
in := make([]byte, 0)
|
||||
buf := make([]byte, 8)
|
||||
binary.LittleEndian.PutUint64(buf, uint64(id))
|
||||
in = append(in, buf...)
|
||||
binary.LittleEndian.PutUint64(buf, uint64(j.UserID64))
|
||||
in = append(in, buf...)
|
||||
out := make([]byte, len(in))
|
||||
|
||||
c.Encrypt(out, in)
|
||||
ref := hex.EncodeToString(out)
|
||||
|
||||
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 {
|
||||
} else if i.Available > 0 {
|
||||
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))
|
||||
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")
|
||||
|
||||
cmd := TGCommand{
|
||||
Type: commandReplyMsg,
|
||||
Text: msg,
|
||||
FromMsgID64: p.MsgID64,
|
||||
FromChatID64: p.ChatID64,
|
||||
ParseMode: cmdParseModeHTML,
|
||||
sha256 := sha256.Sum256([]byte(cfg.Telegram.Token))
|
||||
sha128 := sha256[:aes.BlockSize]
|
||||
c, err := aes.NewCipher(sha128)
|
||||
|
||||
in := make([]byte, 0)
|
||||
buf := make([]byte, 8)
|
||||
binary.LittleEndian.PutUint64(buf, uint64(id))
|
||||
in = append(in, buf...)
|
||||
binary.LittleEndian.PutUint64(buf, uint64(j.UserID64))
|
||||
in = append(in, buf...)
|
||||
out := make([]byte, len(in))
|
||||
|
||||
c.Encrypt(out, in)
|
||||
ref := hex.EncodeToString(out)
|
||||
|
||||
b, err = json.Marshal(p)
|
||||
fmt.Printf("jobGWithdraw : %s\n", string(b))
|
||||
|
||||
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,
|
||||
Text: msg,
|
||||
FromMsgID64: p.MsgID64,
|
||||
FromChatID64: p.ChatID64,
|
||||
ParseMode: cmdParseModeHTML,
|
||||
}
|
||||
TGCmdQueue <- cmd
|
||||
} else {
|
||||
cmd := TGCommand{
|
||||
Type: commandReplyMsg,
|
||||
Text: "No stock available whatsoever",
|
||||
FromMsgID64: p.MsgID64,
|
||||
FromChatID64: p.ChatID64,
|
||||
ParseMode: cmdParseModeHTML,
|
||||
}
|
||||
TGCmdQueue <- cmd
|
||||
}
|
||||
TGCmdQueue <- cmd
|
||||
}
|
||||
|
||||
err = setJobDone(j.ID64)
|
||||
|
Loading…
Reference in New Issue
Block a user