update tributes parsing

This commit is contained in:
shoopea 2020-02-07 11:15:56 +08:00
parent 571d054359
commit aed8bb8512
2 changed files with 2 additions and 2 deletions

View File

@ -1874,7 +1874,7 @@
{
"prio": 5000,
"descn": "Tributes stats ack",
"rule": "^(Here is the list of recent villagers tribute\\:)(?P<Tributes>(\\n[1-9]{2} [a-zA-Z]+ [0-9]{4} [0-9]{2}\\:[0-9]{2} - [a-zA-Z]+ x [0-9]+, [0-9]+🔥)+)$",
"rule": "^(Here is the list of recent villagers tribute\\:)(?P<Tributes>(\\n[1-9]{2} [a-zA-Z]+ [0-9]{4} [0-9]{2}\\:[0-9]{2} - [a-zA-Z ]+ x [0-9]+, [0-9]+🔥)+)$",
"msg_type": "msg_tributes_stats_ack",
"chat_id": 0,
"user_id": 0

2
msg.go
View File

@ -280,7 +280,7 @@ func parseSubTypeMessageTributesStatsAck(m *ChatWarsMessage, r *regexp.Regexp) (
cwm.Msg = m
tributes := []ChatWarsTribute{}
re := regexp.MustCompile(`(\n(?P<Date>[1-9]{2} [a-zA-Z]+ [0-9]{4} [0-9]{2}:[0-9]{2}) - (?P<Item>[a-zA-Z]+) x (?P<Quantity>[0-9]+), (?P<Exp>[0-9]+)🔥)`)
re := regexp.MustCompile(`(\n(?P<Date>[1-9]{2} [a-zA-Z]+ [0-9]{4} [0-9]{2}:[0-9]{2}) - (?P<Item>[a-zA-Z ]+) x (?P<Quantity>[0-9]+), (?P<Exp>[0-9]+)🔥)`)
for _, l := range re.FindAllStringSubmatch(r.ReplaceAllString(m.Text, "${Tributes}"), -1) {
tribute := ChatWarsTribute{}
d, err := fromChatWarsDate(re.ReplaceAllString(l[0], "${Date}"))