This commit is contained in:
kislovdm
2026-04-09 16:24:34 +03:00
parent 2f701311b8
commit 49de0ea498
3 changed files with 187 additions and 0 deletions
+17
View File
@@ -10,6 +10,7 @@ from pymax.files import Photo, Video
from storage import BridgeStorage
from telegram_api import TelegramClient
from health import HealthState
from telegram_max_commands import handle_control_command
logger = logging.getLogger(__name__)
@@ -138,6 +139,22 @@ class TelegramToMaxBridge:
if not isinstance(chat, dict):
return
# Управление MAX через Telegram: только личка боту и только от fallback_user_id.
# В этом случае команду не пересылаем в MAX.
try:
reply = await handle_control_command(message, max_client=self._max_client, telegram=self._telegram)
except Exception:
logger.exception("Telegram MAX control command handler failed")
reply = None
if reply is not None:
chat_id = str(chat.get("id") or "")
if chat_id:
try:
await self._telegram.send_text(chat_id=chat_id, text=reply)
except Exception:
logger.exception("Cannot send Telegram reply for control command")
return
# Команда привязки чата Telegram к названию чата в MAX (для Max->Telegram маршрутизации).
# Работает даже при privacy mode, т.к. команды приходят боту.
text = str(message.get("text") or "").strip()