Update zombies.py: fix get_chat_member check and add response.

This commit is contained in:
Meliodas
2023-12-03 19:56:06 +05:30
committed by GitHub
parent d3821f8ce6
commit 447371c194

View File

@@ -9,12 +9,13 @@ from app.core import Message
@bot.add_cmd(cmd="zombies")
async def clean_zombies(bot: bot, message: Message):
me = await bot.get_chat_members(message.chat.id, bot.me.id)
me = await bot.get_chat_member(message.chat.id, bot.me.id)
if me.status not in {ChatMemberStatus.ADMINISTRATOR, ChatMemberStatus.OWNER}:
await message.reply("Cannot clean zombies without being admin.")
return
zombies = 0
admin_zombies = 0
response = await message.reply("Cleaning Zombies....\nthis may take a while")
async for member in bot.get_chat_members(message.chat.id):
try:
if member.user.is_deleted:
@@ -31,7 +32,7 @@ async def clean_zombies(bot: bot, message: Message):
await asyncio.sleep(1)
except FloodWait as e:
await asyncio.sleep(e.value + 3)
response = f"Cleaned <b>{zombies}</b> zombies."
resp_str = f"Cleaned <b>{zombies}</b> zombies."
if admin_zombies:
response += f"\n<b>{admin_zombies}</b> Admin Zombie(s) not Removed."
await message.reply(response)
resp_str += f"\n<b>{admin_zombies}</b> Admin Zombie(s) not Removed."
await response.edit(resp_str)