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>
33 lines
1.2 KiB
Go
33 lines
1.2 KiB
Go
package main
|
||
|
||
import (
|
||
"context"
|
||
"fmt"
|
||
"net/http"
|
||
"time"
|
||
)
|
||
|
||
// maxBanClient — отдельный клиент с таймаутом для бана в MAX.
|
||
var maxBanClient = &http.Client{Timeout: 10 * time.Second}
|
||
|
||
// banMaxMember удаляет участника из MAX-чата С ЗАПРЕТОМ возврата (block=true).
|
||
// SDK v1.4.2 умеет только RemoveMember без блокировки (кикнутый может вернуться),
|
||
// а флаг block появился лишь в v2. Чтобы не мигрировать весь MAX-клиент ради одного
|
||
// метода, дёргаем REST напрямую — так же, как upload.go (Authorization: MaxToken).
|
||
func (b *Bridge) banMaxMember(ctx context.Context, chatID, userID int64) error {
|
||
url := fmt.Sprintf("https://platform-api.max.ru/chats/%d/members?user_id=%d&block=true&v=1.2.5", chatID, userID)
|
||
req, err := http.NewRequestWithContext(ctx, http.MethodDelete, url, nil)
|
||
if err != nil {
|
||
return err
|
||
}
|
||
req.Header.Set("Authorization", b.cfg.MaxToken)
|
||
resp, err := maxBanClient.Do(req)
|
||
if err != nil {
|
||
return err
|
||
}
|
||
defer resp.Body.Close()
|
||
if resp.StatusCode >= 300 {
|
||
return fmt.Errorf("max ban http %d", resp.StatusCode)
|
||
}
|
||
return nil
|
||
}
|