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"`
|
ItemID64 int64 `json:"item_id"`
|
||||||
Quantity int64 `json:"quantity"`
|
Quantity int64 `json:"quantity"`
|
||||||
Price int64 `json:"price"`
|
Price int64 `json:"price"`
|
||||||
|
Status string `json:"status"`
|
||||||
Link string `json:"link"`
|
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 : ActiveDeals : %s\n", r.ReplaceAllString(m.Text, "${ActiveDeals}"))
|
||||||
log.Printf("parseSubTypeMessageExchangeAck : MaxDeals : %s\n", r.ReplaceAllString(m.Text, "${MaxDeals}"))
|
log.Printf("parseSubTypeMessageExchangeAck : MaxDeals : %s\n", r.ReplaceAllString(m.Text, "${MaxDeals}"))
|
||||||
/*
|
cwm.ActiveDeals, _ = strconv.ParseInt(r.ReplaceAllString(m.Text, "${ActiveDeals}"), 10, 64)
|
||||||
re := regexp.MustCompile(`([a-zA-Z ]+)\n([0-9]+) x ([0-9]+)💰 [Cancelling] (.*)\n`)
|
cwm.MaxDeals, _ = strconv.ParseInt(r.ReplaceAllString(m.Text, "${MaxDeals}"), 10, 64)
|
||||||
for _, l := range re.FindAllStringSubmatch(r.ReplaceAllString(m.Text, "${Items}"), -1) {
|
|
||||||
|
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])
|
i := getObjItemID(``, l[1])
|
||||||
q, _ := strconv.ParseInt(l[2], 10, 64)
|
q, _ := strconv.ParseInt(l[2], 10, 64)
|
||||||
|
p, _ := strconv.ParseInt(l[3], 10, 64)
|
||||||
|
l := l[4]
|
||||||
if i != 0 {
|
if i != 0 {
|
||||||
item := ChatWarsItems{
|
deal := ChatWarsExchangeDeal{
|
||||||
ItemID64: i,
|
ItemID64: i,
|
||||||
Quantity: q,
|
Quantity: q,
|
||||||
|
Price: p,
|
||||||
|
Link: l,
|
||||||
|
}
|
||||||
|
deals = append(items, deal)
|
||||||
}
|
}
|
||||||
items = append(items, item)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
cwm.DealList = deals
|
cwm.DealList = deals
|
||||||
cwm.Msg = m
|
cwm.Msg = m
|
||||||
return &cwm, nil
|
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` +
|
`Your deals \\((?P<ActiveDeals>[0-9]+)/(?P<MaxDeals>[0-9]+)\\):\\n` +
|
||||||
`(?P<Deals>(?s:.*))\\n` +
|
`(?P<Deals>(?s:.*))\\n` +
|
||||||
`Your last 10 comitted trades: /trades$")
|
`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")
|
failOnError(err, "resetMsgParsingRules : populate table msg_rules")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user