Skip to content

Commit 69e110f

Browse files
Added the class ManagedBotCreated and the field managed_bot_created to the class Message.
1 parent 83c17c4 commit 69e110f

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

telebot/types.py

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1279,6 +1279,9 @@ class Message(JsonDeserializable):
12791279
:param giveaway_completed: Optional. Service message: giveaway completed, without public winners
12801280
:type giveaway_completed: :class:`telebot.types.GiveawayCompleted`
12811281

1282+
:param managed_bot_created: Optional. Service message: user created a bot that will be managed by the current bot
1283+
:type managed_bot_created: :class:`telebot.types.ManagedBotCreated`
1284+
12821285
:param paid_message_price_changed: Optional. Service message: the price for paid messages has changed in the chat
12831286
:type paid_message_price_changed: :class:`telebot.types.PaidMessagePriceChanged`
12841287

@@ -1611,6 +1614,9 @@ def de_json(cls, json_string):
16111614
if 'chat_owner_left' in obj:
16121615
opts['chat_owner_left'] = ChatOwnerLeft.de_json(obj['chat_owner_left'])
16131616
content_type = 'chat_owner_left'
1617+
if 'managed_bot_created' in obj:
1618+
opts['managed_bot_created'] = ManagedBotCreated.de_json(obj['managed_bot_created'])
1619+
content_type = 'managed_bot_created'
16141620

16151621
return cls(message_id, from_user, date, chat, content_type, opts, json_string)
16161622

@@ -1750,6 +1756,7 @@ def __init__(self, message_id, from_user, date, chat, content_type, options, jso
17501756
self.suggested_post_refunded: Optional[SuggestedPostRefunded] = None
17511757
self.chat_owner_left: Optional[ChatOwnerLeft] = None
17521758
self.chat_owner_changed: Optional[ChatOwnerChanged] = None
1759+
self.managed_bot_created: Optional[ManagedBotCreated] = None
17531760

17541761
for key in options:
17551762
setattr(self, key, options[key])
@@ -13760,4 +13767,27 @@ def to_dict(self):
1376013767
if self.suggested_username:
1376113768
data['suggested_username'] = self.suggested_username
1376213769
return data
13763-
13770+
13771+
13772+
class ManagedBotCreated(JsonDeserializable):
13773+
"""
13774+
This object contains information about the bot that was created to be managed by the current bot.
13775+
13776+
Telegram documentation: https://core.telegram.org/bots/api#managedbotcreated
13777+
13778+
:param bot: Information about the bot. The bot's token can be fetched using the method getManagedBotToken.
13779+
:type bot: :class:`User`
13780+
13781+
:return: Instance of the class
13782+
:rtype: :class:`ManagedBotCreated`
13783+
"""
13784+
def __init__(self, bot: User, **kwargs):
13785+
self.bot: User = bot
13786+
13787+
@classmethod
13788+
def de_json(cls, json_string):
13789+
if json_string is None: return None
13790+
obj = cls.check_json(json_string)
13791+
obj['bot'] = User.de_json(obj['bot'])
13792+
return cls(**obj)
13793+

telebot/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
'giveaway_created', 'giveaway_winners', 'giveaway_completed', 'boost_added', 'paid_message_price_changed',
4444
'checklist_tasks_done', 'checklist_tasks_added', 'direct_message_price_changed', 'suggested_post_refunded',
4545
'suggested_post_info', 'suggested_post_approved', 'suggested_post_approval_failed', 'suggested_post_declined',
46-
'suggested_post_paid', 'gift_upgrade_sent', 'chat_owner_left', 'chat_owner_changed'
46+
'suggested_post_paid', 'gift_upgrade_sent', 'chat_owner_left', 'chat_owner_changed', 'managed_bot_created'
4747
]
4848

4949
#: All update types, should be used for allowed_updates parameter in polling.

0 commit comments

Comments
 (0)