mirror of
https://github.com/BEARlogin/max-telegram-bridge-bot.git
synced 2026-07-09 17:18:37 +00:00
- MAX media upload: drop deprecated &v=1.2.5 from /uploads and /messages (MAX returns 404 with it; photos/videos broke, text was unaffected). - Run group moderation before discussion-comment ingest. - Generic addon extension hooks; core stays agnostic to their semantics: CrosspostAllowed, CrosspostDeliverable, HandleMaxCommand. - Customizable /help and /start from a file next to the binary (HELP_FILE). - /link command; optional web_app menu button (MINIAPP_URL). - Track bot chats and pair owners; migrations 017-019. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
27 lines
873 B
Go
27 lines
873 B
Go
package main
|
|
|
|
import (
|
|
"strconv"
|
|
"sync"
|
|
"time"
|
|
)
|
|
|
|
// botChatSeen — троттлинг записи bot_chats (не писать в БД на каждое сообщение).
|
|
var botChatSeen sync.Map // "platform:chatID" → unix последней записи
|
|
|
|
// noteBotChat запоминает чат, где есть бот (для мастера линковки в кабинете).
|
|
// Троттлится: пишет не чаще раза в 10 минут на чат.
|
|
func (b *Bridge) noteBotChat(platform string, chatID int64, title, chatType string) {
|
|
if chatID == 0 {
|
|
return
|
|
}
|
|
key := platform + ":" + strconv.FormatInt(chatID, 10)
|
|
now := time.Now().Unix()
|
|
if v, ok := botChatSeen.Load(key); ok {
|
|
if last, _ := v.(int64); now-last < 600 {
|
|
return
|
|
}
|
|
}
|
|
botChatSeen.Store(key, now)
|
|
b.repo.RecordBotChat(platform, chatID, title, chatType)
|
|
}
|