This commit is contained in:
shoopea 2019-05-11 18:45:05 +08:00
parent 2605a326c1
commit d1a0e62437
2 changed files with 40 additions and 0 deletions

28
bot.go
View File

@ -25,6 +25,13 @@ func BotHandlers(b *tb.Bot) {
b.Send(m.Sender, s)
}
})
b.Handle("/msg_rescan_all", func(m *tb.Message) {
s, err := botMsgRescanAll(m)
logOnError(err, "/msg_rescan_all")
if err == nil {
b.Send(m.Sender, s)
}
})
b.Handle(tb.OnPhoto, botPhoto)
b.Handle(tb.OnChannelPost, botChannelPost)
@ -107,3 +114,24 @@ func botMsgRescan(m *tb.Message) (string, error) {
}
return "/msg_rescan msg_id or /msg_rescan all", nil
}
func botMsgRescanAll(m *tb.Message) (string, error) {
fmt.Println("botRescanMsgAll :", m.Text)
if !m.Private() {
fmt.Println("botRescanMsg : !m.Private()")
return ``, nil
}
p := JobPayloadRescanMsg{
Query: fmt.Sprintf("SELECT o.id FROM obj o WHERE o.obj_type_id = %d AND o.obj_sub_type_id = %d;", objTypeMessage, objSubTypeMessageUnknown),
}
b, _ := json.Marshal(p)
log.Printf("botMsgRescan : json : %s\n", string(b))
err := createJob(objSubTypeJobRescanMsg, objJobPriorityRescanAllMsg, time.Now(), b)
logOnError(err, "botMsgRescan : createJob(objSubTypeJobRescanMsg)")
if err != nil {
return "Error scheduling the rescan for all msg", nil
} else {
return "Rescaning all msg scheduled", nil
}
return "/msg_rescan msg_id or /msg_rescan all", nil
}

12
def.go
View File

@ -28,6 +28,18 @@ type ChatWarsMessageAuctionAnnounce struct {
End time.Time `json:"end"`
}
type ChatWarsMessageMiniWar struct {
Report map[string]ChatWarsMessageMiniWarCastle `json:"castle"`
Time time.Time `json:"time"`
}
type ChatWarsMessageMiniWarCastle struct {
Result string `json:"result"`
Gold int32 `json:"gold"`
Stock int32 `json:"stock"`
Points int32 `json:"points"`
}
type MessageParsingRule struct {
ID int32
Priority int32