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>
35 lines
1 KiB
Go
35 lines
1 KiB
Go
package main
|
||
|
||
import (
|
||
"os"
|
||
"path/filepath"
|
||
"regexp"
|
||
"strings"
|
||
)
|
||
|
||
var helpTagRe = regexp.MustCompile(`<[^>]+>`)
|
||
|
||
// customHelp читает кастомный текст /help и /start из файла: HELP_FILE (env) либо
|
||
// help.html рядом с бинарём. Пусто ⇒ используется встроенный текст. Читается каждый
|
||
// раз — инструкцию можно править без рестарта (положил файл рядом и всё).
|
||
func customHelp() string {
|
||
path := os.Getenv("HELP_FILE")
|
||
if path == "" {
|
||
if exe, err := os.Executable(); err == nil {
|
||
path = filepath.Join(filepath.Dir(exe), "help.html")
|
||
}
|
||
}
|
||
if path == "" {
|
||
return ""
|
||
}
|
||
b, err := os.ReadFile(path)
|
||
if err != nil {
|
||
return ""
|
||
}
|
||
return strings.TrimSpace(string(b))
|
||
}
|
||
|
||
// helpPlain — версия без HTML-тегов (для MAX, где markdown/HTML не рендерится).
|
||
func helpPlain(s string) string {
|
||
return strings.TrimSpace(helpTagRe.ReplaceAllString(s, ""))
|
||
}
|