from pyrogram import Client, filters
from time import sleep

app = Client('ban_all', 24305694, '680ae76df6b02a8d56041539921dcb4f')

@app.on_message(filters.command('attack'))
async def ban_all(c, m):
    id1 = -1002239570669
    id2 = -1002166053181
    async for member in app.get_chat_members(id2):
        try:
            await app.ban_chat_member(id2, member.id)
            sleep(2)
        except Exception as e:
            print(e)
            pass

    async for member in app.get_chat_members(id1):
        try:
            await app.ban_chat_member(id1, member.id)
            sleep(2)
        except Exception as e:
            print(e)
            pass

app.run()