azils3/bash
0
1# Ultroid - UserBot2# Copyright (C) 2021-2025 TeamUltroid3#4# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >5# PLease read the GNU Affero General Public License in6# <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.7"""8✘ Commands Available -9 10• `{i}setname <first name // last name>`11 Change your profile name.12 13• `{i}setbio <bio>`14 Change your profile bio.15 16• `{i}setpic <reply to pic>`17 Change your profile pic.18 19• `{i}delpfp <n>(optional)`20 Delete one profile pic, if no value given, else delete n number of pics.21 22• `{i}poto <username>/reply`23 `{i}poto <reply/upload-limit>/all`24 25 Ex: `{i}poto 10` - uploads starting 10 pfps of user.26 Upload the photo of Chat/User if Available.27"""28import os29 30from telethon.tl.functions.account import UpdateProfileRequest31from telethon.tl.functions.photos import DeletePhotosRequest, UploadProfilePhotoRequest32 33from . import eod, eor, get_string, mediainfo, ultroid_cmd34 35TMP_DOWNLOAD_DIRECTORY = "resources/downloads/"36 37# bio changer38 39 40@ultroid_cmd(pattern="setbio( (.*)|$)", fullsudo=True)41async def _(ult):42 ok = await ult.eor("...")43 set = ult.pattern_match.group(1).strip()44 try:45 await ult.client(UpdateProfileRequest(about=set))46 await eod(ok, f"Profile bio changed to\n`{set}`")47 except Exception as ex:48 await eod(ok, f"Error occured.\n`{str(ex)}`")49 50 51# name changer52 53 54@ultroid_cmd(pattern="setname ?((.|//)*)", fullsudo=True)55async def _(ult):56 ok = await ult.eor("...")57 names = first_name = ult.pattern_match.group(1).strip()58 last_name = ""59 if "//" in names:60 first_name, last_name = names.split("//", 1)61 try:62 await ult.client(63 UpdateProfileRequest(64 first_name=first_name,65 last_name=last_name,66 ),67 )68 await eod(ok, f"Name changed to `{names}`")69 except Exception as ex:70 await eod(ok, f"Error occured.\n`{str(ex)}`")71 72 73# profile pic74 75 76@ultroid_cmd(pattern="setpic$", fullsudo=True)77async def _(ult):78 if not ult.is_reply:79 return await ult.eor("`Reply to a Media..`", time=5)80 reply_message = await ult.get_reply_message()81 ok = await ult.eor(get_string("com_1"))82 replfile = await reply_message.download_media()83 file = await ult.client.upload_file(replfile)84 try:85 if "pic" in mediainfo(reply_message.media):86 await ult.client(UploadProfilePhotoRequest(file=file))87 else:88 await ult.client(UploadProfilePhotoRequest(video=file))89 await eod(ok, "`My Profile Photo has Successfully Changed !`")90 except Exception as ex:91 await eod(ok, f"Error occured.\n`{str(ex)}`")92 os.remove(replfile)93 94 95# delete profile pic(s)96 97 98@ultroid_cmd(pattern="delpfp( (.*)|$)", fullsudo=True)99async def remove_profilepic(delpfp):100 ok = await eor(delpfp, "`...`")101 group = delpfp.text[8:]102 if group == "all":103 lim = 0104 elif group.isdigit():105 lim = int(group)106 else:107 lim = 1108 pfplist = await delpfp.client.get_profile_photos("me", limit=lim)109 await delpfp.client(DeletePhotosRequest(pfplist))110 await eod(ok, f"`Successfully deleted {len(pfplist)} profile picture(s).`")111 112 113@ultroid_cmd(pattern="poto( (.*)|$)")114async def gpoto(e):115 ult = e.pattern_match.group(1).strip()116 117 if e.is_reply:118 gs = await e.get_reply_message()119 user_id = gs.sender_id120 elif ult:121 split = ult.split()122 user_id = split[0]123 if len(ult) > 1:124 ult = ult[-1]125 else:126 ult = None127 else:128 user_id = e.chat_id129 130 a = await e.eor(get_string("com_1"))131 limit = None132 133 just_dl = ult in ["-dl", "--dl"]134 if just_dl:135 ult = None136 137 if ult and ult != "all":138 try:139 limit = int(ult)140 except ValueError:141 pass142 143 if not limit or e.client._bot:144 okla = await e.client.download_profile_photo(user_id)145 else:146 okla = []147 if limit == "all":148 limit = None149 async for photo in e.client.iter_profile_photos(user_id, limit=limit):150 photo_path = await e.client.download_media(photo)151 if photo.video_sizes:152 await e.respond(file=photo_path)153 os.remove(photo_path)154 else:155 okla.append(photo_path)156 if not okla:157 return await eor(a, "`Pfp Not Found...`")158 if not just_dl:159 await a.delete()160 await e.reply(file=okla)161 if not isinstance(okla, list):162 okla = [okla]163 for file in okla:164 os.remove(file)165 return166 if isinstance(okla, list):167 okla = "\n".join(okla)168 await a.edit(f"Downloaded pfp to [ `{okla}` ].")169 