本文介绍了通过Telethon库或任何API删除电报资料照片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我无法通过telethon库或任何其他API删除个人资料照片
I can't delete profile photo by telethon library or any else API
我在下面已经做过(使用Telethon),但是没有用
What I already did below (using telethon) but it doesn't work
from telethon import TelegramClient, sync
from telethon.tl.functions.photos import DeletePhotosRequest
api_id = "id"
api_hash = "hash"
client = TelegramClient("bot_5", api_id, api_hash)
client.start()
client(DeletePhotosRequest(client.get_profile_photos('me')))
我希望这段代码能删除我的个人资料照片
I expected what this code would delete my profile photo
如何使用API删除它?
How can I delete it with API?
推荐答案
这将为您服务
from telethon.sync import TelegramClient
from telethon.tl.functions.photos import DeletePhotosRequest
from telethon.tl.types import InputPhoto
with TelegramClient('your session', api_id, api_hash) as client:
p = client.get_profile_photos('me')[0]
client(DeletePhotosRequest(
id=[InputPhoto(
id=p.id,
access_hash=p.access_hash,
file_reference=p.file_reference
)]
))
- get_profile_photos将返回一个列表
这篇关于通过Telethon库或任何API删除电报资料照片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!