fix shop slaves

This commit is contained in:
shoopea 2020-02-11 10:11:42 +08:00
parent 38c5200d96
commit f33570cc6f
2 changed files with 29 additions and 13 deletions

View File

@ -1891,7 +1891,7 @@
"prio": 5000, "prio": 5000,
"descn": "Shop main ack", "descn": "Shop main ack",
"rule": "^Welcome, to the (?P<Name>[a-zA-Z0-9 -]+) #(?P<Number>[0-9]+)\\.\\n(?P<User>.+) (?P<Mana>[0-9]+)\\/(?P<ManaTotal>[0-9]+)💧the (?P<Class>.+) from (?P<Castle>.+)\\n\\n(?P<Fees>.*)\\n\\n(the (?P<Guru>.*) Guru\\n\\n){0,1}.* is (?P<Open>(open|closed))\\.\\n(?s:.*).*/ws_(?P<Link>[a-zA-Z0-9]+)$", "rule": "^Welcome, to the (?P<Name>[a-zA-Z0-9 -]+) #(?P<Number>[0-9]+)\\.\\n(?P<User>.+) (?P<Mana>[0-9]+)\\/(?P<ManaTotal>[0-9]+)💧the (?P<Class>.+) from (?P<Castle>.+)\\n\\n(?P<Fees>.*)\\n\\n(the (?P<Guru>.*) Guru\\n\\n){0,1}.* is (?P<Open>(open|closed))\\.\\n(?s:.*).*/ws_(?P<Link>[a-zA-Z0-9]+)$",
"msg_type": "msg_shop_main_ack", "msg_type": "msg_unknown_action",
"chat_id": 0, "chat_id": 0,
"user_id": 0 "user_id": 0
}, },

40
job.go
View File

@ -2314,18 +2314,6 @@ func jobShopsSlave(j Job) {
logOnError(err, "jobShopsSlave : getMsgParsingRule") logOnError(err, "jobShopsSlave : getMsgParsingRule")
switch id { switch id {
case cacheObjSubType[`msg_unknown_action`]:
muxObjJob.Lock()
b2 := getJobPayloadUnsafe(p.JobCallbackID64)
var p2 JobPayloadShops
err = json.Unmarshal(b2, &p2)
p2.Msgs = append(p2.Msgs, *m)
err = setJobPayloadJSONUnsafe(p.JobCallbackID64, p2)
logOnError(err, "jobShopsSlave : setJobPayloadJSONUnsafe")
muxObjJob.Unlock()
rescheduleJob(j.ID64, 0, time.Unix(maxUnixTimestamp, 0).UTC()) // reschedule so that it gets picked up by shop main ack callback
return
case cacheObjSubType[`msg_shop_main_req`]: case cacheObjSubType[`msg_shop_main_req`]:
muxObjJob.Lock() muxObjJob.Lock()
b2 := getJobPayloadUnsafe(p.JobCallbackID64) b2 := getJobPayloadUnsafe(p.JobCallbackID64)
@ -2338,6 +2326,34 @@ func jobShopsSlave(j Job) {
rescheduleJob(j.ID64, 0, time.Unix(maxUnixTimestamp, 0).UTC()) // reschedule so that it gets picked up by shop main ack callback rescheduleJob(j.ID64, 0, time.Unix(maxUnixTimestamp, 0).UTC()) // reschedule so that it gets picked up by shop main ack callback
return return
case cacheObjSubType[`msg_unknown_action`]:
muxObjJob.Lock()
b2 := getJobPayloadUnsafe(p.JobCallbackID64)
var p2 JobPayloadShops
err = json.Unmarshal(b2, &p2)
p2.Msgs = append(p2.Msgs, *m)
err = setJobPayloadJSONUnsafe(p.JobCallbackID64, p2)
logOnError(err, "jobShopsSlave : setJobPayloadJSONUnsafe")
muxObjJob.Unlock()
c := TGCommand{
Type: commandReplyMsg,
Text: fmt.Sprintf("Unknown shop /ws_%s\n", p.Shops[0]),
FromMsgID64: p2.MsgID64,
FromChatID64: p2.ChatID64,
ParseMode: cmdParseModeHTML,
}
TGCmdQueue <- c
for i, link := range p.Shops {
if cwm.Link == link {
p.Shops = append(p.Shops[:i], p.Shops[i+1:]...)
break
}
}
err = setJobPayloadJSON(j.ID64, p)
logOnError(err, "jobShopsSlave : setJobPayloadJSON")
case cacheObjSubType[`msg_shop_main_ack`]: case cacheObjSubType[`msg_shop_main_ack`]:
cwm, err := parseSubTypeMessageShopMainAck(m, rule.re) cwm, err := parseSubTypeMessageShopMainAck(m, rule.re)
logOnError(err, "jobShopsSlave : parseSubTypeMessageShopMainAck") logOnError(err, "jobShopsSlave : parseSubTypeMessageShopMainAck")