from pyrogram import filters,Client from pyrogram.types import Message,InlineKeyboardMarkup, InlineKeyboardButton from unidecode import unidecode from DragMusic import app from DragMusic.misc import SUDOERS from DragMusic.utils.database import ( get_active_chats, get_active_video_chats, remove_active_chat, remove_active_video_chat, ) @app.on_message(filters.command(["activevc", "activevoice"]) & SUDOERS) async def activevc(_, message: Message): mystic = await message.reply_text("» ɢᴇᴛᴛɪɴɢ ᴀᴄᴛɪᴠᴇ ᴠᴏɪᴄᴇ ᴄʜᴀᴛs ʟɪsᴛ...") served_chats = await get_active_chats() text = "" j = 0 for x in served_chats: try: title = (await app.get_chat(x)).title except: await remove_active_chat(x) continue try: if (await app.get_chat(x)).username: user = (await app.get_chat(x)).username text += f"{j + 1}. {unidecode(title).upper()} [{x}]\n" else: text += ( f"{j + 1}. {unidecode(title).upper()} [{x}]\n" ) j += 1 except: continue if not text: await mystic.edit_text(f"» ɴᴏ ᴀᴄᴛɪᴠᴇ ᴠᴏɪᴄᴇ ᴄʜᴀᴛs ᴏɴ {app.mention}.") else: await mystic.edit_text( f"» ʟɪsᴛ ᴏғ ᴄᴜʀʀᴇɴᴛʟʏ ᴀᴄᴛɪᴠᴇ ᴠᴏɪᴄᴇ ᴄʜᴀᴛs :\n\n{text}", disable_web_page_preview=True, ) @app.on_message(filters.command(["activev", "activevideo"]) & SUDOERS) async def activevi_(_, message: Message): mystic = await message.reply_text("» ɢᴇᴛᴛɪɴɢ ᴀᴄᴛɪᴠᴇ ᴠɪᴅᴇᴏ ᴄʜᴀᴛs ʟɪsᴛ...") served_chats = await get_active_video_chats() text = "" j = 0 for x in served_chats: try: title = (await app.get_chat(x)).title except: await remove_active_video_chat(x) continue try: if (await app.get_chat(x)).username: user = (await app.get_chat(x)).username text += f"{j + 1}. {unidecode(title).upper()} [{x}]\n" else: text += ( f"{j + 1}. {unidecode(title).upper()} [{x}]\n" ) j += 1 except: continue if not text: await mystic.edit_text(f"» ɴᴏ ᴀᴄᴛɪᴠᴇ ᴠɪᴅᴇᴏ ᴄʜᴀᴛs ᴏɴ {app.mention}.") else: await mystic.edit_text( f"» ʟɪsᴛ ᴏғ ᴄᴜʀʀᴇɴᴛʟʏ ᴀᴄᴛɪᴠᴇ ᴠɪᴅᴇᴏ ᴄʜᴀᴛs :\n\n{text}", disable_web_page_preview=True, ) @app.on_message(filters.command(["ac","av"]) & SUDOERS) async def start(client: Client, message: Message): ac_audio = str(len(await get_active_chats())) ac_video = str(len(await get_active_video_chats())) await message.reply_text(f"✫ ᴀᴄᴛɪᴠᴇ ᴄʜᴀᴛs ɪɴғᴏ :\n\nᴠᴏɪᴄᴇ : {ac_audio}\nᴠɪᴅᴇᴏ : {ac_video}", reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton('✯ ᴄʟᴏsᴇ ✯', callback_data=f"close")]]))