test exchange

This commit is contained in:
shoopea 2019-09-14 16:43:18 +08:00
parent 31a4799798
commit e4a1e6618d
3 changed files with 14 additions and 9 deletions

1
def.go
View File

@ -107,6 +107,7 @@ type ChatWarsExchangeDeal struct {
ItemID64 int64 `json:"item_id"`
Quantity int64 `json:"quantity"`
Price int64 `json:"price"`
Status string `json:"status"`
Link string `json:"link"`
}

19
msg.go
View File

@ -29,20 +29,27 @@ func parseSubTypeMessageExchangeAck(m *ChatWarsMessage, r *regexp.Regexp) (*Chat
log.Printf("parseSubTypeMessageExchangeAck : ActiveDeals : %s\n", r.ReplaceAllString(m.Text, "${ActiveDeals}"))
log.Printf("parseSubTypeMessageExchangeAck : MaxDeals : %s\n", r.ReplaceAllString(m.Text, "${MaxDeals}"))
/*
re := regexp.MustCompile(`([a-zA-Z ]+)\n([0-9]+) x ([0-9]+)💰 [Cancelling] (.*)\n`)
for _, l := range re.FindAllStringSubmatch(r.ReplaceAllString(m.Text, "${Items}"), -1) {
cwm.ActiveDeals, _ = strconv.ParseInt(r.ReplaceAllString(m.Text, "${ActiveDeals}"), 10, 64)
cwm.MaxDeals, _ = strconv.ParseInt(r.ReplaceAllString(m.Text, "${MaxDeals}"), 10, 64)
if cwm.ActiveDeals > 0 {
re := regexp.MustCompile(`([a-zA-Z ]+)\n([0-9]+) x ([0-9]+)💰 \[(.*)\] (.*)\n`)
for _, l := range re.FindAllStringSubmatch(r.ReplaceAllString(m.Text, "${Deals}"), -1) {
i := getObjItemID(``, l[1])
q, _ := strconv.ParseInt(l[2], 10, 64)
p, _ := strconv.ParseInt(l[3], 10, 64)
l := l[4]
if i != 0 {
item := ChatWarsItems{
deal := ChatWarsExchangeDeal{
ItemID64: i,
Quantity: q,
Price: p,
Link: l,
}
items = append(items, item)
deals = append(items, deal)
}
}
*/
}
cwm.DealList = deals
cwm.Msg = m
return &cwm, nil

View File

@ -225,9 +225,6 @@ func resetMsgParsingRules() {
`Your deals \\((?P<ActiveDeals>[0-9]+)/(?P<MaxDeals>[0-9]+)\\):\\n` +
`(?P<Deals>(?s:.*))\\n` +
`Your last 10 comitted trades: /trades$")
,(4000, ` + strconv.Itoa(objSubTypeMessageExchangeAck) + `, "Exchange Ack", "^Here you can buy and sell some items.\\n` +
`To find a tradable item just type:\\n` +
`(?s:.*)$")
;`)
failOnError(err, "resetMsgParsingRules : populate table msg_rules")
}