This commit is contained in:
shoopea 2019-05-27 11:20:05 +08:00
parent ea4b3c357c
commit c8f223a8d2

16
job.go
View File

@ -235,12 +235,12 @@ func jobPillage(j Job) {
,obj op ,obj op
,obj_msg omp ,obj_msg omp
,obj_job oj ,obj_job oj
where oj.obj_id = ` + strconv.Itoa(j.ID64) + ` where oj.obj_id = ` + strconv.FormatInt(j.ID64, 10) + `
and omx.user_id = oj.user_id and omx.user_id = oj.user_id
and omx.sender_user_id = ` + strconv.Itoa(userID64ChtWrsBot) + ` and omx.sender_user_id = ` + strconv.Itoa(userID64ChtWrsBot) + `
and omx.obj_id = ox.id and omx.obj_id = ox.id
and ox.obj_sub_type_id in (` + strconv.Itoa(objSubTypeMessagePillageGo) + `, ` + strconv.Itoa(objSubTypeMessagePillageTimeout) + ` and ox.obj_sub_type_id in (` + strconv.Itoa(objSubTypeMessagePillageGo) + `, ` + strconv.Itoa(objSubTypeMessagePillageTimeout) + `
and op.id = ` + strconv.Itoa(r.ObjID64) + ` and op.id = ` + strconv.FormatInt(r.ObjID64, 10) + `
and omp.obj_id = op.id and omp.obj_id = op.id
and omx.date between omp.date and addtime(omp.date, '0 0:3:30.000000');`) and omx.date between omp.date and addtime(omp.date, '0 0:3:30.000000');`)
if len(ids) > 1 { // issue there ? if len(ids) > 1 { // issue there ?
@ -255,17 +255,17 @@ func jobPillage(j Job) {
logOnError(err, "jobPillage : getMsg(objSubTypeMessagePillageGo, objSubTypeMessagePillageTimeout)") logOnError(err, "jobPillage : getMsg(objSubTypeMessagePillageGo, objSubTypeMessagePillageTimeout)")
if err == nil { if err == nil {
if m.Date.Add(60 * time.Second).After(time.Now()) { if m.Date.Add(60 * time.Second).After(time.Now()) {
msgTypeID, err := getObjSubTypeId(ids[0]) msgTypeID64, err := getObjSubTypeId(ids[0])
logOnError(err, "jobPillage : getObjSubTypeId") logOnError(err, "jobPillage : getObjSubTypeId")
if err == nil { if err == nil {
if msgTypeID == objSubTypeMessagePillageGo { if msgTypeID64 == objSubTypeMessagePillageGo {
s := TGCommand{ s := TGCommand{
Type: commandSendMsg, Type: commandSendMsg,
Text: fmt.Sprintf("We avoided a pillage (%s)", m.Date.Format(time.RFC3339)), Text: fmt.Sprintf("We avoided a pillage (%s)", m.Date.Format(time.RFC3339)),
ToUserID64: j.UserID64, ToUserID64: j.UserID64,
} }
TGCmdQueue <- s TGCmdQueue <- s
} else if msgTypeId == objSubTypeMessagePillageTimeout { } else if msgTypeID64 == objSubTypeMessagePillageTimeout {
s := TGCommand{ s := TGCommand{
Type: commandSendMsg, Type: commandSendMsg,
Text: fmt.Sprintf("We got pillaged (%s)", m.Date.Format(time.RFC3339)), Text: fmt.Sprintf("We got pillaged (%s)", m.Date.Format(time.RFC3339)),
@ -283,7 +283,7 @@ func jobPillage(j Job) {
} }
} }
} }
err := setJobDone(j.ID64) err = setJobDone(j.ID64)
logOnError(err, "jobSetDone : setJobDone") logOnError(err, "jobSetDone : setJobDone")
return return
} }
@ -293,7 +293,7 @@ func jobPillage(j Job) {
from obj ox from obj ox
,obj_msg omx ,obj_msg omx
,obj_job oj ,obj_job oj
where oj.obj_id = ` + strconv.Itoa(j.ID64) + ` where oj.obj_id = ` + strconv.FormatInt(j.ID64, 10) + `
and omx.user_id = oj.user_id and omx.user_id = oj.user_id
and omx.sender_user_id = oj.user_id and omx.sender_user_id = oj.user_id
and omx.obj_id = ox.id and omx.obj_id = ox.id
@ -317,7 +317,7 @@ func jobPillage(j Job) {
c := TGCommand{ c := TGCommand{
Type: commandSendMsg, Type: commandSendMsg,
Text: "/go", Text: "/go",
FromUserID64: m.Chat.ID, FromUserID64: j.UserID64,
ToChatID64: userID64ChtWrsBot, ToChatID64: userID64ChtWrsBot,
} }
MQTGCmdQueue <- c MQTGCmdQueue <- c