This commit is contained in:
shoopea 2020-01-05 17:42:29 +08:00
parent 1b51a5c492
commit f79e9d5f66

7
bot.go
View File

@ -931,7 +931,7 @@ func botGWithdraw(m *tb.Message) {
r := regexp.MustCompile("^(( )*[a-z0-9]+ [0-9]+( )*)+$") r := regexp.MustCompile("^(( )*[a-z0-9]+ [0-9]+( )*)+$")
if r.MatchString(m.Payload) { if r.MatchString(m.Payload) {
rx := regexp.MustCompile("[a-z0-9]+ [0-9]+") rx := regexp.MustCompile("(?P<Item>[a-z0-9]+) (?P<Quantity>[0-9]+)")
p := JobPayloadGWithdraw{ p := JobPayloadGWithdraw{
MsgID64: int64(m.ID), MsgID64: int64(m.ID),
ChatID64: m.Chat.ID, ChatID64: m.Chat.ID,
@ -939,8 +939,9 @@ func botGWithdraw(m *tb.Message) {
} }
items := []ChatWarsItems{} items := []ChatWarsItems{}
for _, l := range rx.FindAllStringSubmatch(m.Payload, -1) { for _, l := range rx.FindAllStringSubmatch(m.Payload, -1) {
i := l[0] log.Printf("botGWithdraw : %s\n", l)
q, _ := strconv.ParseInt(l[1], 10, 64) i := r.ReplaceAllString(l, "${Item}")
q, _ := strconv.ParseInt(r.ReplaceAllString(l, "${Quantity}"), 10, 64)
item := ChatWarsItems{ item := ChatWarsItems{
Item: i, Item: i,
Quantity: q, Quantity: q,