[英]How to use InputPhoto in Telethon?
I want to take nicknames and photos of all chat participants in telegram.我想在电报中拍摄所有聊天参与者的昵称和照片。 For this I have code like this:
为此,我有这样的代码:
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.问题是照片是 Telethon 对象。 I can't get the photo out of it and I don't know how to do it
我无法从中取出照片,我不知道该怎么做
output photo: 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)
输出照片:
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 documentation documentation InputPhoto and I hope it helps me, but the documentation does not contain examples of use and I cannot figure out how to implement it.我在文档文档 InputPhoto 中找到了InputPhoto ,我希望它对我有帮助,但文档不包含使用示例,我无法弄清楚如何实现它。 Can someone help with a hint or an example of how to get a photo out of there?
有人可以提供提示或如何从那里获取照片的示例吗?
There is method for this in telethon : download_profile_photo在 Telethon 中有一个方法: download_profile_photo
you can store the photo either downloading or storing it in memory for using it after.您可以将照片存储在下载或存储在内存中以供以后使用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.