diff --git a/README.md b/README.md index 8ccbfc4..4ccbd63 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,10 @@ ChirpNestBot -- [ ] Eliminate cache map race conditions (all maps with read/write) -- [ ] Export/import all messages +- [ ] Test HTML in message +- [ ] Update auction from broadcast +- [ ] Update old auctions with client +- [ ] Convert config to json +- [ ] Eliminate cache map race conditions (all maps with read/write) and use redis ? +- [ ] Transform import/export to jobs - [ ] Turn on/off queue consumption - [ ] Client de-registration announce - [ ] Items parsing/identification @@ -16,6 +20,7 @@ ChirpNestBot - [ ] Experience graphs & forecast - [ ] Impersonate - [x] Foray interception +- [x] Export/import all messages Progression : - 0 -> 4 : Forest + Foray ; - 5 -> 10 : Forest + Foray + Arena ; \ No newline at end of file diff --git a/bot.go b/bot.go index 638c079..a11f599 100644 --- a/bot.go +++ b/bot.go @@ -23,6 +23,7 @@ func BotHandlers(b *tb.Bot) { }) b.Handle("/test", botTest) + b.Handle("/test_html", botTestHTML) b.Handle("/msg_rescan", botMsgRescan) b.Handle("/msg_rescan_all", botMsgRescanAll) b.Handle("/msg_dump", botMsgDump) @@ -109,6 +110,22 @@ func botHelp(m *tb.Message) { return } +func botTestHTML(m *tb.Message) { + if !m.Private() { + return + } + c := TGCommand{ + Type: commandReplyMsg, + Text: "Defend", + FromMsgID64: int64(m.ID), + FromChatID64: m.Chat.ID, + ParseMode: cmdParseModeHTML, + } + TGCmdQueue <- c + + return +} + func botTest(m *tb.Message) { if !m.Private() { return @@ -267,13 +284,6 @@ func botMsgLoad(m *tb.Message) { } r := regexp.MustCompile("^(http|https)://[a-z0-9./]+.zip$") // https://dump.siteop.biz/20190609163137.backup.zip if r.MatchString(m.Payload) { - c := TGCommand{ - Type: commandReplyMsg, - Text: "Got file", - FromMsgID64: int64(m.ID), - FromChatID64: m.Chat.ID, - } - TGCmdQueue <- c resp, err := http.Get(m.Payload) logOnError(err, "botMsgLoad : Get") @@ -281,9 +291,26 @@ func botMsgLoad(m *tb.Message) { buf := new(bytes.Buffer) buf.ReadFrom(resp.Body) - err = UnzipMessages(buf.Bytes()) + + c := TGCommand{ + Type: commandReplyMsg, + Text: "File downloaded.", + FromMsgID64: int64(m.ID), + FromChatID64: m.Chat.ID, + } + TGCmdQueue <- c + + err := UnzipMessages(buf.Bytes()) logOnError(err, "botMsgLoad : UnzipMessages") + c = TGCommand{ + Type: commandReplyMsg, + Text: "Messages injected.", + FromMsgID64: int64(m.ID), + FromChatID64: m.Chat.ID, + } + TGCmdQueue <- c + } else { c := TGCommand{ Type: commandReplyMsg, diff --git a/def.go b/def.go index 218912a..65179ef 100644 --- a/def.go +++ b/def.go @@ -44,6 +44,7 @@ type TGCommand struct { ToUserID64 int64 `json:"to_user_id"` Text string `json:"text"` Document tb.Document `json:"document"` + ParseMode int64 `json:"parse_mode"` } type ChatWarsCastle struct { @@ -246,6 +247,10 @@ const ( commandRefreshMsg = 5 commandSendDocument = 6 + cmdParseModePlain = 1 + cmdParseModeMarkDown = 2 + cmdParseModeHTML = 3 + objTypeUser = 1 objTypeGuild = 2 objTypeMessage = 3 diff --git a/rules.go b/rules.go index 5b94b75..e3b5f0f 100644 --- a/rules.go +++ b/rules.go @@ -9,7 +9,13 @@ func resetMsgParsingRules() { failOnError(err, "resetMsgParsingRules : truncate table msg_rules") _, err = db.Exec(`INSERT INTO msg_rules (prio, msg_type_id, descn, rule) - VALUES (5000, ` + strconv.Itoa(objSubTypeMessageReportAck) + `, "Player war report", "^(?P[🐉🦅🐺🦈🦌🥔🌑])(\\[(?P[A-Z0-9]{1,3})\\]){0,1}(?P([A-Za-z0-9 ]*)) ⚔:(?P[0-9]+)(?P\\((-|\\+)[0-9]+\\)){0,1} 🛡:(?P[0-9]+) Lvl: (?P[0-9]+)\\nYour result on the battlefield:\\n(🔥Exp: (?P[0-9]+)\\n){0,1}(💰Gold: (?P\\-{0,1}[0-9]+)\\n){0,1}(📦Stock: (?P\\-{0,1}[0-9]+)){0,1}(\\n(?P(🔋Stamina restored))){0,1}(\\n(?P(⚡Critical strike))){0,1}$") + VALUES (5000, ` + strconv.Itoa(objSubTypeMessageReportAck) + `, "Player war report", "^(?P[🐉🦅🐺🦈🦌🥔🌑])(\\[(?P[A-Z0-9]{1,3})\\]){0,1}(?P([A-Za-z0-9 ]*)) ⚔:(?P[0-9]+)(?P\\((-|\\+)[0-9]+\\)){0,1} 🛡:(?P[0-9]+) Lvl: (?P[0-9]+)\\n` + + `Your result on the battlefield:\\n` + + `(🔥Exp: (?P[0-9]+)){0,1}(\\n)*` + + `(💰Gold: (?P\\-{0,1}[0-9]+)){0,1}(\\n)*` + + `(📦Stock: (?P\\-{0,1}[0-9]+)){0,1}(\\n)*` + + `(❤️Hp: (?P\\-[0-9]+)){0,1}(\\n)*` + + `((?P(🔋Stamina restored))){0,1}(\\n(?P(⚡Critical strike))){0,1}$") ,(5000, ` + strconv.Itoa(objSubTypeMessageAuctionAnnounce) + `, "Auction annouce", "^Lot #(?P[0-9]+) : (?P.*)\\n(Quality: (?P.*)\\n){0,1}(Condition: (?P.*)\\n){0,1}Seller: (?P[🐉🦅🐺🦈🦌🥔🌑])( ){0,1}(\\[(?P[A-Z0-9]{1,3})\\]){0,1}(?P.*){0,1}\\nCurrent price: (?P[0-9]+) pouch\\(es\\)\\nBuyer: (None|(?P[🐉🦅🐺🦈🦌🥔🌑])( ){0,1}(\\[(?P[A-Z0-9]{1,3})\\]){0,1}(?P.*){0,1})\\nEnd At: (?P.*)\\nStatus: (?P.*)(\\n)*(?s:.*)") ,(5000, ` + strconv.Itoa(objSubTypeMessageTimeAck) + `, "Time", "^In Chat Wars world now\\n(?P