| import os |
| from inspect import getfullargspec |
| from pyrogram.types import Message |
| from pyrogram import filters |
| from SONALI import app |
| from SONALI.misc import SUDOERS |
| from SONALI.utils.database import get_client |
|
|
| ASSISTANT_PREFIX = "." |
|
|
|
|
| @app.on_message(filters.command("setpfp", prefixes=ASSISTANT_PREFIX) & SUDOERS) |
| async def set_pfp(client, message): |
| from SONALI.core.userbot import assistants |
|
|
| if not message.reply_to_message or not message.reply_to_message.photo: |
| return await eor(message, text="Rᴇᴘʟʏ ᴛᴏ ᴀɴ ɪᴍᴀɢᴇ.") |
| for num in assistants: |
| client = await get_client(num) |
| photo = await message.reply_to_message.download() |
| try: |
| await client.set_profile_photo(photo=photo) |
| await eor(message, text="Sᴜᴄᴄᴇssғᴜʟʟʏ Cʜᴀɴɢᴇᴅ Pғᴘ.") |
| os.remove(photo) |
| except Exception as e: |
| await eor(message, text=e) |
|
|
|
|
| @app.on_message(filters.command("setbio", prefixes=ASSISTANT_PREFIX) & SUDOERS) |
| async def set_bio(client, message): |
| from SONALI.core.userbot import assistants |
|
|
| if len(message.command) == 1: |
| return await eor(message, text="Gɪᴠᴇ sᴏᴍᴇ ᴛᴇxᴛ!") |
| elif len(message.command) > 1: |
| for num in assistants: |
| client = await get_client(num) |
| bio = message.text.split(None, 1)[1] |
| try: |
| await client.update_profile(bio=bio) |
| await eor(message, text="Bɪᴏ Cʜᴀɴɢᴇᴅ.") |
| except Exception as e: |
| await eor(message, text=e) |
| else: |
| return await eor(message, text="Gɪᴠᴇ sᴏᴍᴇ ᴛᴇsᴛ ᴛᴏ sᴇᴛ ᴀs ʙɪᴏ.") |
|
|
|
|
| @app.on_message(filters.command("setname", prefixes=ASSISTANT_PREFIX) & SUDOERS) |
| async def set_name(client, message): |
| from SONALI.core.userbot import assistants |
|
|
| if len(message.command) == 1: |
| return await eor(message, text="Tᴇxᴛ Tᴏʜ Dᴏ") |
| elif len(message.command) > 1: |
| for num in assistants: |
| client = await get_client(num) |
| name = message.text.split(None, 1)[1] |
| try: |
| await client.update_profile(first_name=name) |
| await eor(message, text=f"Nᴀᴍᴇ Cʜᴀɴɢᴇᴅ Tᴏ {name} .") |
| except Exception as e: |
| await eor(message, text=e) |
| else: |
| return await eor(message, text="Nᴀᴀᴍ ᴛᴏʜ ʙᴛᴀᴏ.") |
|
|
|
|
| @app.on_message(filters.command("delpfp", prefixes=ASSISTANT_PREFIX) & SUDOERS) |
| async def del_pfp(client, message): |
| from SONALI.core.userbot import assistants |
|
|
| for num in assistants: |
| client = await get_client(num) |
| photos = [p async for p in client.get_chat_photos("me")] |
| try: |
| if photos: |
| await client.delete_profile_photos(photos[0].file_id) |
| await eor(message, text="SᴜᴄᴄᴇssFᴜʟʟʏ Dᴇʟᴇᴛᴇᴅ.") |
| else: |
| await eor(message, text="Nᴏ Pғᴘ Fᴏᴜɴᴅ Fᴏʀ Dᴇʟᴇᴛᴇ.") |
| except Exception as e: |
| await eor(message, text=e) |
|
|
|
|
| @app.on_message(filters.command("delallpfp", prefixes=ASSISTANT_PREFIX) & SUDOERS) |
| async def delall_pfp(client, message): |
| from SONALI.core.userbot import assistants |
|
|
| for num in assistants: |
| client = await get_client(num) |
| photos = [p async for p in client.get_chat_photos("me")] |
| try: |
| if photos: |
| await client.delete_profile_photos([p.file_id for p in photos[1:]]) |
| await eor(message, text="SᴜᴄᴄᴇssFᴜʟʟʏ Dᴇʟᴇᴛᴇᴅ Pɪᴄs") |
| else: |
| await eor(message, text="Kᴜᴄʜ Mɪʟᴀ Hᴇᴇ Nᴀʜɪ Dᴇʟᴇᴛᴇ Kᴀʀɴᴇ ᴋ Lɪʏᴇ.") |
| except Exception as e: |
| await eor(message, text=e) |
|
|
|
|
| async def eor(msg: Message, **kwargs): |
| func = ( |
| (msg.edit_text if msg.from_user.is_self else msg.reply) |
| if msg.from_user |
| else msg.reply |
| ) |
| spec = getfullargspec(func.__wrapped__).args |
| return await func(**{k: v for k, v in kwargs.items() if k in spec}) |
|
|