testtest
This commit is contained in:
parent
239c45db8a
commit
364f541561
27
bot.go
27
bot.go
@ -87,11 +87,32 @@ func botMsgRescan(m *tb.Message) (string, error) {
|
||||
}
|
||||
r := regexp.MustCompile("^[0-9]+$")
|
||||
if r.MatchString(m.Payload) {
|
||||
return "Rescaning msg #" + m.Payload, nil
|
||||
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
|
||||
}
|
||||
|
||||
}
|
||||
r = regexp.MustCompile("^all$")
|
||||
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
|
||||
}
|
||||
|
48
sql.go
48
sql.go
@ -1324,35 +1324,35 @@ func insertMsgAuctionAnnounce(m *ChatWarsMessageAuctionAnnounce) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func createJob(job_type_id int32, payload []byte) error {
|
||||
/*
|
||||
res, err := db.Exec(`INSERT INTO obj (obj_type_id, obj_sub_type_id)
|
||||
VALUES (` + strconv.Itoa(objTypeMessage) + `,` + strconv.Itoa(objSubTypeMessageUnknown) + `);`)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
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)
|
||||
VALUES (` + strconv.Itoa(objTypeJob) + `,` + strconv.Itoa(job_type_id) + `);`)
|
||||
logOnError(err, "createJob : insert obj")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
objId, err := res.LastInsertId()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
objId, err := res.LastInsertId()
|
||||
logOnError(err, "createJob : get last insert Id")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
stmt, err := db.Prepare(`INSERT INTO obj_msg (obj_id, msg_id, chat_id, user_id, sender_user_id, date, text)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?);`)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
defer stmt.Close()
|
||||
stmt, err := db.Prepare(`INSERT INTO obj_job (obj_id, priority, status, schedule, start, end, payload)
|
||||
VALUES (?, ?, ?, ?, NULL, NULL, ?);`)
|
||||
logOnError(err, "createJob : prepare insert obj_job")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer stmt.Close()
|
||||
|
||||
_, err = stmt.Exec(objId, m.ID64, m.ChatID64, m.UserID64, m.SenderUserID64, m.Date, m.Text)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
_, err = stmt.Exec(objId, priority, objJobStatusNew, schedule, payload)
|
||||
logOnError(err, "createJob : insert obj_job")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return objId, nil
|
||||
*/
|
||||
return nil
|
||||
|
||||
}
|
||||
|
||||
func loadMsgParsingRules() (m map[int]MessageParsingRule, err error) {
|
||||
|
Loading…
Reference in New Issue
Block a user