Skip to content

Commit da8f38d

Browse files
Added the field can_manage_bots to the class User. Added the class KeyboardButtonRequestManagedBot and the field request_managed_bot to the class KeyboardButton.
1 parent 6970a3c commit da8f38d

File tree

1 file changed

+55
-4
lines changed

1 file changed

+55
-4
lines changed

telebot/types.py

Lines changed: 55 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,9 @@ class User(JsonDeserializable, Dictionaryable, JsonSerializable):
518518
:param allows_users_to_create_topics: Optional. True, if the bot allows users to create and delete topics in private chats. Returned only in getMe.
519519
:type allows_users_to_create_topics: :obj:`bool`
520520

521+
:param can_manage_bots: Optional. True, if other bots can be created to be controlled by the bot. Returned only in getMe.
522+
:type can_manage_bots: :obj:`bool`
523+
521524
:return: Instance of the class
522525
:rtype: :class:`telebot.types.User`
523526
"""
@@ -531,7 +534,7 @@ def de_json(cls, json_string):
531534
def __init__(self, id, is_bot, first_name, last_name=None, username=None, language_code=None,
532535
can_join_groups=None, can_read_all_group_messages=None, supports_inline_queries=None,
533536
is_premium=None, added_to_attachment_menu=None, can_connect_to_business=None,
534-
has_main_web_app=None, has_topics_enabled=None, allows_users_to_create_topics=None, **kwargs):
537+
has_main_web_app=None, has_topics_enabled=None, allows_users_to_create_topics=None, can_manage_bots=None, **kwargs):
535538
self.id: int = id
536539
self.is_bot: bool = is_bot
537540
self.first_name: str = first_name
@@ -547,7 +550,7 @@ def __init__(self, id, is_bot, first_name, last_name=None, username=None, langua
547550
self.has_main_web_app: Optional[bool] = has_main_web_app
548551
self.has_topics_enabled: Optional[bool] = has_topics_enabled
549552
self.allows_users_to_create_topics: Optional[bool] = allows_users_to_create_topics
550-
553+
self.can_manage_bots: Optional[bool] = can_manage_bots
551554
@property
552555
def full_name(self) -> str:
553556
"""
@@ -576,7 +579,8 @@ def to_dict(self):
576579
'can_connect_to_business': self.can_connect_to_business,
577580
'has_main_web_app': self.has_main_web_app,
578581
'has_topics_enabled': self.has_topics_enabled,
579-
'allows_users_to_create_topics': self.allows_users_to_create_topics
582+
'allows_users_to_create_topics': self.allows_users_to_create_topics,
583+
'can_manage_bots': self.can_manage_bots
580584
}
581585

582586

@@ -2970,14 +2974,19 @@ class KeyboardButton(Dictionaryable, JsonSerializable):
29702974
send its identifier to the bot in a “chat_shared” service message. Available in private chats only.
29712975
:type request_chat: :class:`telebot.types.KeyboardButtonRequestChat`
29722976

2977+
:param request_managed_bot: Optional. If specified, pressing the button will ask the user to create and share a bot
2978+
that will be managed by the current bot. Available for bots that enabled management of other bots in the @BotFather
2979+
Mini App. Available in private chats only.
2980+
:type request_managed_bot: :class:`telebot.types.KeyboardButtonRequestManagedBot`
2981+
29732982
:return: Instance of the class
29742983
:rtype: :class:`telebot.types.KeyboardButton`
29752984
"""
29762985
def __init__(self, text: str, request_contact: Optional[bool]=None,
29772986
request_location: Optional[bool]=None, request_poll: Optional[KeyboardButtonPollType]=None,
29782987
web_app: Optional[WebAppInfo]=None, request_user: Optional[KeyboardButtonRequestUser]=None,
29792988
request_chat: Optional[KeyboardButtonRequestChat]=None, request_users: Optional[KeyboardButtonRequestUsers]=None,
2980-
icon_custom_emoji_id: Optional[str]=None, style: Optional[str]=None, **kwargs):
2989+
icon_custom_emoji_id: Optional[str]=None, style: Optional[str]=None, request_managed_bot: Optional[KeyboardButtonRequestManagedBot]=None):
29812990
self.text: str = text
29822991
self.request_contact: Optional[bool] = request_contact
29832992
self.request_location: Optional[bool] = request_location
@@ -2987,6 +2996,7 @@ def __init__(self, text: str, request_contact: Optional[bool]=None,
29872996
self.request_users: Optional[KeyboardButtonRequestUsers] = request_users
29882997
self.icon_custom_emoji_id: Optional[str] = icon_custom_emoji_id
29892998
self.style: Optional[str] = style
2999+
self.request_managed_bot: Optional[KeyboardButtonRequestManagedBot] = request_managed_bot
29903000
if request_user is not None:
29913001
log_deprecation_warning('The parameter "request_user" is deprecated, use "request_users" instead')
29923002
if self.request_users is None:
@@ -3015,6 +3025,8 @@ def to_dict(self):
30153025
json_dict['icon_custom_emoji_id'] = self.icon_custom_emoji_id
30163026
if self.style is not None:
30173027
json_dict['style'] = self.style
3028+
if self.request_managed_bot is not None:
3029+
json_dict['request_managed_bot'] = self.request_managed_bot.to_dict()
30183030
return json_dict
30193031

30203032

@@ -13655,3 +13667,42 @@ def de_json(cls, json_string):
1365513667
obj['audios'] = [Audio.de_json(audio) for audio in obj['audios']]
1365613668
return cls(**obj)
1365713669

13670+
13671+
class KeyboardButtonRequestManagedBot(JsonSerializable):
13672+
"""
13673+
This object defines the parameters for the creation of a managed bot.
13674+
Information about the created bot will be shared with the bot using the update managed_bot and a Message with
13675+
the field managed_bot_created.
13676+
13677+
Telegram documentation: https://core.telegram.org/bots/api#keyboardbuttonrequestmanagedbot
13678+
13679+
:param request_id: Signed 32-bit identifier of the request. Must be unique within the message
13680+
:type request_id: :obj:`int`
13681+
13682+
:param suggested_name: Optional. Suggested name for the bot
13683+
:type suggested_name: :obj:`str`
13684+
13685+
:param suggested_username: Optional. Suggested username for the bot
13686+
:type suggested_username: :obj:`str`
13687+
13688+
:return: Instance of the class
13689+
:rtype: :class:`KeyboardButtonRequestManagedBot`
13690+
"""
13691+
def __init__(self, request_id: int, suggested_name: Optional[str] = None, suggested_username: Optional[str] = None, **kwargs):
13692+
self.request_id: int = request_id
13693+
self.suggested_name: Optional[str] = suggested_name
13694+
self.suggested_username: Optional[str] = suggested_username
13695+
13696+
def to_json(self):
13697+
return json.dumps(self.to_dict())
13698+
13699+
def to_dict(self):
13700+
data = {
13701+
'request_id': self.request_id
13702+
}
13703+
if self.suggested_name:
13704+
data['suggested_name'] = self.suggested_name
13705+
if self.suggested_username:
13706+
data['suggested_username'] = self.suggested_username
13707+
return data
13708+

0 commit comments

Comments
 (0)