update g_stock trigger
This commit is contained in:
parent
07796e06a3
commit
cb66651b84
8
bot.go
8
bot.go
@ -639,7 +639,13 @@ func botListParsingRule(m *tb.Message) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func botGStock(m *tb.Message) {
|
func botGStock(m *tb.Message) {
|
||||||
if !m.Private() {
|
if m.Private() {
|
||||||
|
clt, ok := getLockedClient(m.Chat.ID, false)
|
||||||
|
if !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
clt.Mux.Unlock()
|
||||||
|
} else if m.Chat.ID != cfg.Bot.Mainchat {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
19
job.go
19
job.go
@ -717,14 +717,19 @@ func jobGStock(j Job) {
|
|||||||
case 0: // send /g_stock_res
|
case 0: // send /g_stock_res
|
||||||
p.Progress = 1
|
p.Progress = 1
|
||||||
b, _ := json.Marshal(&p)
|
b, _ := json.Marshal(&p)
|
||||||
err = createJobCallback(objSubTypeJobGStock, j.UserID64, objSubTypeMessageGStockAnyAck, b, 1*time.Minute)
|
jobID64, err := createJob(objSubTypeJobGStock, objJobPriority, j.UserID64, 0, time.Unix(maxUnixTimestamp, 0).UTC(), b)
|
||||||
logOnError(err, "jobGStock : createJobCallback")
|
logOnError(err, "jobGStock : createJob")
|
||||||
|
setJobCallback(jobID64, j.UserID64, objSubTypeMessageGStockAnyAck)
|
||||||
|
setJobCallback(jobID64, j.UserID64, objSubTypeMessageBusy)
|
||||||
|
err = setJobTimeout(jobID64, 1*time.Minute)
|
||||||
|
logOnError(err, "jobGStock : setJobTimeout")
|
||||||
clientSendCWMsg(cfg.Bot.Admin, "/g_stock_res")
|
clientSendCWMsg(cfg.Bot.Admin, "/g_stock_res")
|
||||||
case 1: // send /g_stock_alch
|
case 1: // send /g_stock_alch
|
||||||
msg, err := getObjMsg(j.Trigger)
|
msg, err := getObjMsg(j.Trigger)
|
||||||
logOnError(err, "jobGStock : getObjMsg msg")
|
logOnError(err, "jobGStock : getObjMsg msg")
|
||||||
rule, err := getMsgParsingRule(msg)
|
rule, err := getMsgParsingRule(msg)
|
||||||
logOnError(err, "jobGStock : getMsgParsingRule")
|
logOnError(err, "jobGStock : getMsgParsingRule")
|
||||||
|
if rule.MsgTypeID == objSubTypeMessageGStockAnyAck {
|
||||||
cwm, err := parseSubTypeMessageGStockAnyAck(msg, rule.re)
|
cwm, err := parseSubTypeMessageGStockAnyAck(msg, rule.re)
|
||||||
for _, v := range cwm.Stock {
|
for _, v := range cwm.Stock {
|
||||||
p.Stock = append(p.Stock, v)
|
p.Stock = append(p.Stock, v)
|
||||||
@ -734,6 +739,16 @@ func jobGStock(j Job) {
|
|||||||
err = createJobCallback(objSubTypeJobGStock, j.UserID64, objSubTypeMessageGStockAnyAck, b, 1*time.Minute)
|
err = createJobCallback(objSubTypeJobGStock, j.UserID64, objSubTypeMessageGStockAnyAck, b, 1*time.Minute)
|
||||||
logOnError(err, "jobGStock : createJobCallback")
|
logOnError(err, "jobGStock : createJobCallback")
|
||||||
clientSendCWMsg(cfg.Bot.Admin, "/g_stock_alch")
|
clientSendCWMsg(cfg.Bot.Admin, "/g_stock_alch")
|
||||||
|
} else if rule.MsgTypeID == objSubTypeMessageBusy {
|
||||||
|
m := TGCommand{
|
||||||
|
Type: commandReplyMsg,
|
||||||
|
Text: "Busy, please retry later.",
|
||||||
|
FromMsgID64: p.MsgID64,
|
||||||
|
FromChatID64: p.ChatID64,
|
||||||
|
ParseMode: cmdParseModeHTML,
|
||||||
|
}
|
||||||
|
TGCmdQueue <- m
|
||||||
|
}
|
||||||
case 2: // send /g_stock_misc
|
case 2: // send /g_stock_misc
|
||||||
msg, err := getObjMsg(j.Trigger)
|
msg, err := getObjMsg(j.Trigger)
|
||||||
logOnError(err, "jobGStock : getObjMsg msg")
|
logOnError(err, "jobGStock : getObjMsg msg")
|
||||||
|
7
obj.go
7
obj.go
@ -724,10 +724,9 @@ func getSilentObjItemID(code string, name string) int64 {
|
|||||||
//log.Printf("Matching item code %s with %s.\n", code, obj.Code)
|
//log.Printf("Matching item code %s with %s.\n", code, obj.Code)
|
||||||
return obj.ObjID64
|
return obj.ObjID64
|
||||||
}
|
}
|
||||||
if ok, _ := regexp.MatchString(`^a[0-9]+[a-e]$`, code); ok {
|
if ok, _ := regexp.MatchString(`^(a|w)[0-9]+[a-e]$`, code); ok {
|
||||||
code2 := code[:len(code)-1]
|
// log.Printf("Matching quality item code %s with %s.\n", code, code[:len(code)-1])
|
||||||
log.Printf("Matching quality item code %s with %s.\n", code, code2)
|
if obj, ok := cacheObjItem[code[:len(code)-1]]; ok {
|
||||||
if obj, ok := cacheObjItem[code2]; ok {
|
|
||||||
return obj.ObjID64
|
return obj.ObjID64
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user