Files
tg_post_min/app/bot/routers/channel.py
2025-08-28 04:28:37 +09:00

19 lines
847 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# app/bot/routers/channel.py
from telegram.ext import CommandHandler, filters
async def channel_redirect(update, ctx):
try:
await update.effective_message.reply_text(
"⚠️ В канале команды не поддерживаются. "
"Откройте ЛС со мной и выполните:\n"
"• /bind @username (или -100…)\n"
"• или /add_group и перешлите сюда пост из канала.",
disable_web_page_preview=True
)
except Exception:
pass
def register_channel_handlers(app):
# В канале любые «команды настроек» переводим в ЛС
app.add_handler(CommandHandler(["start","settings","security","dicts","spam_import"], channel_redirect, filters.ChatType.CHANNEL))