Is there a way to change avatar in telegram bot using python?
Question:
I was trying to find some documentation, but i`ve failed. I would be grateful if you send me doc or example how to do it.
Answers:
In order to change your profile photo you should use MTPROTOAPI. One of the good libraries written in Python is called telethon. You can check here on how to update profile information.
install telethon:
python3 -m pip install --upgrade telethon
update profile photo:
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')
))
For those who just want to change without programmatically:
- Send the command /setuserpic to the bot responsible for creating other @BotFather bots.
- Send an image to the dialog that will be set as the bot’s avatar.
I was trying to find some documentation, but i`ve failed. I would be grateful if you send me doc or example how to do it.
In order to change your profile photo you should use MTPROTOAPI. One of the good libraries written in Python is called telethon. You can check here on how to update profile information.
install telethon:
python3 -m pip install --upgrade telethon
update profile photo:
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')
))
For those who just want to change without programmatically:
- Send the command /setuserpic to the bot responsible for creating other @BotFather bots.
- Send an image to the dialog that will be set as the bot’s avatar.