This commit is contained in:
shoopea 2020-02-01 15:25:33 +08:00
parent 9d8e727fe0
commit 7d38a0329b
3 changed files with 47 additions and 10 deletions

46
bot.go
View File

@ -771,6 +771,52 @@ func botCraftItem(m *ChatWarsMessage, r *regexp.Regexp) {
return return
} }
func botCraftAll(m *ChatWarsMessage, r *regexp.Regexp) {
clt, err := getLockedIdleClient()
if err != nil {
c := TGCommand{
Type: commandReplyMsg,
Text: "Busy, please retry later.",
FromMsgID64: m.ID64,
FromChatID64: m.ChatID64,
}
TGCmdQueue <- c
return
}
userID64 := clt.TGUserID64
clt.Mux.Unlock()
p := JobPayloadCraftAll{
MsgID64: m.ID64,
ChatID64: m.ChatID64,
Status: 0,
}
b, _ := json.Marshal(p)
t := time.Now().UTC().Add(1 * time.Second)
_, err = createJob(cacheObjSubType[`job_craft_all`], objJobPriority, userID64, 0, t, b)
if err != nil {
c := TGCommand{
Type: commandReplyMsg,
Text: fmt.Sprintf("%s", err),
FromMsgID64: m.ID64,
FromChatID64: m.ChatID64,
}
TGCmdQueue <- c
} else {
c := TGCommand{
Type: commandReplyMsg,
Text: "Craft all coming",
FromMsgID64: m.ID64,
FromChatID64: m.ChatID64,
}
TGCmdQueue <- c
}
return
}
func botSaveRes(m *tb.Message) { func botSaveRes(m *tb.Message) {
if !m.Private() { if !m.Private() {
return return

2
def.go
View File

@ -493,7 +493,6 @@ type JobPayloadVaultItemStatus struct {
type JobPayloadCraftItem struct { type JobPayloadCraftItem struct {
MsgID64 int64 `json:"msg_id"` MsgID64 int64 `json:"msg_id"`
ChatID64 int64 `json:"chat_id"` ChatID64 int64 `json:"chat_id"`
UserID64 int64 `json:"user_id"`
ObjItemID64 int64 `json:"item_id"` ObjItemID64 int64 `json:"item_id"`
Quantity int64 `json:"quantity"` Quantity int64 `json:"quantity"`
Status int64 `json:"status"` Status int64 `json:"status"`
@ -503,7 +502,6 @@ type JobPayloadCraftItem struct {
type JobPayloadCraftAll struct { type JobPayloadCraftAll struct {
MsgID64 int64 `json:"msg_id"` MsgID64 int64 `json:"msg_id"`
ChatID64 int64 `json:"chat_id"` ChatID64 int64 `json:"chat_id"`
UserID64 int64 `json:"user_id"`
Status int64 `json:"status"` Status int64 `json:"status"`
VaultJobID64 int64 `json:"vault_job_id"` VaultJobID64 int64 `json:"vault_job_id"`
} }

View File

@ -513,14 +513,7 @@ func SQLIdentifyMsgWorker(id int, objIds <-chan int64) {
case cacheObjSubType[`msg_bot_craft_item`]: case cacheObjSubType[`msg_bot_craft_item`]:
botCraftItem(m, rule.re) botCraftItem(m, rule.re)
case cacheObjSubType[`msg_bot_craft_all`]: case cacheObjSubType[`msg_bot_craft_all`]:
c := TGCommand{ botCraftAll(m, rule.re)
Type: commandReplyMsg,
Text: `Not implemented yet`,
FromMsgID64: m.ID64,
FromChatID64: m.ChatID64,
ParseMode: cmdParseModeHTML,
}
TGCmdQueue <- c
default: default:
//log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Unknwon message type in rule %d : %d (%d)\n%s\n", msgParsingRules[i].ID, msgParsingRules[i].MsgTypeID64, objId, m.Text) //log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Unknwon message type in rule %d : %d (%d)\n%s\n", msgParsingRules[i].ID, msgParsingRules[i].MsgTypeID64, objId, m.Text)
} }