test exchange
This commit is contained in:
parent
31a4799798
commit
e4a1e6618d
1
def.go
1
def.go
@ -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
19
msg.go
@ -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,
|
||||
}
|
||||
deals = append(items, deal)
|
||||
}
|
||||
items = append(items, item)
|
||||
}
|
||||
}
|
||||
*/
|
||||
cwm.DealList = deals
|
||||
cwm.Msg = m
|
||||
return &cwm, nil
|
||||
|
3
rules.go
3
rules.go
@ -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")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user