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.`")
""" Сделано на основе поста https://habr.com/ru/post/457078/ (@mumtozvalijonov) с моими небольшими доработками """ from telethon import TelegramClient, sync from telethon.tl.functions.photos import UploadProfilePhotoRequest, DeletePhotosRequest from datetime import datetime import time from config import * from generate_time_images import * client = TelegramClient('my_session9911', api_id, api_hash) client.start() while True: change_img() client(DeletePhotosRequest(client.get_profile_photos('me'))) file = client.upload_file(f"time.png") client(UploadProfilePhotoRequest(file)) time.sleep(30) if __name__ == '__main__': pass
async def _(event): pic = await borg.get_profile_photos("me") await borg(DeletePhotosRequest(pic)) await event.edit("Done Ur All pic Had Deleted!!!")
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())
from telethon import TelegramClient, sync from config import * from telethon.tl.functions.photos import UploadProfilePhotoRequest, DeletePhotosRequest from telethon.tl.functions.account import UpdateProfileRequest from datetime import datetime from utils import * import time client = TelegramClient('TimeAvatar', api_id, api_hash) client.start() prev_update_time = "" while True: if time_has_changed(prev_update_time): if addTimeToName: client( UpdateProfileRequest( first_name=f"Eugene ({prev_update_time})")) prev_update_time = convert_time_to_string(datetime.now()) photos = client.get_profile_photos('me') file = client.upload_file( f"{images_dir}/{prev_update_time.replace(':', '-')}.jpg") client(UploadProfilePhotoRequest(file)) client(DeletePhotosRequest(photos)) time.sleep(10)
async def pfpdstartcmd(self, message): """Start PFPd Usage: .pfpdstart (sleep time in seconds) P.S. If you unloaded this module without stopping PFPd daemon, delete the daemon message to stop the PFPd.""" args = utils.get_args(message) if args: if self.running: await message.edit("PFPd is already running.") elif self.config: self.running = True self.error = False try: self.sleeptime = int(args[0]) except: self.running = False self.error = True self.sleeptime = 0 await message.edit( "[PFPd] Failed to convert sleep time to integer.") while self.running: await message.edit("[PFPd] Updating...") try: pfpsjson = urllib.request.urlopen(self.config).read() except: self.running = False self.error = True self.sleeptime = 0 await message.edit( "[PFPd] Invalid JSON config URL.\n(URL must contain https:// or http:// prefix)" ) break try: pfps = json.loads(pfpsjson) except: self.running = False self.error = True self.sleeptime = 0 await message.edit("[PFPd] Invalid JSON config file.") break try: photo = secrets.choice(pfps["pfps"]) except: self.running = False self.error = True self.sleeptime = 0 await message.edit( "[PFPd] Invalid JSON config file.\nMake sure \"pfps\" key is a list and it contains atleast one photo." ) break try: pfpfile = urllib.request.urlopen(photo) except: self.running = False self.error = True self.sleeptime = 0 await message.edit( "[PFPd] Invalid photo URL: {}\n(URL must contain https:// or http:// prefix)" .format(photo)) break try: await self.client( UploadProfilePhotoRequest( await self.client.upload_file(pfpfile))) await self.client( DeletePhotosRequest(await self.client.get_profile_photos( self.me.username, offset=1))) await message.edit("[PFPd] Updated successfully.") self.timer = self.sleeptime while self.timer: if self.running: await asyncio.sleep(1) self.timer -= 1 else: break except: await message.edit( "[PFPd] Flood timeout, waiting 200 seconds...") self.timer = 200 while self.timer: if self.running: await asyncio.sleep(1) self.timer -= 1 else: break if not self.error: await message.edit("Stopped.") else: await message.edit("No JSON config URL is set.") else: await message.edit("No sleep time supplied.")
async def main(): client = TelegramClient(None, api_id, api_hash) await client.connect() if not await client.is_user_authorized(): try: phone_number = input("Phone number: {}".format(" " * 7)) try: await client.send_code_request(phone=phone_number) except PhoneNumberInvalidError: print("-3, Phone number invalid") sleep(5) exit("-3") try: await client.sign_in(phone=phone_number, code=input('Enter telegram code: ')) except PhoneCodeInvalidError: print("-2, Code invalid") sleep(5) exit("-2") except SessionPasswordNeededError: try: await client.sign_in( password=getpass("2FA password: {}".format(" " * 7))) except (PasswordHashInvalidError, PasswordEmptyError): print("-1, Password invalid") sleep(5) exit("-1") except FloodWaitError: print( "Account login limited for 24 hours due login attempts flood.\nExiting..." ) sleep(5) exit("-5") cls() self_user = await client.get_me() print(""" first_name= [{0}] last_name= [{1}] username= [{2}] id= [{3}] phone= [{4}] """.format(self_user.first_name, self_user.last_name, self_user.username, self_user.id, self_user.phone)) answer = input("Leave channels?\n(Y)es | (n)o\n") if match(r'(y|yes)', answer, flags=IGNORECASE): leavechat = True else: leavechat = False answer = input("Clear account? \n(Y)es | (n)o\n") cls() if match(r'(y|yes)', answer, flags=IGNORECASE): dialogs = await client.get_dialogs() contacts_list = await client(GetContactsRequest(0)) animation = Animate(dialogs, "1 of 3 - chats wiping: ") for _ in dialogs: animation.callback() try: sleep(0.5) try: await client(DeleteHistoryRequest(_, 0)) except PeerIdInvalidError: if leavechat: await client(LeaveChannelRequest(_)) except FloodWaitError as e: print( "Telegram limits number of requests, please wait for {} seconds" .format(e.seconds)) print( "When the limit passes, we will do everything ourselves\n") flood_waiter(e.seconds) try: await client(DeleteHistoryRequest(_, 0)) except PeerIdInvalidError: await client(LeaveChannelRequest(_)) del animation cls() animation = Animate( range(2), "1 of 3 - chats wiping: Done!\n2 of 3 - contacts wiping: ") for _ in range(2): animation.callback() try: sleep(0.5) await client(DeleteContactsRequest(contacts_list.users)) except FloodWaitError as e: print( "Telegram limits number of requests, please wait for {} seconds" .format(e.seconds)) print( "When the limit passes, we will do everything ourselves\n") flood_waiter(e.seconds) await client(DeleteContactsRequest(contacts_list.users)) del animation cls() print( """1 of 3 - chats wiping: Done!\n2 of 3 - contacts wiping: Done!\nName set to default\n\ Username cleared\nBio cleared\nProfile pics: Done!\n""") await client( UpdateProfileRequest(about="", first_name="default", last_name="")) try: await client(UpdateUsernameRequest("")) except UsernameNotModifiedError: pass me = await client.get_me() photos_list = await client(GetUserPhotosRequest(me, 0, 0, 0)) await client(DeletePhotosRequest(photos_list.photos)) input("Enjoy your brand-new account! (Press enter)") await client.log_out() exit("1") else: await client.log_out() exit("0")