This repository has been archived on 2024-08-21. You can view files and clone it, but cannot push or open issues or pull requests.
EmojiCaptchaBot/plugins/commands/ban_failed.py

41 lines
1.1 KiB
Python
Raw Normal View History

2023-08-14 13:11:53 +03:00
import logging
from pyrogram import filters
from pyrogram.types import Message
from classes.pyroclient import PyroClient
2023-08-23 12:12:26 +03:00
from modules.utils import is_permitted
2023-08-14 13:11:53 +03:00
logger = logging.getLogger(__name__)
@PyroClient.on_message(
~filters.scheduled
& filters.group
& filters.command(["ban_failed"], prefixes=["/"]) # type: ignore
)
async def command_ban_failed(app: PyroClient, message: Message):
2023-08-17 17:37:42 +03:00
group = await app.find_group(message.chat.id)
2023-08-14 13:11:53 +03:00
locale = group.select_locale(app, message.from_user)
2023-08-23 12:12:26 +03:00
if not (await is_permitted(app, group, message=message)):
2023-08-14 13:11:53 +03:00
await message.reply_text(
app._("permission_denied", "messages", locale=locale), quote=True
)
return
if group.ban_failed:
await message.reply_text(
app._("ban_failed_disabled", "messages", locale=locale)
)
else:
await message.reply_text(app._("ban_failed_enabled", "messages", locale=locale))
logger.info(
"Ban on fail in group %s has been set to %s",
group.id,
not group.ban_failed,
)
await group.set_ban_failed(not group.ban_failed)