29 lines
1.6 KiB
Python
29 lines
1.6 KiB
Python
# app/bot/routers/group.py
|
||
from telegram.ext import CommandHandler, MessageHandler, ChatMemberHandler, filters
|
||
from app.bot.handlers.join_info import on_my_chat_member
|
||
from app.bot.handlers.moderation import moderate_message
|
||
from app.bot.handlers.security import security_cmd, dicts_cmd
|
||
from app.bot.handlers.mod_status import mod_status_cmd
|
||
from app.bot.handlers.chat_id_cmd import chat_id_cmd
|
||
|
||
async def spam_import_redirect(update, ctx):
|
||
await update.effective_message.reply_text(
|
||
"Импорт словаря выполняется в ЛС. Откройте чат со мной и пришлите /spam_import.",
|
||
disable_web_page_preview=True
|
||
)
|
||
|
||
def register_group_handlers(app):
|
||
# Команды в группах/супергруппах
|
||
app.add_handler(CommandHandler("security", security_cmd, filters.ChatType.GROUPS))
|
||
app.add_handler(CommandHandler("dicts", dicts_cmd, filters.ChatType.GROUPS))
|
||
app.add_handler(CommandHandler("mod_status", mod_status_cmd, filters.ChatType.GROUPS))
|
||
app.add_handler(CommandHandler("id", chat_id_cmd, filters.ChatType.GROUPS))
|
||
# /spam_import — редирект в ЛС
|
||
app.add_handler(CommandHandler("spam_import", spam_import_redirect, filters.ChatType.GROUPS))
|
||
|
||
# Модерация всех сообщений (privacy mode должен быть Disabled)
|
||
app.add_handler(MessageHandler(filters.ChatType.GROUPS & ~filters.COMMAND, moderate_message))
|
||
|
||
# my_chat_member для уведомлений о добавлении бота
|
||
app.add_handler(ChatMemberHandler(on_my_chat_member, chat_member_types=ChatMemberHandler.MY_CHAT_MEMBER))
|