update craft item

This commit is contained in:
shoopea 2020-01-27 12:10:21 +08:00
parent ca052bc10c
commit f65c61236d
2 changed files with 16 additions and 5 deletions

13
bot.go
View File

@ -723,9 +723,20 @@ func botCraftItem(m *ChatWarsMessage) {
p := JobPayloadCraftItem{ p := JobPayloadCraftItem{
MsgID64: m.ID64, MsgID64: m.ID64,
ChatID64: m.ChatID64, ChatID64: m.ChatID64,
ObjItemID64: getCraftItemID(m.Text),
Status: 0, Status: 0,
} }
p.ObjItemID64, err = getCraftItemID(m.Text)
if err != nil {
c := TGCommand{
Type: commandReplyMsg,
Text: fmt.Sprintf("%s", err),
FromMsgID64: m.ID64,
FromChatID64: m.ChatID64,
}
TGCmdQueue <- c
return
}
b, _ := json.Marshal(p) b, _ := json.Marshal(p)
t := time.Now().UTC().Add(1 * time.Second) t := time.Now().UTC().Add(1 * time.Second)
_, err = createJob(cacheObjSubType[`job_craft_item`], objJobPriority, userID64, 0, t, b) _, err = createJob(cacheObjSubType[`job_craft_item`], objJobPriority, userID64, 0, t, b)

View File

@ -242,7 +242,7 @@ func addObjItemCraftItem(objID64 int64, itemID64 int64, quantity int64) error {
return nil return nil
} }
func getCraftItemID(cmd string) (int64, error) { func getCraftItemID(cmd string) int64, error) {
muxObjItem.RLock() muxObjItem.RLock()
defer muxObjItem.RUnlock() defer muxObjItem.RUnlock()