Adding internal timeout to job pillage

This commit is contained in:
shoopea 2019-07-31 10:06:05 +08:00
parent 90853271d3
commit d018453106
2 changed files with 13 additions and 1 deletions

1
def.go
View File

@ -215,6 +215,7 @@ type JobPayloadMsgRefresh struct {
type JobPayloadPillage struct { type JobPayloadPillage struct {
ObjID64 int64 `json:"obj_id"` ObjID64 int64 `json:"obj_id"`
Date time.Time `json:"date"`
} }
type JobPayloadTribute struct { type JobPayloadTribute struct {

11
job.go
View File

@ -351,6 +351,17 @@ func jobPillage(j Job) {
return return
} }
// is the job outdated now ?
if r.Date.Before(time.Now().Sub(3*time.Minute + 30*time.Second)) {
s := TGCommand{
Type: commandSendMsg,
Text: fmt.Sprintf("Pillage interception expired"),
ToUserID64: j.UserID64,
}
TGCmdQueue <- s
return
}
s := TGCommand{ s := TGCommand{
Type: commandSendMsg, Type: commandSendMsg,
Text: fmt.Sprintf("No outcome for the pillage yet"), Text: fmt.Sprintf("No outcome for the pillage yet"),