我想拍下所有聊天参与者的昵称和照片。为此,我有如下代码:
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)
我在文档documentation InputPhoto中找到了InputPhoto,我希望它对我有所帮助,但文档中没有使用示例,我无法理解如何实现它。有没有人能给你一个提示或一个例子,告诉你如何从那里得到一张照片
telethon中有一种方法:download_profile_photo
您可以下载照片或将其存储在内存中,以便在下载后使用
相关问题 更多 >
编程相关推荐