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.sender_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 delpfp.edit(f"`Successfully deleted {len(input_photos)} profile picture(s).`")
async def remove_profilepic(delpfp): """ امر حذف الصور - لحذ صوره واحد من حسابك او جميعها """ group = delpfp.text[8:] if group == "الصور": lim = 0 elif group.isdigit(): lim = int(group) else: lim = 1 pfplist = await delpfp.client( GetUserPhotosRequest(user_id=delpfp.sender_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 delpfp.edit(f"**⪼ تم حذف ↩︎** {len(input_photos)} **من صور حسابك ༗.**")
async def _(event): if event.fwd_from: return name = f"{DEFAULTUSER}" bio = f"{DEFAULTUSERBIO}" n = 1 await event.edit("`Processing...`") pfplist = await event.client( GetUserPhotosRequest(user_id=event.from_id, offset=0, max_id=0, limit=n)) input_photos = [] for sep in pfplist.photos: input_photos.append( InputPhoto(id=sep.id, access_hash=sep.access_hash, file_reference=sep.file_reference)) await event.client(DeletePhotosRequest(id=input_photos)) await event.client(UpdateProfileRequest(first_name=name, last_name="")) await event.client(UpdateProfileRequest(about=bio)) await event.edit("`succesfully reverted my account back`")
async def rmpfp(context): """ Removes your profile picture. """ group = context.text[8:] if group == 'all': limit = 0 elif group.isdigit(): limit = int(group) else: limit = 1 pfp_list = await bot( GetUserPhotosRequest(user_id=context.from_id, offset=0, max_id=0, limit=limit)) input_photos = [] for sep in pfp_list.photos: input_photos.append( InputPhoto(id=sep.id, access_hash=sep.access_hash, file_reference=sep.file_reference)) await bot(DeletePhotosRequest(id=input_photos)) await context.edit(f"`Removed {len(input_photos)} profile picture(s).`")
async def remove_profilepic(delpfp): """ .delpfp komutu için Telegram'daki mevcut profil resminizi silin. """ 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 = [] for sep in pfplist.photos: input_photos.append( InputPhoto(id=sep.id, access_hash=sep.access_hash, file_reference=sep.file_reference)) await delpfp.client(DeletePhotosRequest(id=input_photos)) await delpfp.edit(f"`{Len (input_photos)} profil resmi başarıyla silindi.`" )
async def remove_profilepic(delpfp): """ .delpfp komutu Telegram'daki şu anki profil resminizi kaldırır. """ 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 = [] for sep in pfplist.photos: input_photos.append( InputPhoto(id=sep.id, access_hash=sep.access_hash, file_reference=sep.file_reference)) await delpfp.client(DeletePhotosRequest(id=input_photos)) await delpfp.edit(LANG['DELPFP'] % len(input_photos))
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 = [] for sep in pfplist.photos: input_photos.append( InputPhoto(id=sep.id, access_hash=sep.access_hash, file_reference=sep.file_reference)) await delpfp.client(DeletePhotosRequest(id=input_photos)) await delpfp.edit(f"`Berhasil Menghapus {len(input_photos)} Foto Profil.`")
async def remove_profilepic(delpfp): 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 = [] for sep in pfplist.photos: input_photos.append( InputPhoto(id=sep.id, access_hash=sep.access_hash, file_reference=sep.file_reference)) await delpfp.client(DeletePhotosRequest(id=input_photos)) await delpfp.edit( f"`Successfully deleted {len(input_photos)} profile picture(s).`")
async def remove_profilepic(delpfp): 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.sender_id, offset=0, max_id=0, limit=lim) ) input_photos = [] for sep in pfplist.photos: input_photos.append( InputPhoto( id=sep.id, access_hash=sep.access_hash, file_reference=sep.file_reference, ) ) await delpfp.client(DeletePhotosRequest(id=input_photos)) await eod(delpfp, f"🗑️ **Successfully deleted** `{len(input_photos)}` **profile picture(s).**")
async def updateProfile(userObj, reset=False): firstName = "Deleted Account" if userObj.user.first_name is None else userObj.user.first_name lastName = "" if userObj.user.last_name is None else userObj.user.last_name userAbout = userObj.about if userObj.about is not None else "" userAbout = "" if len(userAbout) > 70 else userAbout if reset: userPfps = await bot.get_profile_photos('me') userPfp = userPfps[0] await bot(DeletePhotosRequest( id=[InputPhoto( id=userPfp.id, access_hash=userPfp.access_hash, file_reference=userPfp.file_reference )])) else: try: userPfp = userObj.profile_photo pfpImage = await bot.download_media(userPfp) await bot(UploadProfilePhotoRequest(await bot.upload_file(pfpImage))) except BaseException: pass await bot(UpdateProfileRequest( about=userAbout, first_name=firstName, last_name=lastName ))
async def top_images(event: telethon.events.NewMessage.Event): match = event.pattern_match logger.info("New query: " + match.group(0)) await event.client( SetTypingRequest(event.input_chat, SendMessageUploadPhotoAction(0))) results = ( pixiv.get_pixiv_results( int(match.group(2) or 0) * MAX_GROUPED_MEDIA, # user gives page num nsfw=bool(match.group(1))))[:MAX_GROUPED_MEDIA] try: images = await event.client([ UploadMediaRequest(event.input_chat, InputMediaPhotoExternal(result['url'], 86000)) for result in results ]) except telethon.errors.MultiError as e: logger.warning("UploadMedia returned one or more errors") logging.debug('error: %s', e, exc_info=True) images = filter(None, e.results) if not images: logger.exception("All UploadMedia requests failed") return images = [ InputSingleMedia( InputMediaPhoto( InputPhoto(img.photo.id, img.photo.access_hash, b'')), '') for img in images ] try: await event.client(SendMultiMediaRequest(event.input_chat, images)) except (telethon.errors.UserIsBlockedError, telethon.errors.RPCError): # TODO: add other relevant errors logger.exception("Failed to send multimedia")
client.start() prevNum = 0 while True: # clear current photo pics = client.get_profile_photos('me') if len(pics) != 0: pic = pics[0] client( DeletePhotosRequest(id=[ InputPhoto(id=pic.id, access_hash=pic.access_hash, file_reference=pic.file_reference) ])) # get new random number newNum = random.randrange(1, 33) # prevent repetetive pics if newNum == prevNum: continue client( UploadProfilePhotoRequest(client.upload_file(f'./pics/{newNum}.jpg'))) prevNum = newNum time.sleep(sleep_time + random.random())
def to_input_photo(self) -> InputPhoto: return InputPhoto(self.file_id, self.access_hash, self.file_reference)