Skip to content

Commit 4b23926

Browse files
authored
Merge pull request #2553 from coder2020official/botapi-94
Botapi 9.4
2 parents bc4374f + bec87fa commit 4b23926

File tree

7 files changed

+340
-18
lines changed

7 files changed

+340
-18
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<p align="center">A simple, but extensible Python implementation for the <a href="https://core.telegram.org/bots/api">Telegram Bot API</a>.</p>
1111
<p align="center">Both synchronous and asynchronous.</p>
1212

13-
## <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>
13+
## <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>
1414

1515
<h2><a href='https://pytba.readthedocs.io/en/latest/index.html'>Official documentation</a></h2>
1616
<h2><a href='https://pytba.readthedocs.io/ru/latest/index.html'>Official ru documentation</a></h2>

telebot/__init__.py

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1512,6 +1512,29 @@ def get_user_profile_photos(self, user_id: int, offset: Optional[int]=None,
15121512
apihelper.get_user_profile_photos(self.token, user_id, offset=offset, limit=limit)
15131513
)
15141514

1515+
def get_user_profile_audios(self, user_id: int, offset: Optional[int]=None,
1516+
limit: Optional[int]=None) -> types.UserProfileAudios:
1517+
"""
1518+
Use this method to get a list of profile audios for a user. Returns a :class:`telebot.types.UserProfileAudios` object.
1519+
1520+
Telegram documentation: https://core.telegram.org/bots/api#getuserprofileaudios
1521+
1522+
:param user_id: Unique identifier of the target user
1523+
:type user_id: :obj:`int`
1524+
1525+
:param offset: Sequential number of the first audio to be returned. By default, all audios are returned.
1526+
:type offset: :obj:`int`
1527+
1528+
:param limit: Limits the number of audios to be retrieved. Values between 1-100 are accepted. Defaults to 100.
1529+
:type limit: :obj:`int`
1530+
1531+
:return: If the request is successful, a UserProfileAudios object is returned.
1532+
:rtype: :class:`telebot.types.UserProfileAudios`
1533+
"""
1534+
return types.UserProfileAudios.de_json(
1535+
apihelper.get_user_profile_audios(self.token, user_id, offset=offset, limit=limit)
1536+
)
1537+
15151538
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:
15161539
"""
15171540
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.
@@ -5048,6 +5071,31 @@ def get_my_short_description(self, language_code: Optional[str]=None):
50485071
return types.BotShortDescription.de_json(
50495072
apihelper.get_my_short_description(self.token, language_code=language_code))
50505073

5074+
def set_my_profile_photo(self, photo: types.InputProfilePhoto) -> bool:
5075+
"""
5076+
Use this method to change the profile photo of the bot. Returns True on success.
5077+
5078+
Telegram documentation: https://core.telegram.org/bots/api#setmyprofilephoto
5079+
5080+
:param photo: The new profile photo to set
5081+
:type photo: :class:`telebot.types.InputProfilePhoto`
5082+
5083+
:return: True on success.
5084+
:rtype: :obj:`bool`
5085+
"""
5086+
return apihelper.set_my_profile_photo(self.token, photo)
5087+
5088+
def remove_my_profile_photo(self) -> bool:
5089+
"""
5090+
Use this method to remove the profile photo of the bot. Requires no parameters. Returns True on success.
5091+
5092+
Telegram documentation: https://core.telegram.org/bots/api#removemyprofilephoto
5093+
5094+
:return: True on success.
5095+
:rtype: :obj:`bool`
5096+
"""
5097+
return apihelper.remove_my_profile_photo(self.token)
5098+
50515099

50525100
def set_chat_menu_button(self, chat_id: Union[int, str]=None, menu_button: types.MenuButton=None) -> bool:
50535101
"""
@@ -7758,7 +7806,7 @@ def delete_sticker_from_set(self, sticker: str) -> bool:
77587806
77597807
:param sticker: File identifier of the sticker
77607808
:return: On success, True is returned.
7761-
:rtype: :obj:`bool`
7809+
:rtype: :obj:`bool`
77627810
"""
77637811
return apihelper.delete_sticker_from_set(self.token, sticker)
77647812

@@ -7767,8 +7815,8 @@ def create_forum_topic(self,
77677815
chat_id: int, name: str, icon_color: Optional[int]=None,
77687816
icon_custom_emoji_id: Optional[str]=None) -> types.ForumTopic:
77697817
"""
7770-
Use this method to create a topic in a forum supergroup chat. The bot must be an administrator
7771-
in the chat for this to work and must have the can_manage_topics administrator rights.
7818+
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
7819+
must be an administrator in the chat for this to work and must have the can_manage_topics administrator right.
77727820
Returns information about the created topic as a ForumTopic object.
77737821
77747822
Telegram documentation: https://core.telegram.org/bots/api#createforumtopic

telebot/apihelper.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,16 @@ def get_user_profile_photos(token, user_id, offset=None, limit=None):
349349
return _make_request(token, method_url, params=payload)
350350

351351

352+
def get_user_profile_audios(token, user_id, offset=None, limit=None):
353+
method_url = r'getUserProfileAudios'
354+
payload = {'user_id': user_id}
355+
if offset:
356+
payload['offset'] = offset
357+
if limit:
358+
payload['limit'] = limit
359+
return _make_request(token, method_url, params=payload)
360+
361+
352362
def set_user_emoji_status(token, user_id, emoji_status_custom_emoji_id=None, emoji_status_expiration_date=None):
353363
method_url = r'setUserEmojiStatus'
354364
payload = {'user_id': user_id}
@@ -1526,6 +1536,17 @@ def get_my_name(token, language_code=None):
15261536
payload['language_code'] = language_code
15271537
return _make_request(token, method_url, params=payload)
15281538

1539+
def set_my_profile_photo(token, photo):
1540+
method_url = r'setMyProfilePhoto'
1541+
payload = {}
1542+
photo_json, files = photo.convert_input_profile_photo()
1543+
payload['photo'] = photo_json
1544+
return _make_request(token, method_url, params=payload, files=files, method='post')
1545+
1546+
def delete_my_profile_photo(token):
1547+
method_url = r'deleteMyProfilePhoto'
1548+
return _make_request(token, method_url, method='post')
1549+
15291550
def set_chat_menu_button(token, chat_id=None, menu_button=None):
15301551
method_url = r'setChatMenuButton'
15311552
payload = {}

telebot/async_telebot.py

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2989,6 +2989,26 @@ async def get_user_profile_photos(self, user_id: int, offset: Optional[int]=None
29892989
result = await asyncio_helper.get_user_profile_photos(self.token, user_id, offset, limit)
29902990
return types.UserProfilePhotos.de_json(result)
29912991

2992+
async def get_user_profile_audios(self, user_id: int, offset: Optional[int]=None, limit: Optional[int]=None) -> types.UserProfileAudios:
2993+
"""
2994+
Use this method to get a list of profile audios for a user. Returns a UserProfileAudios object.
2995+
2996+
Telegram documentation: https://core.telegram.org/bots/api#getuserprofileaudios
2997+
2998+
:param user_id: Unique identifier of the target user
2999+
:type user_id: :obj:`int`
3000+
3001+
:param offset: Sequential number of the first audio to be returned. By default, all audios are returned.
3002+
:type offset: :obj:`int`
3003+
3004+
:param limit: Limits the number of audios to be retrieved. Values between 1-100 are accepted. Defaults to 100.
3005+
:type limit: :obj:`int`
3006+
3007+
:return: If successful, returns a UserProfileAudios object.
3008+
:rtype: :class:`telebot.types.UserProfileAudios`
3009+
"""
3010+
return types.UserProfileAudios.de_json(await asyncio_helper.get_user_profile_audios(self.token, user_id, offset=offset, limit=limit))
3011+
29923012
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:
29933013
"""
29943014
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.
@@ -6533,6 +6553,31 @@ async def get_my_name(self, language_code: Optional[str]=None):
65336553
result = await asyncio_helper.get_my_name(self.token, language_code)
65346554
return types.BotName.de_json(result)
65356555

6556+
async def set_my_profile_photo(self, photo: types.InputProfilePhoto) -> bool:
6557+
"""
6558+
Use this method to change the profile photo of the bot. Returns True on success.
6559+
6560+
Telegram documentation: https://core.telegram.org/bots/api#setmyprofilephoto
6561+
6562+
:param photo: InputProfilePhoto: The new profile photo to set
6563+
:type photo: :class:`telebot.types.InputProfilePhoto`
6564+
6565+
:return: True on success.
6566+
:rtype: :obj:`bool`
6567+
"""
6568+
return await asyncio_helper.set_my_profile_photo(self.token, photo)
6569+
6570+
async def remove_my_profile_photo(self) -> bool:
6571+
"""
6572+
Use this method to remove the profile photo of the bot. Requires no parameters. Returns True on success.
6573+
6574+
Telegram documentation: https://core.telegram.org/bots/api#removemyprofilephoto
6575+
6576+
:return: True on success.
6577+
:rtype: :obj:`bool`
6578+
"""
6579+
return await asyncio_helper.remove_my_profile_photo(self.token)
6580+
65366581
async def set_chat_menu_button(self, chat_id: Union[int, str]=None,
65376582
menu_button: types.MenuButton=None) -> bool:
65386583
"""
@@ -9193,8 +9238,8 @@ async def create_forum_topic(self,
91939238
chat_id: int, name: str, icon_color: Optional[int]=None,
91949239
icon_custom_emoji_id: Optional[str]=None) -> types.ForumTopic:
91959240
"""
9196-
Use this method to create a topic in a forum supergroup chat. The bot must be an administrator
9197-
in the chat for this to work and must have the can_manage_topics administrator rights.
9241+
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
9242+
must be an administrator in the chat for this to work and must have the can_manage_topics administrator right.
91989243
Returns information about the created topic as a ForumTopic object.
91999244
92009245
Telegram documentation: https://core.telegram.org/bots/api#createforumtopic

telebot/asyncio_helper.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,16 @@ async def get_user_profile_photos(token, user_id, offset=None, limit=None):
330330
return await _process_request(token, method_url, params=payload)
331331

332332

333+
async def get_user_profile_audios(token, user_id, offset=None, limit=None):
334+
method_url = r'getUserProfileAudios'
335+
payload = {'user_id': user_id}
336+
if offset:
337+
payload['offset'] = offset
338+
if limit:
339+
payload['limit'] = limit
340+
return await _process_request(token, method_url, params=payload)
341+
342+
333343
async def set_user_emoji_status(token, user_id, emoji_status_custom_emoji_id=None, emoji_status_expiration_date=None):
334344
method_url = r'setUserEmojiStatus'
335345
payload = {'user_id': user_id}
@@ -1517,6 +1527,18 @@ async def get_my_name(token, language_code=None):
15171527
payload['language_code'] = language_code
15181528
return await _process_request(token, method_url, params=payload)
15191529

1530+
async def set_my_profile_photo(token, photo):
1531+
method_url = r'setMyProfilePhoto'
1532+
payload = {}
1533+
photo_json, files = photo.convert_input_profile_photo()
1534+
payload['photo'] = photo_json
1535+
1536+
return await _process_request(token, method_url, params=payload, files=files, method='post')
1537+
1538+
async def remove_my_profile_photo(token):
1539+
method_url = r'removeMyProfilePhoto'
1540+
return await _process_request(token, method_url, method='post')
1541+
15201542
async def set_chat_menu_button(token, chat_id=None, menu_button=None):
15211543
method_url = r'setChatMenuButton'
15221544
payload = {}

0 commit comments

Comments
 (0)