From d1a0e62437ca1676576ebc39567a4dc54d76cd6d Mon Sep 17 00:00:00 2001 From: shoopea Date: Sat, 11 May 2019 18:45:05 +0800 Subject: [PATCH] test --- bot.go | 28 ++++++++++++++++++++++++++++ def.go | 12 ++++++++++++ 2 files changed, 40 insertions(+) diff --git a/bot.go b/bot.go index fb894d3..25517c0 100644 --- a/bot.go +++ b/bot.go @@ -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 +} diff --git a/def.go b/def.go index 0977725..474e610 100644 --- a/def.go +++ b/def.go @@ -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