Spaces:
Paused
Paused
| import os | |
| import asyncio | |
| from pyrogram import Client, filters | |
| from pyrogram.types import Message | |
| from pyrogram import enums | |
| from pyrogram.enums import ChatMemberStatus | |
| from pyrogram.errors import FloodWait | |
| from DragMusic import app | |
| from time import time | |
| import asyncio | |
| from DragMusic.utils.extraction import extract_user | |
| # Define a dictionary to track the last message timestamp for each user | |
| user_last_message_time = {} | |
| user_command_count = {} | |
| # Define the threshold for command spamming (e.g., 20 commands within 60 seconds) | |
| SPAM_THRESHOLD = 2 | |
| SPAM_WINDOW_SECONDS = 5 | |
| # ------------------------------------------------------------------------------- # | |
| chatQueue = [] | |
| stopProcess = False | |
| # ------------------------------------------------------------------------------- # | |
| async def remove(client, message): | |
| global stopProcess | |
| try: | |
| try: | |
| sender = await app.get_chat_member(message.chat.id, message.from_user.id) | |
| has_permissions = sender.privileges | |
| except: | |
| has_permissions = message.sender_chat | |
| if has_permissions: | |
| bot = await app.get_chat_member(message.chat.id, "self") | |
| if bot.status == ChatMemberStatus.MEMBER: | |
| await message.reply( | |
| "➠ | ɪ ɴᴇᴇᴅ ᴀᴅᴍɪɴ ᴘᴇʀᴍɪssɪᴏɴs ᴛᴏ ʀᴇᴍᴏᴠᴇ ᴅᴇʟᴇᴛᴇᴅ ᴀᴄᴄᴏᴜɴᴛs." | |
| ) | |
| else: | |
| if len(chatQueue) > 30: | |
| await message.reply( | |
| "➠ | ɪ'ᴍ ᴀʟʀᴇᴀᴅʏ ᴡᴏʀᴋɪɴɢ ᴏɴ ᴍʏ ᴍᴀxɪᴍᴜᴍ ɴᴜᴍʙᴇʀ ᴏғ 30 ᴄʜᴀᴛs ᴀᴛ ᴛʜᴇ ᴍᴏᴍᴇɴᴛ. ᴘʟᴇᴀsᴇ ᴛʀʏ ᴀɢᴀɪɴ sʜᴏʀᴛʟʏ." | |
| ) | |
| else: | |
| if message.chat.id in chatQueue: | |
| await message.reply( | |
| "➠ | ᴛʜᴇʀᴇ's ᴀʟʀᴇᴀᴅʏ ᴀɴ ᴏɴɢɪɪɴɢ ᴘʀᴏᴄᴇss ɪɴ ᴛʜɪs ᴄʜᴀᴛ. ᴘʟᴇᴀsᴇ [ /stop ] ᴛᴏ sᴛᴀʀᴛ ᴀ ɴᴇᴡ ᴏɴᴇ." | |
| ) | |
| else: | |
| chatQueue.append(message.chat.id) | |
| deletedList = [] | |
| async for member in app.get_chat_members(message.chat.id): | |
| if member.user.is_deleted == True: | |
| deletedList.append(member.user) | |
| else: | |
| pass | |
| lenDeletedList = len(deletedList) | |
| if lenDeletedList == 0: | |
| await message.reply("⟳ | ɴᴏ ᴅᴇʟᴇᴛᴇᴅ ᴀᴄᴄᴏᴜɴᴛs ɪɴ ᴛʜɪs ᴄʜᴀᴛ.") | |
| chatQueue.remove(message.chat.id) | |
| else: | |
| k = 0 | |
| processTime = lenDeletedList * 1 | |
| temp = await app.send_message( | |
| message.chat.id, | |
| f"🧭 | ᴛᴏᴛᴀʟ ᴏғ {lenDeletedList} ᴅᴇʟᴇᴛᴇᴅ ᴀᴄᴄᴏᴜɴᴛs ʜᴀs ʙᴇᴇɴ ᴅᴇᴛᴇᴄᴛᴇᴅ.\n🥀 | ᴇsᴛɪᴍᴀᴛᴇᴅ ᴛɪᴍᴇ: {processTime} sᴇᴄᴏɴᴅs ғʀᴏᴍ ɴᴏᴡ.", | |
| ) | |
| if stopProcess: | |
| stopProcess = False | |
| while len(deletedList) > 0 and not stopProcess: | |
| deletedAccount = deletedList.pop(0) | |
| try: | |
| await app.ban_chat_member( | |
| message.chat.id, deletedAccount.id | |
| ) | |
| except Exception: | |
| pass | |
| k += 1 | |
| await asyncio.sleep(10) | |
| if k == lenDeletedList: | |
| await message.reply( | |
| f"✅ | sᴜᴄᴄᴇssғᴜʟʟʏ ʀᴇᴍᴏᴠᴇᴅ ᴀʟʟ ᴅᴇʟᴇᴛᴇᴅ ᴀᴄᴄɪᴜɴᴛs ғʀᴏᴍ ᴛʜɪs ᴄʜᴀᴛ." | |
| ) | |
| await temp.delete() | |
| else: | |
| await message.reply( | |
| f"✅ | sᴜᴄᴄᴇssғᴜʟʟʏ ʀᴇᴍᴏᴠᴇᴅ {k} ᴅᴇʟᴇᴛᴇᴅ ᴀᴄᴄᴏᴜɴᴛs ғʀᴏᴍ ᴛʜɪs ᴄʜᴀᴛ." | |
| ) | |
| await temp.delete() | |
| chatQueue.remove(message.chat.id) | |
| else: | |
| await message.reply( | |
| "👮🏻 | sᴏʀʀʏ, ᴏɴʟʏ ᴀᴅᴍɪɴ ᴄᴀɴ ᴇxᴇᴄᴜᴛᴇ ᴛʜɪs ᴄᴏᴍᴍᴀɴᴅ." | |
| ) | |
| except FloodWait as e: | |
| await asyncio.sleep(e.value) | |
| # ------------------------------------------------------------------------------- # | |
| async def admins(client, message): | |
| try: | |
| adminList = [] | |
| ownerList = [] | |
| async for admin in app.get_chat_members( | |
| message.chat.id, filter=enums.ChatMembersFilter.ADMINISTRATORS | |
| ): | |
| if admin.privileges.is_Dragmous == False: | |
| if admin.user.is_bot == True: | |
| pass | |
| elif admin.status == ChatMemberStatus.OWNER: | |
| ownerList.append(admin.user) | |
| else: | |
| adminList.append(admin.user) | |
| else: | |
| pass | |
| lenAdminList = len(ownerList) + len(adminList) | |
| text2 = f"**ɢʀᴏᴜᴘ sᴛᴀғғ - {message.chat.title}**\n\n" | |
| try: | |
| owner = ownerList[0] | |
| if owner.username == None: | |
| text2 += f"👑 ᴏᴡɴᴇʀ\n└ {owner.mention}\n\n👮🏻 ᴀᴅᴍɪɴs\n" | |
| else: | |
| text2 += f"👑 ᴏᴡɴᴇʀ\n└ @{owner.username}\n\n👮🏻 ᴀᴅᴍɪɴs\n" | |
| except: | |
| text2 += f"👑 ᴏᴡɴᴇʀ\n└ <i>Hidden</i>\n\n👮🏻 ᴀᴅᴍɪɴs\n" | |
| if len(adminList) == 0: | |
| text2 += "└ <i>ᴀᴅᴍɪɴs ᴀʀᴇ ʜɪᴅᴅᴇɴ</i>" | |
| await app.send_message(message.chat.id, text2) | |
| else: | |
| while len(adminList) > 1: | |
| admin = adminList.pop(0) | |
| if admin.username == None: | |
| text2 += f"├ {admin.mention}\n" | |
| else: | |
| text2 += f"├ @{admin.username}\n" | |
| else: | |
| admin = adminList.pop(0) | |
| if admin.username == None: | |
| text2 += f"└ {admin.mention}\n\n" | |
| else: | |
| text2 += f"└ @{admin.username}\n\n" | |
| text2 += f"✅ | ᴛᴏᴛᴀʟ ɴᴜᴍʙᴇʀ ᴏғ ᴀᴅᴍɪɴs: {lenAdminList}" | |
| await app.send_message(message.chat.id, text2) | |
| except FloodWait as e: | |
| await asyncio.sleep(e.value) | |
| # ------------------------------------------------------------------------------- # | |
| async def bots(client, message): | |
| try: | |
| botList = [] | |
| async for bot in app.get_chat_members( | |
| message.chat.id, filter=enums.ChatMembersFilter.BOTS | |
| ): | |
| botList.append(bot.user) | |
| lenBotList = len(botList) | |
| text3 = f"ʙᴏᴛ ʟɪsᴛ - {message.chat.title}\n\n🤖 ʙᴏᴛs\n" | |
| while len(botList) > 1: | |
| bot = botList.pop(0) | |
| text3 += f"├ @{bot.username}\n" | |
| else: | |
| bot = botList.pop(0) | |
| text3 += f" @{bot.username}\n\n" | |
| text3 += f"✅ | ᴛᴏᴛᴀʟ ɴᴜᴍʙᴇʀ ᴏғ ʙᴏᴛs: {lenBotList}" | |
| await app.send_message(message.chat.id, text3) | |
| except FloodWait as e: | |
| await asyncio.sleep(e.value) | |
| # ------------------------------------------------------------------------------- # | |