This commit is contained in:
shoopea 2020-01-26 21:47:13 +08:00
parent cdfdc21c13
commit 60469f8564
4 changed files with 16 additions and 10 deletions

1
bot.go
View File

@ -678,6 +678,7 @@ func botGStock(m ChatWarsMessage) {
p := JobPayloadGStock{
MsgID64: m.ID64,
ChatID64: m.ChatID64,
Status: 0,
}
b, _ := json.Marshal(p)
t := time.Now().UTC().Add(1 * time.Second)

1
def.go
View File

@ -401,6 +401,7 @@ type JobPayloadStatus struct {
}
type JobPayloadGStock struct {
Status int64 `json:"status"`
MsgID64 int64 `json:"msg_id"`
ChatID64 int64 `json:"chat_id"`
VaultJobID64 int64 `json:"vault_job_id"`

View File

@ -246,9 +246,13 @@ func getCraftItemID(cmd string) (int64, error) {
muxObjItem.RLock()
defer muxObjItem.RUnlock()
for _, o := range objItems {
if id, ok := cacheObjItemCraft[cmd]; ok {
return objItems[id].ObjID64, nil
} else {
return 0, nil
}
return 0, nil
}
func loadObjItem() error {

16
job.go
View File

@ -201,13 +201,16 @@ func setJobPayload(jobID64 int64, payload []byte) error {
return nil
}
func getJobPayload(j.ID64) []byte {
func getJobPayload(jobID64 int64) []byte {
var b []byte
muxObjJob.Lock()
j := cacheObjJob[jobID64]
b = j.Payload
defer muxObjJob.Unlock()
return b
if j, ok := cacheObjJob[jobID64]; ok {
b = j.Payload
return b
} else {
return nil
}
}
func setJobDone(jobID64 int64) error {
@ -909,9 +912,6 @@ func jobGStock(j Job) {
err = json.Unmarshal(j.Payload, &p)
logOnError(err, "jobGStock : Unmarshal payload")
fmt.Printf("jobGStock : Progress => %d\n", p.Progress)
fmt.Printf("jobGStock : UserID64 => %d\n", j.UserID64)
if p.Status == 0 {
p2.JobCallbackID64 = j.ID64
p2.ItemTypeList = make([]int64, 0)
@ -938,7 +938,7 @@ func jobGStock(j Job) {
return
}
b = getJobPayload(p.VaultJobID64)
b := getJobPayload(p.VaultJobID64)
err = json.Unmarshal(b, &p2)
logOnError(err, "jobGStock : Unmarshal(p2)")