testtest
This commit is contained in:
parent
239c45db8a
commit
364f541561
25
bot.go
25
bot.go
@ -87,11 +87,32 @@ func botMsgRescan(m *tb.Message) (string, error) {
|
|||||||
}
|
}
|
||||||
r := regexp.MustCompile("^[0-9]+$")
|
r := regexp.MustCompile("^[0-9]+$")
|
||||||
if r.MatchString(m.Payload) {
|
if r.MatchString(m.Payload) {
|
||||||
|
m, _ := strconv.ParseInt(m.Payload, 10, 64)
|
||||||
|
p := JobPayloadRescanMsg{
|
||||||
|
MsgID64: m,
|
||||||
|
}
|
||||||
|
b, _ := json.Marshal(p)
|
||||||
|
err := createJob(objSubTypeJobRescanMsg, 2, time.Now(), b)
|
||||||
|
logOnError(err, "botMsgRescan : createJob(objSubTypeJobRescanMsg)")
|
||||||
|
if err != nil {
|
||||||
|
return "Error scheduling the rescan for msg #" + m.Payload, nil
|
||||||
|
} else {
|
||||||
return "Rescaning msg #" + m.Payload, nil
|
return "Rescaning msg #" + m.Payload, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
r = regexp.MustCompile("^all$")
|
r = regexp.MustCompile("^all$")
|
||||||
if r.MatchString(m.Payload) {
|
if r.MatchString(m.Payload) {
|
||||||
return "Rescaning all msg", nil
|
m, _ := strconv.ParseInt(m.Payload, 10, 64)
|
||||||
|
p := JobPayloadRescanAllMsg{}
|
||||||
|
b, _ := json.Marshal(p)
|
||||||
|
err := createJob(objSubTypeJobRescanAllMsg, 3, time.Now(), b)
|
||||||
|
logOnError(err, "botMsgRescan : createJob(objSubTypeJobRescanAllMsg)")
|
||||||
|
if err != nil {
|
||||||
|
return "Error scheduling the rescan for all msg", nil
|
||||||
|
} else {
|
||||||
|
return "Rescaning all msg scheduled", nil
|
||||||
}
|
}
|
||||||
return `rescaning`, nil
|
}
|
||||||
|
return "/msg_rescan msg_id or /msg_rescan all", nil
|
||||||
}
|
}
|
||||||
|
26
sql.go
26
sql.go
@ -1324,35 +1324,35 @@ func insertMsgAuctionAnnounce(m *ChatWarsMessageAuctionAnnounce) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func createJob(job_type_id int32, payload []byte) error {
|
func createJob(job_type_id int32, priority int32, schedule time.Time, payload []byte) error {
|
||||||
/*
|
|
||||||
res, err := db.Exec(`INSERT INTO obj (obj_type_id, obj_sub_type_id)
|
res, err := db.Exec(`INSERT INTO obj (obj_type_id, obj_sub_type_id)
|
||||||
VALUES (` + strconv.Itoa(objTypeMessage) + `,` + strconv.Itoa(objSubTypeMessageUnknown) + `);`)
|
VALUES (` + strconv.Itoa(objTypeJob) + `,` + strconv.Itoa(job_type_id) + `);`)
|
||||||
|
logOnError(err, "createJob : insert obj")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
objId, err := res.LastInsertId()
|
objId, err := res.LastInsertId()
|
||||||
|
logOnError(err, "createJob : get last insert Id")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
stmt, err := db.Prepare(`INSERT INTO obj_msg (obj_id, msg_id, chat_id, user_id, sender_user_id, date, text)
|
stmt, err := db.Prepare(`INSERT INTO obj_job (obj_id, priority, status, schedule, start, end, payload)
|
||||||
VALUES (?, ?, ?, ?, ?, ?, ?);`)
|
VALUES (?, ?, ?, ?, NULL, NULL, ?);`)
|
||||||
|
logOnError(err, "createJob : prepare insert obj_job")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return err
|
||||||
}
|
}
|
||||||
defer stmt.Close()
|
defer stmt.Close()
|
||||||
|
|
||||||
_, err = stmt.Exec(objId, m.ID64, m.ChatID64, m.UserID64, m.SenderUserID64, m.Date, m.Text)
|
_, err = stmt.Exec(objId, priority, objJobStatusNew, schedule, payload)
|
||||||
|
logOnError(err, "createJob : insert obj_job")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return objId, nil
|
|
||||||
*/
|
|
||||||
return nil
|
return nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadMsgParsingRules() (m map[int]MessageParsingRule, err error) {
|
func loadMsgParsingRules() (m map[int]MessageParsingRule, err error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user