This commit is contained in:
shoopea 2020-01-02 19:56:43 +08:00
parent 231c0ea357
commit c5e26e5849
2 changed files with 4 additions and 4 deletions

View File

@ -182,13 +182,13 @@
{ {
"prio": 5000, "prio": 5000,
"descn": "Stock Ack", "descn": "Stock Ack",
"rule": "^📦Storage \\((?P<Used>[0-9]+)\\/(?P<Available>[0-9]+)\\):(?P<Items>(\\n[a-zA-Z❄ ]+ \\([0-9]+\\))*)$", "rule": "^📦Storage \\((?P<Used>[0-9]+)\\/(?P<Available>[0-9]+)\\):(?P<Items>(\\n[^\\(]+ \\([0-9]+\\))*)$",
"msg_type": "stock_ack" "msg_type": "stock_ack"
}, },
{ {
"prio": "4000", "prio": "4000",
"descn": "Stock Ack", "descn": "Stock Ack",
"rule": "^📦Storage \\((?P<Used>[0-9]+)\\/(?P<Available>[0-9]+)\\):\\nUse \\/sg_\\{code\\} to trade some amount of resource for .*💰\\/pcs\\n(?P<Items>(\\n\\/sg_[0-9]+ [a-zA-Z❄ ]+ \\([0-9]+\\))*)$", "rule": "^📦Storage \\((?P<Used>[0-9]+)\\/(?P<Available>[0-9]+)\\):\\nUse \\/sg_\\{code\\} to trade some amount of resource for .*💰\\/pcs\\n(?P<Items>(\\n\\/sg_[0-9]+ [^\\(]+ \\([0-9]+\\))*)$",
"msg_type": "stock_ack" "msg_type": "stock_ack"
}, },
{ {

4
msg.go
View File

@ -130,7 +130,7 @@ func parseSubTypeMessageStockAck(m *ChatWarsMessage, r *regexp.Regexp) (*ChatWar
cwm := ChatWarsMessageStockAck{} cwm := ChatWarsMessageStockAck{}
items := []ChatWarsItems{} items := []ChatWarsItems{}
re := regexp.MustCompile(`\n([a-zA-Z ]+) \(([0-9]+)\)`) re := regexp.MustCompile(`\n([^\(]+) \(([0-9]+)\)`)
for _, l := range re.FindAllStringSubmatch(r.ReplaceAllString(m.Text, "${Items}"), -1) { for _, l := range re.FindAllStringSubmatch(r.ReplaceAllString(m.Text, "${Items}"), -1) {
i := getObjItemID(``, l[1]) i := getObjItemID(``, l[1])
q, _ := strconv.ParseInt(l[2], 10, 64) q, _ := strconv.ParseInt(l[2], 10, 64)
@ -142,7 +142,7 @@ func parseSubTypeMessageStockAck(m *ChatWarsMessage, r *regexp.Regexp) (*ChatWar
items = append(items, item) items = append(items, item)
} }
} }
re = regexp.MustCompile(`\n\/sg_[0-9]+ ([a-zA-Z ]+) \(([0-9]+)\)`) re = regexp.MustCompile(`\n\/sg_[0-9]+ ([^\(]+) \(([0-9]+)\)`)
for _, l := range re.FindAllStringSubmatch(r.ReplaceAllString(m.Text, "${Items}"), -1) { for _, l := range re.FindAllStringSubmatch(r.ReplaceAllString(m.Text, "${Items}"), -1) {
i := getObjItemID(``, l[1]) i := getObjItemID(``, l[1])
q, _ := strconv.ParseInt(l[2], 10, 64) q, _ := strconv.ParseInt(l[2], 10, 64)