update stash

This commit is contained in:
shoopea 2020-06-29 12:47:19 +02:00
parent d93ecb96ee
commit f531a28053
2 changed files with 15 additions and 2 deletions

2
def.go
View File

@ -641,7 +641,7 @@ type JobPayloadGetStash struct {
UserID64 int64 `json:"user_id"`
ClientID64 []int64 `json:"clients_id"`
ClientCount int64 `json:"client_count"`
Stock []ChatWarsItems `json:"stock"`
Stash map[int64]int64 `json:"stock"`
CleanupMsg []ChatWarsMessage `json:"cleanup_msg"`
}

15
job.go
View File

@ -2110,6 +2110,13 @@ func jobGetStash(j Job) {
break
}
}
cwm, err := parseSubTypeMessageExchangeAck(m, rule)
logOnError(err, "jobGetStash : parseSubTypeMessageExchangeAck")
if err == nil {
for _, d := range cwm.DealList {
p.Stash[d.ItemID64] += d.Quantity
}
}
fmt.Printf("jobGetStash : %d clients remaining\n", len(p.ClientID64))
fmt.Printf("jobGetStash : clearing trigger for next client\n")
j.Trigger = 0
@ -2161,13 +2168,19 @@ func jobGetStash(j Job) {
if len(p.ClientID64) == 0 && j.Trigger == 0 {
fmt.Printf("jobGetStash : Cleaning up\n")
for _, m := range p.CleanupMsg {
fmt.Printf("jobGetStash : clientDelTGMsg(%d, %d, %d)\n", m.TGUserID64, m.ID64, m.ChatID64)
clientDelTGMsg(m.TGUserID64, m.ID64, m.ChatID64)
}
}
out = "Stash:\n"
for k, v := range p.Stash {
out = fmt.Sprintf(" %d : %d\n", k, v)
}
c := TGCommand{
Type: commandReplyMsg,
Text: "Done.",
Text: out,
FromMsgID64: p.MsgID64,
FromChatID64: p.ChatID64,
ParseMode: cmdParseModeHTML,