This commit is contained in:
shoopea 2020-02-03 14:34:21 +08:00
parent 428bfe102c
commit 0e21b49707

5
msg.go
View File

@ -278,7 +278,7 @@ func parseSubTypeMessageGStockAnyAck(m *ChatWarsMessage, r *regexp.Regexp) (*Cha
func parseSubTypeMessageTributesStatsAck(m *ChatWarsMessage, r *regexp.Regexp) (*ChatWarsMessageTributesStatsAck, error) {
cwm := ChatWarsMessageTributesStatsAck{}
cwm.Msg = m
cwm.Tributes = new([]ChatWarsTribute{}, 0)
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]+)🔥)`)
for _, l := range re.FindAllStringSubmatch(r.ReplaceAllString(m.Text, "${Tributes}"), -1) {
@ -293,9 +293,10 @@ func parseSubTypeMessageTributesStatsAck(m *ChatWarsMessage, r *regexp.Regexp) (
log.Printf("parseSubTypeMessageTributesStatsAck : Quantity : %s => %d\n", re.ReplaceAllString(l[0], "${Quantity}"), tribute.Quantity)
tribute.Exp, _ = strconv.ParseInt(r.ReplaceAllString(l[0], "${Exp}"), 10, 64)
log.Printf("parseSubTypeMessageTributesStatsAck : Exp : %s => %d \n", re.ReplaceAllString(l[0], "${Exp}"), tribute.Exp)
cwm.Tributes = append(cwm.Tributes, tribute)
cwm.Tributes = append(tributes, tribute)
log.Printf("parseSubTypeMessageTributesStatsAck : #%d / #%d : %d + %d (%v)\n", cwm.Msg.TGUserID64, tribute.ItemID64, tribute.Quantity, tribute.Exp, tribute.Date)
}
cwm.Tributes = tributes
return &cwm, nil
}