This commit is contained in:
shoopea 2019-05-16 10:49:34 +08:00
parent 03e0d85446
commit 324b0ae8c7
3 changed files with 27 additions and 7 deletions

4
bot.go
View File

@ -84,7 +84,9 @@ func botMsgRescan(m *tb.Message) (string, error) {
r := regexp.MustCompile("^[0-9]+$")
if r.MatchString(m.Payload) {
p := JobPayloadRescanMsg{
Query: fmt.Sprintf("SELECT o.id FROM obj o WHERE o.id = %s AND o.obj_type_id = %d AND o.obj_sub_type_id = %d;", m.Payload, objTypeMessage, objSubTypeMessageUnknown),
Query: fmt.Sprintf("SELECT o.id FROM obj o WHERE o.id = %s AND o.obj_type_id = %d AND o.obj_sub_type_id = %d;", m.Payload, objTypeMessage, objSubTypeMessageUnknown),
MsgID64: int64(m.ID),
ChatID64: m.Chat.ID,
}
b, _ := json.Marshal(p)
log.Printf("botMsgRescan : json : %s\n", string(b))

7
def.go
View File

@ -108,9 +108,10 @@ type JobPayloadRescanMsg struct {
}
type JobPayloadSetDone struct {
JobID64 int64 `json:"job_id"`
MsgID64 int64 `json:"msg_id"`
ChatID64 int64 `json:"chat_id"`
JobID64 int64 `json:"job_id"`
MsgID64 int64 `json:"msg_id"`
ChatID64 int64 `json:"chat_id"`
Text string `json:"test"`
}
const (

23
job.go
View File

@ -24,22 +24,39 @@ func jobRescan(j Job) {
}
b, _ := json.Marshal(p)
err := createJob(objSubTypeJobRescanMsg, objJobPriorityRescanChildMsg, time.Now(), b)
err := createJob(objSubTypeJobRescanMsg, objJobPriorityRescanChildMsg, j.UserID64, time.Now(), b)
logOnError(err, "jobRescan : createJob(objSubTypeJobRescanMsg)")
}
p := JobPayloadSetDone{
JobID64: j.ID64,
JobID64: j.ID64,
MsgID64: j.MsgID64,
ChatID64: j.ChatID64,
Text: fmt.Sprintf("%d messages processed.", len(ids)),
}
b, _ := json.Marshal(p)
err := createJob(objSubTypeJobSetJobDone, objJobPriority, time.Now(), b)
err := createJob(objSubTypeJobSetJobDone, objJobPriority, j.UserID64, time.Now(), b)
logOnError(err, "jobRescan : createJob(objSubTypeJobSetJobDone)")
} else if len(ids) == 1 {
SQLMsgIdentifyQueue <- ids[0]
err = setJobDone(j.ID64)
logOnError(err, "jobRescan : setJobDone(1)")
m := TGCommand{
Type: commandReplyMsg,
Text: "One message processed.",
FromMsgID64: j.MsgID64,
FromChatID64j.ChatID64,
}
TGCmdQueue <- m
} else {
err = setJobDone(j.ID64)
logOnError(err, "jobRescan : setJobDone(0)")
m := TGCommand{
Type: commandReplyMsg,
Text: "No message processed.",
FromMsgID64: j.MsgID64,
FromChatID64j.ChatID64,
}
TGCmdQueue <- m
}
return
}