test recipe in crafting stock

This commit is contained in:
shoopea 2019-09-23 09:17:47 +08:00
parent 31c9022da8
commit 9a5f62b4c7
2 changed files with 13 additions and 10 deletions

21
msg.go
View File

@ -59,17 +59,20 @@ func parseSubTypeMessageStockAnyAck(m *ChatWarsMessage, r *regexp.Regexp) (*Chat
cwm := ChatWarsMessageStockAnyAck{}
items := []ChatWarsItems{}
re := regexp.MustCompile(`([a-zA-Z ]+) \(([0-9]+)\)\n{0,1}`)
re := regexp.MustCompile(`(📃){0,1}([a-zA-Z ]+) \(([0-9]+)\)( /view_[a-z0-9]+){0,1}\n{0,1}`)
for _, l := range re.FindAllStringSubmatch(r.ReplaceAllString(m.Text, "${Items}"), -1) {
i := getObjItemID(``, l[1])
q, _ := strconv.ParseInt(l[2], 10, 64)
if i != 0 {
item := ChatWarsItems{
ItemID64: i,
Quantity: q,
fmt.Printf("parseSubTypeMessageStockAnyAck : %+q\n", l)
/*
i := getObjItemID(``, l[1])
q, _ := strconv.ParseInt(l[2], 10, 64)
if i != 0 {
item := ChatWarsItems{
ItemID64: i,
Quantity: q,
}
items = append(items, item)
}
items = append(items, item)
}
*/
}
cwm.Stock = items

View File

@ -200,7 +200,7 @@ func resetMsgParsingRules() {
,(5000, ` + strconv.Itoa(objSubTypeMessageEquipStockReq) + `, "Equipment Stock Req", "^🏷Equipment$")
,(5000, ` + strconv.Itoa(objSubTypeMessageCraftStockReq) + `, "Crafting Stock Req", "^⚒Crafting$")
,(5000, ` + strconv.Itoa(objSubTypeMessageStockEmpty) + `, "Stock Empty", "^\\[empty\\]$")
,(5000, ` + strconv.Itoa(objSubTypeMessageStockAnyAck) + `, "Any Stock Ack", "^(?P<Items>(([a-zA-Z ]+ \\([0-9]+\\)\\n{0,1})+))$")
,(5000, ` + strconv.Itoa(objSubTypeMessageStockAnyAck) + `, "Any Stock Ack", "^(?P<Items>(([a-zA-Z 📃]+ \\([0-9]+\\)( /view_[a-z0-9]+){0,1}\\n{0,1})+))$")
,(5000, ` + strconv.Itoa(objSubTypeMessageGDepositReq) + `, "GDeposit Req", "^/g_deposit (?P<Item>[a-z0-9]+) (?P<Quantity>[0-9]+)$")
,(5000, ` + strconv.Itoa(objSubTypeMessageGDepositAck) + `, "GDeposit Ack #2", "^Deposited successfully: (?P<Item>.*) \\((?P<Quantity>[0-9]+)\\)$")
,(5000, ` + strconv.Itoa(objSubTypeMessageGDepositAck) + `, "GDeposit Ack #1", "^Deposited (?P<Item>.*) \\((?P<Quantity>[0-9]+)\\) successfully$")