Skip to content

Commit 742c0ae

Browse files
Added the class ChatOwnerLeft and the field chat_owner_left to the class Message. Added the class ChatOwnerChanged and the field chat_owner_changed to the class Message.
1 parent fb3405e commit 742c0ae

2 files changed

Lines changed: 61 additions & 2 deletions

File tree

telebot/types.py

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1133,6 +1133,12 @@ class Message(JsonDeserializable):
11331133
the bot itself)
11341134
:type left_chat_member: :class:`telebot.types.User`
11351135

1136+
:param chat_owner_left: Optional. Service message: chat owner has left
1137+
:type chat_owner_left: :class:`telebot.types.ChatOwnerLeft`
1138+
1139+
:param chat_owner_changed: Optional. Service message: chat owner has changed
1140+
:type chat_owner_changed: :class:`telebot.types.ChatOwnerChanged`
1141+
11361142
:param new_chat_title: Optional. A chat title was changed to this value
11371143
:type new_chat_title: :obj:`str`
11381144

@@ -1584,6 +1590,12 @@ def de_json(cls, json_string):
15841590
if 'suggested_post_refunded' in obj:
15851591
opts['suggested_post_refunded'] = SuggestedPostRefunded.de_json(obj['suggested_post_refunded'])
15861592
content_type = 'suggested_post_refunded'
1593+
if 'chat_owner_changed' in obj:
1594+
opts['chat_owner_changed'] = ChatOwnerChanged.de_json(obj['chat_owner_changed'])
1595+
content_type = 'chat_owner_changed'
1596+
if 'chat_owner_left' in obj:
1597+
opts['chat_owner_left'] = ChatOwnerLeft.de_json(obj['chat_owner_left'])
1598+
content_type = 'chat_owner_left'
15871599

15881600
return cls(message_id, from_user, date, chat, content_type, opts, json_string)
15891601

@@ -1720,6 +1732,8 @@ def __init__(self, message_id, from_user, date, chat, content_type, options, jso
17201732
self.suggested_post_declined: Optional[SuggestedPostDeclined] = None
17211733
self.suggested_post_paid: Optional[SuggestedPostPaid] = None
17221734
self.suggested_post_refunded: Optional[SuggestedPostRefunded] = None
1735+
self.chat_owner_left: Optional[ChatOwnerLeft] = None
1736+
self.chat_owner_changed: Optional[ChatOwnerChanged] = None
17231737

17241738
for key in options:
17251739
setattr(self, key, options[key])
@@ -13505,4 +13519,49 @@ def de_json(cls, json_string):
1350513519
obj = cls.check_json(json_string)
1350613520
return cls(**obj)
1350713521

13508-
13522+
13523+
class ChatOwnerLeft(JsonDeserializable):
13524+
"""
13525+
Describes a service message about the chat owner leaving the chat.
13526+
13527+
Telegram documentation: https://core.telegram.org/bots/api#chatownerleft
13528+
13529+
:param new_owner: Optional. The user which will be the new owner of the chat if the previous owner does not return to the chat
13530+
:type new_owner: :class:`User`
13531+
13532+
:return: Instance of the class
13533+
:rtype: :class:`ChatOwnerLeft`
13534+
"""
13535+
def __init__(self, new_owner: Optional[User] = None, **kwargs):
13536+
self.new_owner: Optional[User] = new_owner
13537+
13538+
@classmethod
13539+
def de_json(cls, json_string):
13540+
if json_string is None: return None
13541+
obj = cls.check_json(json_string)
13542+
if 'new_owner' in obj:
13543+
obj['new_owner'] = User.de_json(obj['new_owner'])
13544+
return cls(**obj)
13545+
13546+
class ChatOwnerChanged(JsonDeserializable):
13547+
"""
13548+
Describes a service message about an ownership change in the chat.
13549+
13550+
Telegram documentation: https://core.telegram.org/bots/api#chatownerchanged
13551+
13552+
:param new_owner: The new owner of the chat
13553+
:type new_owner: :class:`User`
13554+
13555+
:return: Instance of the class
13556+
:rtype: :class:`ChatOwnerChanged`
13557+
"""
13558+
def __init__(self, new_owner: User, **kwargs):
13559+
self.new_owner: User = new_owner
13560+
13561+
@classmethod
13562+
def de_json(cls, json_string):
13563+
if json_string is None: return None
13564+
obj = cls.check_json(json_string)
13565+
obj['new_owner'] = User.de_json(obj['new_owner'])
13566+
return cls(**obj)
13567+

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'
46+
'suggested_post_paid', 'gift_upgrade_sent', 'chat_owner_left', 'chat_owner_changed'
4747
]
4848

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

0 commit comments

Comments
 (0)