D
D
Dmitry Prilepsky2020-08-28 09:28:24
Python
Dmitry Prilepsky, 2020-08-28 09:28:24

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

the problem is that the photo is a Telethon object. I can't get the link out of it, or I just don't know how to

output the photo variable:
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)

I found InputPhoto in the teletone documentation and hope it helps me, but the documentation doesn't include usage examples and I can't figure out how to implement it. Can anyone help with a hint or an example of how to get the photo itself out of there?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2020-08-28
@SoreMix

https://docs.telethon.dev/en/latest/quick-reference...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question