test
This commit is contained in:
parent
7c94be55b9
commit
7b859ac266
@ -124,6 +124,11 @@
|
||||
"name": "Pillage incoming",
|
||||
"obj_type": "msg"
|
||||
},
|
||||
{
|
||||
"intl_id": "msg_pillage_inc2",
|
||||
"name": "Pillage incoming v2",
|
||||
"obj_type": "msg"
|
||||
},
|
||||
{
|
||||
"intl_id": "msg_pillage_go",
|
||||
"name": "Pillage go",
|
||||
|
@ -25,12 +25,20 @@
|
||||
},
|
||||
{
|
||||
"prio": 5000,
|
||||
"descn": "Pillage Inc",
|
||||
"descn": "Pillage Inc #1",
|
||||
"rule": "^You were strolling around on your horse when you noticed (\\[(?P<Guild>[A-Z0-9]{1,3})\\]){0,1}(?P<Attacker>.*) of .{1}(?P<Castle>(Moonlight|Wolfpack|Deerhorn|Dragonscale|Sharkteeth|Potato|Highnest)) Castle trying to pillage a local village. To stop him click /go$",
|
||||
"msg_type": "msg_pillage_inc",
|
||||
"chat_id": 0,
|
||||
"user_id": 0
|
||||
},
|
||||
{
|
||||
"prio": 5000,
|
||||
"descn": "Pillage Inc #2",
|
||||
"rule": "^You were strolling around on your horse when you noticed (\\[(?P<Guild>[A-Z0-9]{1,3})\\]){0,1}(?P<Attacker>.*) of .{1}(?P<Castle>(Moonlight|Wolfpack|Deerhorn|Dragonscale|Sharkteeth|Potato|Highnest)) Castle trying to pillage a local village\\.$",
|
||||
"msg_type": "msg_pillage_inc2",
|
||||
"chat_id": 0,
|
||||
"user_id": 0
|
||||
},
|
||||
{
|
||||
"prio": 5000,
|
||||
"descn": "Go",
|
||||
|
31
job.go
31
job.go
@ -464,7 +464,7 @@ func jobPillage(j Job) {
|
||||
err = json.Unmarshal(j.Payload, &r)
|
||||
logOnError(err, "jobPillage : Unmarshal payload")
|
||||
|
||||
// check if we have a acknoledgment of go or a timeout within 3m30 of the PillageInc from the Job
|
||||
// check if we have a acknowledgment of go or a timeout within 3m30 of the PillageInc from the Job
|
||||
ids := getSQLListID64(`SELECT ox.id
|
||||
FROM obj ox
|
||||
,obj_msg omx
|
||||
@ -581,7 +581,7 @@ func jobPillage(j Job) {
|
||||
|
||||
if len(ids) > 0 { // we did, so we reschedule the job to check the outcome and wait
|
||||
m, err := getObjMsg(ids[0])
|
||||
logOnError(err, "jobPillage : getMsg(cacheObjSubType[`msg_go`], 10)")
|
||||
logOnError(err, "jobPillage : getMsg")
|
||||
if err == nil {
|
||||
s := TGCommand{
|
||||
Type: commandSendMsg,
|
||||
@ -593,7 +593,34 @@ func jobPillage(j Job) {
|
||||
err = rescheduleJob(j.ID64, j.Trigger, time.Now().Add(30*time.Second).UTC())
|
||||
logOnError(err, "jobPillage : rescheduleJob(cacheObjSubType[`msg_go`], 10)")
|
||||
} else { //no /go in the last 30 sec so we go ahead, send one and reschedule to check again in 25sec
|
||||
t, err := getObjSubTypeId(r.ObjID64)
|
||||
logOnError(err, "jobPillage : getObjSubTypeId")
|
||||
if t == cacheObjSubType[`msg_pillage_inc`] {
|
||||
clientSendCWMsg(j.UserID64, "/go")
|
||||
} else if t == cacheObjSubType[`msg_pillage_inc2`] {
|
||||
m, err := getObjMsg(r.ObjID64)
|
||||
if len(m.Callbacks) != 1 {
|
||||
s := TGCommand{
|
||||
Type: commandSendMsg,
|
||||
Text: fmt.Sprintf("More than one button (%s)", m.Date.Format(time.RFC3339)),
|
||||
ToUserID64: j.UserID64,
|
||||
}
|
||||
TGCmdQueue <- s
|
||||
} else {
|
||||
for _, c := range m.Callbacks {
|
||||
if c.Name == `🧹Intervene` {
|
||||
clientCallback(j.UserID64, m.ID64, m.ChatID64, c.Name, c.Data)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
s := TGCommand{
|
||||
Type: commandSendMsg,
|
||||
Text: fmt.Sprintf("Unknown pillage version (%s)", m.Date.Format(time.RFC3339)),
|
||||
ToUserID64: j.UserID64,
|
||||
}
|
||||
TGCmdQueue <- s
|
||||
}
|
||||
err = rescheduleJob(j.ID64, j.Trigger, time.Now().Add(30*time.Second).UTC())
|
||||
logOnError(err, "jobPillage : rescheduleJob")
|
||||
|
||||
|
@ -406,6 +406,8 @@ func SQLIdentifyMsgWorker(id int, objIds <-chan int64) {
|
||||
}
|
||||
}
|
||||
case cacheObjSubType[`msg_pillage_inc`]:
|
||||
fallthrough
|
||||
case cacheObjSubType[`msg_pillage_inc2`]:
|
||||
cwm, err := parseSubTypeMessagePillageInc(m, rule.re)
|
||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_pillage_inc`]")
|
||||
cwm.ObjID64 = objId
|
||||
|
Loading…
Reference in New Issue
Block a user