File size: 1,359 Bytes
2768977
 
 
13a9f4f
2768977
 
 
 
 
13a9f4f
 
 
 
 
 
2768977
 
 
 
 
 
 
 
 
 
 
13a9f4f
 
2768977
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from pyrogram import *
from pyrogram.types import *
from pyrogram.enums import *
from pyrogram.errors import *
from akn.utils.database import db
from akn.langs import transdev

@Client.on_message(filters.command("rmzombies"))
async def arzrmzombies_command(client, message):
    bot = (await client.get_chat_member(message.chat.id, client.me.id)).privileges
    if not bot.can_restrict_members:
        return await message.reply_text("I don't have enough permissions to restrict members.")
    if not message.chat.type in [ChatType.GROUP, ChatType.SUPERGROUP]:
        return await message.reply_text("This command can only be used in groups.")
    
    deleted_accounts = []
    async for m in client.get_chat_members(message.chat.id):
        if m.user.is_bot:
           continue
        if m.user.is_deleted:
           deleted_accounts.append(m.user.id)
    if len(deleted_accounts) == 0:
        return await message.reply_text("No deleted accounts found in the group.")
    for user_id in deleted_accounts:
        try:
            await client.ban_chat_member(message.chat.id, user_id)
        except UserAdminInvalid:
           pass
        except Exception as e:
            return await message.reply_text(f"Failed to kick user {user_id}: {e}")
    await message.reply_text(f"Removed {len(deleted_accounts)} deleted accounts from the group.")