This commit is contained in:
shoopea 2020-02-03 14:28:11 +08:00
parent 6178e92c51
commit e43e9365b8

4
msg.go
View File

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