update resource ack
This commit is contained in:
parent
f9a51b54a0
commit
ae32a555f5
13
job.go
13
job.go
@ -734,7 +734,9 @@ func jobGDeposit(j Job) {
|
||||
|
||||
if p.Status == 0 { /* handle remaining resources to be stored */
|
||||
var res, misc, alch, craft, equip bool = false, false, false, false, false
|
||||
log.Printf("jobGDeposit : Checking items (%d).\n", len(p.ResObjID64))
|
||||
var delay time.Duration = 0 * time.Second
|
||||
var b []byte
|
||||
|
||||
if len(p.ResObjID64) > 0 {
|
||||
for i := range p.ResObjID64 {
|
||||
obj, err := getObjItem(p.ResObjID64[i])
|
||||
@ -760,43 +762,36 @@ func jobGDeposit(j Job) {
|
||||
}
|
||||
}
|
||||
}
|
||||
log.Printf("jobGDeposit : Sending messages.\n")
|
||||
var delay time.Duration = 10 * time.Second
|
||||
var b []byte
|
||||
|
||||
if res || alch || misc || craft || equip {
|
||||
p.Status = 1
|
||||
b, _ = json.Marshal(&p)
|
||||
}
|
||||
if res {
|
||||
log.Printf("jobGDeposit : Sending res.\n")
|
||||
clientSendCWMsgDelay(p.ChatID64, `📦Resources`, delay)
|
||||
err = createJobCallback(objSubTypeJobGDeposit, j.UserID64, objSubTypeMessageOrderbookAck, b, delay)
|
||||
logOnError(err, "jobGDeposit : createJobCallback")
|
||||
delay = delay + 2*time.Second
|
||||
}
|
||||
if alch {
|
||||
log.Printf("jobGDeposit : Sending alch.\n")
|
||||
clientSendCWMsgDelay(p.ChatID64, `⚗️Alchemy`, delay)
|
||||
err = createJobCallback(objSubTypeJobGDeposit, j.UserID64, objSubTypeMessageOrderbookAck, b, delay)
|
||||
logOnError(err, "jobGDeposit : createJobCallback")
|
||||
delay = delay + 2*time.Second
|
||||
}
|
||||
if misc {
|
||||
log.Printf("jobGDeposit : Sending misc.\n")
|
||||
clientSendCWMsgDelay(p.ChatID64, `🗃Misc`, delay)
|
||||
err = createJobCallback(objSubTypeJobGDeposit, j.UserID64, objSubTypeMessageOrderbookAck, b, delay)
|
||||
logOnError(err, "jobGDeposit : createJobCallback")
|
||||
delay = delay + 2*time.Second
|
||||
}
|
||||
if craft {
|
||||
log.Printf("jobGDeposit : Sending craft.\n")
|
||||
clientSendCWMsgDelay(p.ChatID64, `⚒Crafting`, delay)
|
||||
err = createJobCallback(objSubTypeJobGDeposit, j.UserID64, objSubTypeMessageOrderbookAck, b, delay)
|
||||
logOnError(err, "jobGDeposit : createJobCallback")
|
||||
delay = delay + 2*time.Second
|
||||
}
|
||||
if equip {
|
||||
log.Printf("jobGDeposit : Sending equip.\n")
|
||||
clientSendCWMsgDelay(p.ChatID64, `🏷Equipment`, delay)
|
||||
err = createJobCallback(objSubTypeJobGDeposit, j.UserID64, objSubTypeMessageOrderbookAck, b, delay)
|
||||
logOnError(err, "jobGDeposit : createJobCallback")
|
||||
|
12
msg.go
12
msg.go
@ -43,6 +43,18 @@ func parseSubTypeMessageStockAck(m *ChatWarsMessage, r *regexp.Regexp) (*ChatWar
|
||||
items = append(items, item)
|
||||
}
|
||||
}
|
||||
re := regexp.MustCompile(`\n\/sg_[0-9]+ ([a-zA-Z ]+) \(([0-9]+)\)`)
|
||||
for _, l := range re.FindAllStringSubmatch(r.ReplaceAllString(m.Text, "${Items}"), -1) {
|
||||
i := getObjItemID(``, l[1])
|
||||
q, _ := strconv.ParseInt(l[2], 10, 64)
|
||||
if i != 0 {
|
||||
item := ChatWarsItems{
|
||||
ItemID64: i,
|
||||
Quantity: q,
|
||||
}
|
||||
items = append(items, item)
|
||||
}
|
||||
}
|
||||
cwm.Used, _ = strconv.ParseInt(r.ReplaceAllString(m.Text, "${Used}"), 10, 64)
|
||||
cwm.Available, _ = strconv.ParseInt(r.ReplaceAllString(m.Text, "${Available}"), 10, 64)
|
||||
cwm.Stock = items
|
||||
|
3
rules.go
3
rules.go
@ -123,6 +123,9 @@ func resetMsgParsingRules() {
|
||||
,(5000, ` + strconv.Itoa(objSubTypeMessageStockReq) + `, "Stock Req", "^/stock$")
|
||||
,(5000, ` + strconv.Itoa(objSubTypeMessageStockAck) + `, "Stock Ack", "^📦Storage \\((?P<Used>[0-9]+)\\/(?P<Available>[0-9]+)\\):` +
|
||||
`(?P<Items>(\\n[a-zA-Z ]+ \\([0-9]+\\))*)$")
|
||||
,(5000, ` + strconv.Itoa(objSubTypeMessageStockAck) + `, "Stock Ack", "^📦Storage \\((?P<Used>[0-9]+)\\/(?P<Available>[0-9]+)\\):` +
|
||||
`Use \\/sg_\\{code\\} to trade some amount of resource for .* 💰 \\/pcs\\n` +
|
||||
`(?P<Items>(\\n\\/sg_[0-9]+ [a-zA-Z ]+ \\([0-9]+\\))*)$")
|
||||
,(5000, ` + strconv.Itoa(objSubTypeMessageMiscReq) + `, "Misc Req", "^/misc$")` + /*
|
||||
,(5000, ` + strconv.Itoa(objSubTypeMessageUnionWar) + `, "Union war report", "^(🏠Trade union news:\\n){0,1}` +
|
||||
`(((?P<Union>[A-Z][a-z]+ [A-Z][a-z]+) was (?P<StatusUnion>(easily defended|defended successfully|breached.|easily breached.|closely breached.))( Attackers have pillaged union for (?P<Loot>[0-9]+) stock){0,1}:\\n` +
|
||||
|
Loading…
Reference in New Issue
Block a user