Answer the question
In order to leave comments, you need to log in
How to get photo from UserProfilePhoto?
I want to take photos and nicknames of all chat participants in Telegram. For this I have this code:
client = TelegramClient(username, api_id, api_hash)
async def dump_all_participants(channel) -> list:
offset_user = 0
limit_user = 100
all_participants = []
filter_user = ChannelParticipantsSearch('')
while True:
participants = await client(GetParticipantsRequest(channel,
filter_user, offset_user, limit_user, hash=0))
if not participants.users:
break
all_participants.extend(participants.users)
offset_user += len(participants.users)
all_users_details = []
for participant in all_participants:
if participant.photo is None:
photo = UNKNOWN.STRING
else:
photo = participant.photo
all_users_details.append({participant.id: [participant.username, photo]})
return all_users_details
UserProfilePhoto(photo_id=208135253786732667, photo_small=FileLocationToBeDeprecated(volume_id=257125342, local_id=230348), photo_big=FileLocationToBeDeprecated(volume_id=257125342, local_id=230350), dc_id=2, has_video=False)
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