Skip to content

Commit 1ef9b37

Browse files
committed
Add support for Bot API version 9.5
1 parent 5d06ec9 commit 1ef9b37

8 files changed

Lines changed: 247 additions & 15 deletions

File tree

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#february-9-2026"><img src="https://img.shields.io/badge/Bot%20API-9.4-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#march-1-2026"><img src="https://img.shields.io/badge/Bot%20API-9.5-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: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4237,7 +4237,7 @@ def send_message_draft(
42374237
entities: Optional[List[types.MessageEntity]]=None):
42384238
"""
42394239
Use this method to stream a partial message to a user while the message is being generated;
4240-
supported only for bots with forum topic mode enabled. Returns True on success.
4240+
available for all bots. Returns True on success.
42414241
42424242
Telegram documentation: https://core.telegram.org/bots/api#sendmessagedraft
42434243
@@ -4487,7 +4487,8 @@ def promote_chat_member(
44874487
can_post_stories: Optional[bool]=None,
44884488
can_edit_stories: Optional[bool]=None,
44894489
can_delete_stories: Optional[bool]=None,
4490-
can_manage_direct_messages: Optional[bool]=None) -> bool:
4490+
can_manage_direct_messages: Optional[bool]=None,
4491+
can_manage_tags: Optional[bool]=None) -> bool:
44914492
"""
44924493
Use this method to promote or demote a user in a supergroup or a channel. The bot must be an administrator
44934494
in the chat for this to work and must have the appropriate admin rights.
@@ -4561,6 +4562,9 @@ def promote_chat_member(
45614562
within the channel and decline suggested posts; for channels only
45624563
:type can_manage_direct_messages: :obj:`bool`
45634564
4565+
:param can_manage_tags: Pass True if the administrator can manage tags in the chat
4566+
:type can_manage_tags: :obj:`bool`
4567+
45644568
:return: True on success.
45654569
:rtype: :obj:`bool`
45664570
"""
@@ -4578,6 +4582,7 @@ def promote_chat_member(
45784582
can_manage_video_chats=can_manage_video_chats, can_manage_topics=can_manage_topics,
45794583
can_post_stories=can_post_stories, can_edit_stories=can_edit_stories,
45804584
can_delete_stories=can_delete_stories, can_manage_direct_messages=can_manage_direct_messages,
4585+
can_manage_tags=can_manage_tags,
45814586
)
45824587

45834588

@@ -4606,6 +4611,30 @@ def set_chat_administrator_custom_title(
46064611
return apihelper.set_chat_administrator_custom_title(self.token, chat_id, user_id, custom_title)
46074612

46084613

4614+
def set_chat_member_tag(
4615+
self, chat_id: Union[int, str], user_id: int, tag: Optional[str]=None) -> bool:
4616+
"""
4617+
Use this method to set a new tag for a member in a chat.
4618+
Returns True on success.
4619+
4620+
Telegram documentation: https://core.telegram.org/bots/api#setchatmembertag
4621+
4622+
:param chat_id: Unique identifier for the target chat or username of the target supergroup
4623+
(in the format @supergroupusername)
4624+
:type chat_id: :obj:`int` or :obj:`str`
4625+
4626+
:param user_id: Unique identifier of the target user
4627+
:type user_id: :obj:`int`
4628+
4629+
:param tag: New tag for the member; pass an empty string to remove the tag
4630+
:type tag: :obj:`str`
4631+
4632+
:return: True on success.
4633+
:rtype: :obj:`bool`
4634+
"""
4635+
return apihelper.set_chat_member_tag(self.token, chat_id, user_id, tag)
4636+
4637+
46094638
def ban_chat_sender_chat(self, chat_id: Union[int, str], sender_chat_id: Union[int, str]) -> bool:
46104639
"""
46114640
Use this method to ban a channel chat in a supergroup or a channel.

telebot/apihelper.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1287,7 +1287,7 @@ def promote_chat_member(
12871287
can_restrict_members=None, can_pin_messages=None, can_promote_members=None,
12881288
is_anonymous=None, can_manage_chat=None, can_manage_video_chats=None,
12891289
can_manage_topics=None, can_post_stories=None, can_edit_stories=None,
1290-
can_delete_stories=None, can_manage_direct_messages=None):
1290+
can_delete_stories=None, can_manage_direct_messages=None, can_manage_tags=None):
12911291
method_url = 'promoteChatMember'
12921292
payload = {'chat_id': chat_id, 'user_id': user_id}
12931293
if can_change_info is not None:
@@ -1322,6 +1322,8 @@ def promote_chat_member(
13221322
payload['can_delete_stories'] = can_delete_stories
13231323
if can_manage_direct_messages is not None:
13241324
payload['can_manage_direct_messages'] = can_manage_direct_messages
1325+
if can_manage_tags is not None:
1326+
payload['can_manage_tags'] = can_manage_tags
13251327
return _make_request(token, method_url, params=payload, method='post')
13261328

13271329

@@ -1333,6 +1335,14 @@ def set_chat_administrator_custom_title(token, chat_id, user_id, custom_title):
13331335
return _make_request(token, method_url, params=payload, method='post')
13341336

13351337

1338+
def set_chat_member_tag(token, chat_id, user_id, tag=None):
1339+
method_url = 'setChatMemberTag'
1340+
payload = {'chat_id': chat_id, 'user_id': user_id}
1341+
if tag is not None:
1342+
payload['tag'] = tag
1343+
return _make_request(token, method_url, params=payload, method='post')
1344+
1345+
13361346
def ban_chat_sender_chat(token, chat_id, sender_chat_id):
13371347
method_url = 'banChatSenderChat'
13381348
payload = {'chat_id': chat_id, 'sender_chat_id': sender_chat_id}

telebot/async_telebot.py

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5757,7 +5757,7 @@ async def send_message_draft(
57575757
entities: Optional[List[types.MessageEntity]]=None):
57585758
"""
57595759
Use this method to stream a partial message to a user while the message is being generated;
5760-
supported only for bots with forum topic mode enabled. Returns True on success.
5760+
available for all bots. Returns True on success.
57615761
57625762
Telegram documentation: https://core.telegram.org/bots/api#sendmessagedraft
57635763
@@ -5996,7 +5996,8 @@ async def promote_chat_member(
59965996
can_post_stories: Optional[bool]=None,
59975997
can_edit_stories: Optional[bool]=None,
59985998
can_delete_stories: Optional[bool]=None,
5999-
can_manage_direct_messages: Optional[bool]=None) -> bool:
5999+
can_manage_direct_messages: Optional[bool]=None,
6000+
can_manage_tags: Optional[bool]=None) -> bool:
60006001
"""
60016002
Use this method to promote or demote a user in a supergroup or a channel. The bot must be an administrator
60026003
in the chat for this to work and must have the appropriate admin rights.
@@ -6070,6 +6071,9 @@ async def promote_chat_member(
60706071
within the channel and decline suggested posts; for channels only
60716072
:type can_manage_direct_messages: :obj:`bool`
60726073
6074+
:param can_manage_tags: Pass True if the administrator can manage tags in the chat
6075+
:type can_manage_tags: :obj:`bool`
6076+
60736077
:return: True on success.
60746078
:rtype: :obj:`bool`
60756079
"""
@@ -6084,7 +6088,8 @@ async def promote_chat_member(
60846088
can_edit_messages, can_delete_messages, can_invite_users,
60856089
can_restrict_members, can_pin_messages, can_promote_members,
60866090
is_anonymous, can_manage_chat, can_manage_video_chats, can_manage_topics,
6087-
can_post_stories, can_edit_stories, can_delete_stories, can_manage_direct_messages=can_manage_direct_messages
6091+
can_post_stories, can_edit_stories, can_delete_stories,
6092+
can_manage_direct_messages=can_manage_direct_messages, can_manage_tags=can_manage_tags
60886093
)
60896094

60906095
async def set_chat_administrator_custom_title(
@@ -6112,6 +6117,30 @@ async def set_chat_administrator_custom_title(
61126117
return await asyncio_helper.set_chat_administrator_custom_title(self.token, chat_id, user_id, custom_title)
61136118

61146119

6120+
async def set_chat_member_tag(
6121+
self, chat_id: Union[int, str], user_id: int, tag: Optional[str]=None) -> bool:
6122+
"""
6123+
Use this method to set a new tag for a member in a chat.
6124+
Returns True on success.
6125+
6126+
Telegram documentation: https://core.telegram.org/bots/api#setchatmembertag
6127+
6128+
:param chat_id: Unique identifier for the target chat or username of the target supergroup
6129+
(in the format @supergroupusername)
6130+
:type chat_id: :obj:`int` or :obj:`str`
6131+
6132+
:param user_id: Unique identifier of the target user
6133+
:type user_id: :obj:`int`
6134+
6135+
:param tag: New tag for the member; pass an empty string to remove the tag
6136+
:type tag: :obj:`str`
6137+
6138+
:return: True on success.
6139+
:rtype: :obj:`bool`
6140+
"""
6141+
return await asyncio_helper.set_chat_member_tag(self.token, chat_id, user_id, tag)
6142+
6143+
61156144
async def ban_chat_sender_chat(self, chat_id: Union[int, str], sender_chat_id: Union[int, str]) -> bool:
61166145
"""
61176146
Use this method to ban a channel chat in a supergroup or a channel.

telebot/asyncio_helper.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1281,7 +1281,7 @@ async def promote_chat_member(
12811281
can_restrict_members=None, can_pin_messages=None, can_promote_members=None,
12821282
is_anonymous=None, can_manage_chat=None, can_manage_video_chats=None, can_manage_topics=None,
12831283
can_post_stories=None, can_edit_stories=None, can_delete_stories=None,
1284-
can_manage_direct_messages=None):
1284+
can_manage_direct_messages=None, can_manage_tags=None):
12851285
method_url = 'promoteChatMember'
12861286
payload = {'chat_id': chat_id, 'user_id': user_id}
12871287
if can_change_info is not None:
@@ -1316,6 +1316,8 @@ async def promote_chat_member(
13161316
payload['can_delete_stories'] = can_delete_stories
13171317
if can_manage_direct_messages is not None:
13181318
payload['can_manage_direct_messages'] = can_manage_direct_messages
1319+
if can_manage_tags is not None:
1320+
payload['can_manage_tags'] = can_manage_tags
13191321
return await _process_request(token, method_url, params=payload, method='post')
13201322

13211323

@@ -1327,6 +1329,14 @@ async def set_chat_administrator_custom_title(token, chat_id, user_id, custom_ti
13271329
return await _process_request(token, method_url, params=payload, method='post')
13281330

13291331

1332+
async def set_chat_member_tag(token, chat_id, user_id, tag=None):
1333+
method_url = 'setChatMemberTag'
1334+
payload = {'chat_id': chat_id, 'user_id': user_id}
1335+
if tag is not None:
1336+
payload['tag'] = tag
1337+
return await _process_request(token, method_url, params=payload, method='post')
1338+
1339+
13301340
async def ban_chat_sender_chat(token, chat_id, sender_chat_id):
13311341
method_url = 'banChatSenderChat'
13321342
payload = {'chat_id': chat_id, 'sender_chat_id': sender_chat_id}

0 commit comments

Comments
 (0)