from telethon.tl.functions.photos import DeletePhotosRequest, GetUserPhotosRequest
from telethon.tl.types import InputPhoto

from userbot.cmdhelp import CmdHelp
from userbot.utils import admin_cmd, edit_or_reply, sudo_cmd

CmdHelp("delfp").add_command("delpfp", None, "delete ur currnt profile picture").add()


@borg.on(admin_cmd(pattern="delpfp ?(.*)"))
@borg.on(sudo_cmd(pattern="delpfp ?(.*)", allow_sudo=True))
async def remove_profilepic(delpfp):
    """For .delpfp command, delete your current profile picture in Telegram."""
    group = delpfp.text[8:]
    if group == "all":
        lim = 0
    elif group.isdigit():
        lim = int(group)
    else:
        lim = 1

    pfplist = await delpfp.client(
        GetUserPhotosRequest(user_id=delpfp.from_id, offset=0, max_id=0, limit=lim)
    )
    input_photos = [InputPhoto(
                id=sep.id,
                access_hash=sep.access_hash,
                file_reference=sep.file_reference,
            ) for sep in pfplist.photos]
    await delpfp.client(DeletePhotosRequest(id=input_photos))
    await edit_or_reply(
        delpfp, f"`Successfully deleted {len(input_photos)} profile picture(s).`"
    )

[((321, 354), 'userbot.utils.admin_cmd', 'admin_cmd', ([], {'pattern': '"""delpfp ?(.*)"""'}), "(pattern='delpfp ?(.*)')\n", (330, 354), False, 'from userbot.utils import admin_cmd, edit_or_reply, sudo_cmd\n'), ((365, 414), 'userbot.utils.sudo_cmd', 'sudo_cmd', ([], {'pattern': '"""delpfp ?(.*)"""', 'allow_sudo': '(True)'}), "(pattern='delpfp ?(.*)', allow_sudo=True)\n", (373, 414), False, 'from userbot.utils import admin_cmd, edit_or_reply, sudo_cmd\n'), ((823, 913), 'telethon.tl.types.InputPhoto', 'InputPhoto', ([], {'id': 'sep.id', 'access_hash': 'sep.access_hash', 'file_reference': 'sep.file_reference'}), '(id=sep.id, access_hash=sep.access_hash, file_reference=sep.\n    file_reference)\n', (833, 913), False, 'from telethon.tl.types import InputPhoto\n'), ((721, 796), 'telethon.tl.functions.photos.GetUserPhotosRequest', 'GetUserPhotosRequest', ([], {'user_id': 'delpfp.from_id', 'offset': '(0)', 'max_id': '(0)', 'limit': 'lim'}), '(user_id=delpfp.from_id, offset=0, max_id=0, limit=lim)\n', (741, 796), False, 'from telethon.tl.functions.photos import DeletePhotosRequest, GetUserPhotosRequest\n'), ((1023, 1059), 'telethon.tl.functions.photos.DeletePhotosRequest', 'DeletePhotosRequest', ([], {'id': 'input_photos'}), '(id=input_photos)\n', (1042, 1059), False, 'from telethon.tl.functions.photos import DeletePhotosRequest, GetUserPhotosRequest\n'), ((223, 239), 'userbot.cmdhelp.CmdHelp', 'CmdHelp', (['"""delfp"""'], {}), "('delfp')\n", (230, 239), False, 'from userbot.cmdhelp import CmdHelp\n')]