Skip to content

Instantly share code, notes, and snippets.

@JosXa
Created June 8, 2017 18:33
Show Gist options
  • Select an option

  • Save JosXa/7defefb6b64a09fca7b16c557019ffbc to your computer and use it in GitHub Desktop.

Select an option

Save JosXa/7defefb6b64a09fca7b16c557019ffbc to your computer and use it in GitHub Desktop.
#!/usr/bin/python3
import time
import random
from telethon import InteractiveTelegramClient
from telethon.tl.functions.photos import UploadProfilePhotoRequest
import os
client = InteractiveTelegramClient(
'test1',
'+400000000000',
api_id=34057,
api_hash='blabla'
)
photo_folder = 'blabla'
while True:
photos = os.listdir(photo_folder)
for photo in photos:
input_file = client.upload_file(photo_folder + photo)
result = client.invoke(UploadProfilePhotoRequest(input_file))
print('Profile picture changed to {}.'.format(photo))
time.sleep(45)
@Lonami
Copy link

Lonami commented Oct 8, 2017

You have to call UpdateProfilePhotoRequest after you've uploaded the input file as a photo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment