From fbfdbf22f8d4eff255a13634b69bdb01dff16e9f Mon Sep 17 00:00:00 2001 From: shoopea Date: Mon, 21 Oct 2019 14:45:47 +0800 Subject: [PATCH] update ambush dynamic reaction --- README.md | 3 ++- bot.go | 5 +++-- client.go | 16 ++++++++++++++++ workers.go | 3 ++- 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 6ea0607..9a3d0da 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ ChirpNestBot +- [ ] Remove duplicate messages from external channels where there was client+bot feed - [ ] Identify TG user_id - [ ] Add autobid option for auctions - [ ] Check for not launching concurrent msg rescan jobs @@ -23,7 +24,7 @@ ChirpNestBot - [ ] Vault valuation - [ ] Experience graphs & forecast - [ ] Impersonate -- [ ] Link TelegramUserID and UserID +- [ ] Link TelegramUserID and UserID (can use historic auction messages) - [ ] Issue with Squire in the /g_roles ? - [x] Foray interception - [ ] Handle Foray timeout to stop spamming in case something goes bad diff --git a/bot.go b/bot.go index c284b04..62f110c 100644 --- a/bot.go +++ b/bot.go @@ -100,8 +100,6 @@ func botQuery(q *tb.Query) { func botText(m *tb.Message) { PrintText(m) - b, _ := json.Marshal(m) - log.Printf("botText : %s\n", string(b)) if (m.Chat.ID == cfg.Bot.Depositchat || m.Chat.ID == cfg.Bot.Mainchat) && int64(m.OriginalSender.ID) == chtwrsbotID64 { cwm := ChatWarsMessage{ @@ -115,6 +113,9 @@ func botText(m *tb.Message) { } MQCWMsgQueue <- cwm + } else { + b, _ := json.Marshal(m) + log.Printf("botText : %s\n", string(b)) } // all the text messages that weren't // captured by existing handlers diff --git a/client.go b/client.go index 21e23e8..56bc9df 100644 --- a/client.go +++ b/client.go @@ -127,3 +127,19 @@ func clientGetCWUserID64(tgUserID64 int64) (int64, error) { } return 0, errors.New("Unknown user_id.") } + +func clientSpreadQuestResultAmbush(cwm ChatWarsMessageQuestResultAmbush) error { + /* + muxClients.RLock() + var ret string + for id, c := range clients { + if c.Active { + ret = fmt.Sprintf("%s%s | UserID : %d | TelegramID : %d (online)\n", ret, c.Login, c.CWUserID64, id) + } else { + ret = fmt.Sprintf("%s%s | UserID : %d | TelegramID : %d (offline)\n", ret, c.Login, c.CWUserID64, id) + } + } + muxClients.RUnlock() + */ + return nil +} diff --git a/workers.go b/workers.go index 5594e95..d2b42ac 100644 --- a/workers.go +++ b/workers.go @@ -397,7 +397,8 @@ func SQLIdentifyMsgWorker(id int, objIds <-chan int64) { } MQTGCmdQueue <- s } else if m.ChatID64 == cfg.Bot.Mainchat { - + err = clientSpreadQuestResultAmbush(cwm) + logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : clientSpreadQuestResultAmbush.") } } case objSubTypeMessagePillageInc: