Files
plain-ub-overfork/app/plugins/admin/zombies.py
overspend1 8fe355ed0c Update README and alive command for @overspend1 fork
- Updated README title to show OVERSPEND1 FORK
- Changed maintainer credit to @overspend1
- Updated alive command to show @overspend1 as creator instead of Meliodas
2025-07-25 20:27:05 +02:00

47 lines
1.3 KiB
Python

import asyncio
from datetime import UTC, datetime, timedelta
from pyrogram.errors import FloodWait
from app import BOT, Message
from app.extra_config import ADMIN_STATUS
@BOT.add_cmd(cmd="zombies")
async def clean_zombies(bot: BOT, message: Message):
if not message.chat._raw.admin_rights:
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(chat_id=message.chat.id):
try:
if member.user.is_deleted:
if member.status in ADMIN_STATUS:
admin_zombies += 1
continue
zombies += 1
await bot.ban_chat_member(
chat_id=message.chat.id,
user_id=member.user.id,
until_date=datetime.now(UTC) + timedelta(seconds=60),
)
await asyncio.sleep(1)
except FloodWait as e:
await asyncio.sleep(e.value + 3)
resp_str = f"Cleaned <b>{zombies}</b> zombies."
if admin_zombies:
resp_str += f"\n<b>{admin_zombies}</b> Admin Zombie(s) not Removed."
await response.edit(resp_str)