# =======================================
# _ __ __ __ _
# | |/ /___ | \/ | ___ __| |___
# | ' // _ \ | |\/| |/ _ \ / _` / __|
# | . \ __/ | | | | (_) | (_| \__ \
# |_|\_\___| |_| |_|\___/ \__,_|___/
# @ke_mods
# =======================================
# meta developer: @ke_mods
from .. import loader, utils
from telethon.tl.types import ChatBannedRights
from telethon.tl.functions.channels import EditBannedRequest
from telethon.tl.types import ChannelParticipantsKicked
@loader.tds
class UnbanAllMod(loader.Module):
strings = {
"name": "UnbanAll",
"no_rights": "❌ I don't have administrator rights to remove restrictions.",
"success": "✅ All banned chat members have been unbanned.",
"unban_in_process": "👀 Unbanning users...",
"no_banned": "ℹ️ There are no banned members in this chat.",
"error_occured": "💢 An error occurred while unbanning user {}:\n{}",
}
strings_ru = {
"no_rights": "❌ У меня нет прав администратора для снятия ограничений.",
"success": "✅ Все забаненные участники чата были разблокированы.",
"unban_in_process": "👀 Разбаниваю пользователей...",
"no_banned": "ℹ️ В этом чате нет забаненных участников.",
"error_occured": "💢 Произошла ошибка при разблокировке пользователя {}:\n{}",
}
@loader.command(ru_doc="- Разбанить всех забаненных пользователей")
async def unbanallcmd(self, message):
"""- Unban all banned users"""
chat = await message.get_chat()
if not chat.admin_rights and not chat.creator:
await utils.answer(message, self.strings["no_rights"])
return
await utils.answer(message, self.strings["unban_in_process"])
no_banned = True
async for user in self.client.iter_participants(
message.chat_id, filter=ChannelParticipantsKicked
):
no_banned = False
try:
await self.client(EditBannedRequest(
message.chat_id,
user.id,
ChatBannedRights(until_date=0)
))
except Exception as e:
await utils.answer(message, self.strings["error_occured"].format(user.id, e))
pass
if no_banned:
await utils.answer(message, self.strings["no_banned"])
return
await utils.answer(message, self.strings["success"])