有没有办法使用 python 更改电报机器人中的头像?
Is there a way to change avatar in telegram bot using python?
我试图找到一些文档,但我失败了。如果您将文档或示例发送给我,我将不胜感激。
要更改个人资料照片,您应该使用 MTPROTOAPI。在 Python 中编写的一个很好的库称为 telethon. You can check here 关于如何更新配置文件信息。
安装电视节目:
python3 -m pip install --upgrade telethon
更新个人资料照片:
import asyncio
from telethon import TelegramClient
from telethon.tl.functions.photos import UploadProfilePhotoRequest
# Use your own values from my.telegram.org
api_id = 12345
api_hash = '0123456789abcdef0123456789abcdef'
client = await TelegramClient('anon', api_id, api_hash)
await client(UploadProfilePhotoRequest(
await client.upload_file('/path/to/some/file')
))
我试图找到一些文档,但我失败了。如果您将文档或示例发送给我,我将不胜感激。
要更改个人资料照片,您应该使用 MTPROTOAPI。在 Python 中编写的一个很好的库称为 telethon. You can check here 关于如何更新配置文件信息。
安装电视节目:
python3 -m pip install --upgrade telethon
更新个人资料照片:
import asyncio
from telethon import TelegramClient
from telethon.tl.functions.photos import UploadProfilePhotoRequest
# Use your own values from my.telegram.org
api_id = 12345
api_hash = '0123456789abcdef0123456789abcdef'
client = await TelegramClient('anon', api_id, api_hash)
await client(UploadProfilePhotoRequest(
await client.upload_file('/path/to/some/file')
))