Answer the question
In order to leave comments, you need to log in
How to use InputPhoto in telethone?
I have a photo id and I need to pull it out of telegram. I use telethon, but its documentation is hell. I really tried to understand, but without examples it is very difficult. Please help with an example (or at least advice where to look for it). I made this myself
def get_data(user):
with TelegramClient('anon', api_id, api_hash) as client:
result = client(functions.photos.GetUserPhotosRequest(
user_id=user,
offset=0,
max_id=0,
limit=0
))
client.flood_sleep_threshold = 24 * 60 * 60
array_of_photos = result.photos
for photo in array_of_photos:
file_reference = photo.file_reference
file_id = photo.id
access_hash = photo.access_hash
return file_reference, file_id, access_hash
file_reference, file_id, access_hash = get_data('user')
with TelegramClient(name, api_id, api_hash) as client:
result = client(functions.upload.GetFileRequest(
location=types.InputFileLocation(
volume_id=-12398745604826,
local_id=42,
secret=-12398745604826,
file_reference=b'arbitrary\x7f data \xfa here'
),
offset=42,
limit=100,
precise=True,
cdn_supported=True
))
print(result.stringify())
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question