From d0184531063f92e775a51062af9bc298ac425ce4 Mon Sep 17 00:00:00 2001 From: shoopea Date: Wed, 31 Jul 2019 10:06:05 +0800 Subject: [PATCH] Adding internal timeout to job pillage --- def.go | 3 ++- job.go | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/def.go b/def.go index cc0ea7a..03ba699 100644 --- a/def.go +++ b/def.go @@ -214,7 +214,8 @@ type JobPayloadMsgRefresh struct { } type JobPayloadPillage struct { - ObjID64 int64 `json:"obj_id"` + ObjID64 int64 `json:"obj_id"` + Date time.Time `json:"date"` } type JobPayloadTribute struct { diff --git a/job.go b/job.go index 386ddcb..e1f832f 100644 --- a/job.go +++ b/job.go @@ -351,6 +351,17 @@ func jobPillage(j Job) { 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{ Type: commandSendMsg, Text: fmt.Sprintf("No outcome for the pillage yet"),