Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<p align="center">A simple, but extensible Python implementation for the <a href="https://core.telegram.org/bots/api">Telegram Bot API</a>.</p>
<p align="center">Both synchronous and asynchronous.</p>

## <p align="center">Supported Bot API version: <a href="https://core.telegram.org/bots/api#august-15-2025"><img src="https://img.shields.io/badge/Bot%20API-9.2-blue?logo=telegram" alt="Supported Bot API version"></a>
## <p align="center">Supported Bot API version: <a href="https://core.telegram.org/bots/api#february-9-2026"><img src="https://img.shields.io/badge/Bot%20API-9.4-blue?logo=telegram" alt="Supported Bot API version"></a>

<h2><a href='https://pytba.readthedocs.io/en/latest/index.html'>Official documentation</a></h2>
<h2><a href='https://pytba.readthedocs.io/ru/latest/index.html'>Official ru documentation</a></h2>
Expand Down
54 changes: 51 additions & 3 deletions telebot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1512,6 +1512,29 @@ def get_user_profile_photos(self, user_id: int, offset: Optional[int]=None,
apihelper.get_user_profile_photos(self.token, user_id, offset=offset, limit=limit)
)

def get_user_profile_audios(self, user_id: int, offset: Optional[int]=None,
limit: Optional[int]=None) -> types.UserProfileAudios:
"""
Use this method to get a list of profile audios for a user. Returns a :class:`telebot.types.UserProfileAudios` object.

Telegram documentation: https://core.telegram.org/bots/api#getuserprofileaudios

:param user_id: Unique identifier of the target user
:type user_id: :obj:`int`

:param offset: Sequential number of the first audio to be returned. By default, all audios are returned.
:type offset: :obj:`int`

:param limit: Limits the number of audios to be retrieved. Values between 1-100 are accepted. Defaults to 100.
:type limit: :obj:`int`

:return: If the request is successful, a UserProfileAudios object is returned.
:rtype: :class:`telebot.types.UserProfileAudios`
"""
return types.UserProfileAudios.de_json(
apihelper.get_user_profile_audios(self.token, user_id, offset=offset, limit=limit)
)

def set_user_emoji_status(self, user_id: int, emoji_status_custom_emoji_id: Optional[str]=None, emoji_status_expiration_date: Optional[int]=None) -> bool:
"""
Changes the emoji status for a given user that previously allowed the bot to manage their emoji status via the Mini App method requestEmojiStatusAccess. Returns True on success.
Expand Down Expand Up @@ -5048,6 +5071,31 @@ def get_my_short_description(self, language_code: Optional[str]=None):
return types.BotShortDescription.de_json(
apihelper.get_my_short_description(self.token, language_code=language_code))

def set_my_profile_photo(self, photo: types.InputProfilePhoto) -> bool:
"""
Use this method to change the profile photo of the bot. Returns True on success.

Telegram documentation: https://core.telegram.org/bots/api#setmyprofilephoto

:param photo: The new profile photo to set
:type photo: :class:`telebot.types.InputProfilePhoto`

:return: True on success.
:rtype: :obj:`bool`
"""
return apihelper.set_my_profile_photo(self.token, photo)

def remove_my_profile_photo(self) -> bool:
"""
Use this method to remove the profile photo of the bot. Requires no parameters. Returns True on success.

Telegram documentation: https://core.telegram.org/bots/api#removemyprofilephoto

:return: True on success.
:rtype: :obj:`bool`
"""
return apihelper.remove_my_profile_photo(self.token)


def set_chat_menu_button(self, chat_id: Union[int, str]=None, menu_button: types.MenuButton=None) -> bool:
"""
Expand Down Expand Up @@ -7758,7 +7806,7 @@ def delete_sticker_from_set(self, sticker: str) -> bool:

:param sticker: File identifier of the sticker
:return: On success, True is returned.
:rtype: :obj:`bool`
:rtype: :obj:`bool`
"""
return apihelper.delete_sticker_from_set(self.token, sticker)

Expand All @@ -7767,8 +7815,8 @@ def create_forum_topic(self,
chat_id: int, name: str, icon_color: Optional[int]=None,
icon_custom_emoji_id: Optional[str]=None) -> types.ForumTopic:
"""
Use this method to create a topic in a forum supergroup chat. The bot must be an administrator
in the chat for this to work and must have the can_manage_topics administrator rights.
Use this method to create a topic in a forum supergroup chat or a private chat with a user. In the case of a supergroup chat the bot
must be an administrator in the chat for this to work and must have the can_manage_topics administrator right.
Returns information about the created topic as a ForumTopic object.

Telegram documentation: https://core.telegram.org/bots/api#createforumtopic
Expand Down
21 changes: 21 additions & 0 deletions telebot/apihelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,16 @@ def get_user_profile_photos(token, user_id, offset=None, limit=None):
return _make_request(token, method_url, params=payload)


def get_user_profile_audios(token, user_id, offset=None, limit=None):
method_url = r'getUserProfileAudios'
payload = {'user_id': user_id}
if offset:
payload['offset'] = offset
if limit:
payload['limit'] = limit
return _make_request(token, method_url, params=payload)


def set_user_emoji_status(token, user_id, emoji_status_custom_emoji_id=None, emoji_status_expiration_date=None):
method_url = r'setUserEmojiStatus'
payload = {'user_id': user_id}
Expand Down Expand Up @@ -1526,6 +1536,17 @@ def get_my_name(token, language_code=None):
payload['language_code'] = language_code
return _make_request(token, method_url, params=payload)

def set_my_profile_photo(token, photo):
method_url = r'setMyProfilePhoto'
payload = {}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

    photo_json, files = photo.convert_input_profile_photo()
    payload['photo'] = photo_json

photo_json, files = photo.convert_input_profile_photo()
payload['photo'] = photo_json
return _make_request(token, method_url, params=payload, files=files, method='post')

def delete_my_profile_photo(token):
method_url = r'deleteMyProfilePhoto'
return _make_request(token, method_url, method='post')

def set_chat_menu_button(token, chat_id=None, menu_button=None):
method_url = r'setChatMenuButton'
payload = {}
Expand Down
49 changes: 47 additions & 2 deletions telebot/async_telebot.py
Original file line number Diff line number Diff line change
Expand Up @@ -2989,6 +2989,26 @@ async def get_user_profile_photos(self, user_id: int, offset: Optional[int]=None
result = await asyncio_helper.get_user_profile_photos(self.token, user_id, offset, limit)
return types.UserProfilePhotos.de_json(result)

async def get_user_profile_audios(self, user_id: int, offset: Optional[int]=None, limit: Optional[int]=None) -> types.UserProfileAudios:
"""
Use this method to get a list of profile audios for a user. Returns a UserProfileAudios object.

Telegram documentation: https://core.telegram.org/bots/api#getuserprofileaudios

:param user_id: Unique identifier of the target user
:type user_id: :obj:`int`

:param offset: Sequential number of the first audio to be returned. By default, all audios are returned.
:type offset: :obj:`int`

:param limit: Limits the number of audios to be retrieved. Values between 1-100 are accepted. Defaults to 100.
:type limit: :obj:`int`

:return: If successful, returns a UserProfileAudios object.
:rtype: :class:`telebot.types.UserProfileAudios`
"""
return types.UserProfileAudios.de_json(await asyncio_helper.get_user_profile_audios(self.token, user_id, offset=offset, limit=limit))

async def set_user_emoji_status(self, user_id: int, emoji_status_custom_emoji_id: Optional[str]=None, emoji_status_expiration_date: Optional[int]=None) -> bool:
"""
Use this method to change the emoji status for a given user that previously allowed the bot to manage their emoji status via the Mini App method requestEmojiStatusAccess.
Expand Down Expand Up @@ -6533,6 +6553,31 @@ async def get_my_name(self, language_code: Optional[str]=None):
result = await asyncio_helper.get_my_name(self.token, language_code)
return types.BotName.de_json(result)

async def set_my_profile_photo(self, photo: types.InputProfilePhoto) -> bool:
"""
Use this method to change the profile photo of the bot. Returns True on success.

Telegram documentation: https://core.telegram.org/bots/api#setmyprofilephoto

:param photo: InputProfilePhoto: The new profile photo to set
:type photo: :class:`telebot.types.InputProfilePhoto`

:return: True on success.
:rtype: :obj:`bool`
"""
return await asyncio_helper.set_my_profile_photo(self.token, photo)

async def remove_my_profile_photo(self) -> bool:
"""
Use this method to remove the profile photo of the bot. Requires no parameters. Returns True on success.

Telegram documentation: https://core.telegram.org/bots/api#removemyprofilephoto

:return: True on success.
:rtype: :obj:`bool`
"""
return await asyncio_helper.remove_my_profile_photo(self.token)

async def set_chat_menu_button(self, chat_id: Union[int, str]=None,
menu_button: types.MenuButton=None) -> bool:
"""
Expand Down Expand Up @@ -9193,8 +9238,8 @@ async def create_forum_topic(self,
chat_id: int, name: str, icon_color: Optional[int]=None,
icon_custom_emoji_id: Optional[str]=None) -> types.ForumTopic:
"""
Use this method to create a topic in a forum supergroup chat. The bot must be an administrator
in the chat for this to work and must have the can_manage_topics administrator rights.
Use this method to create a topic in a forum supergroup chat or a private chat with a user. In the case of a supergroup chat the bot
must be an administrator in the chat for this to work and must have the can_manage_topics administrator right.
Returns information about the created topic as a ForumTopic object.

Telegram documentation: https://core.telegram.org/bots/api#createforumtopic
Expand Down
22 changes: 22 additions & 0 deletions telebot/asyncio_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,16 @@ async def get_user_profile_photos(token, user_id, offset=None, limit=None):
return await _process_request(token, method_url, params=payload)


async def get_user_profile_audios(token, user_id, offset=None, limit=None):
method_url = r'getUserProfileAudios'
payload = {'user_id': user_id}
if offset:
payload['offset'] = offset
if limit:
payload['limit'] = limit
return await _process_request(token, method_url, params=payload)


async def set_user_emoji_status(token, user_id, emoji_status_custom_emoji_id=None, emoji_status_expiration_date=None):
method_url = r'setUserEmojiStatus'
payload = {'user_id': user_id}
Expand Down Expand Up @@ -1517,6 +1527,18 @@ async def get_my_name(token, language_code=None):
payload['language_code'] = language_code
return await _process_request(token, method_url, params=payload)

async def set_my_profile_photo(token, photo):
method_url = r'setMyProfilePhoto'
payload = {}
photo_json, files = photo.convert_input_profile_photo()
payload['photo'] = photo_json

return await _process_request(token, method_url, params=payload, files=files, method='post')

async def remove_my_profile_photo(token):
method_url = r'removeMyProfilePhoto'
return await _process_request(token, method_url, method='post')

async def set_chat_menu_button(token, chat_id=None, menu_button=None):
method_url = r'setChatMenuButton'
payload = {}
Expand Down
Loading