From 070b81ddbbc0cebd3334563f28368d2393ede791 Mon Sep 17 00:00:00 2001 From: Mahdyar Hasanpour Date: Tue, 2 Apr 2024 10:01:06 +0330 Subject: [PATCH 1/3] feat: add the field `is_from_offline` to the class `Message` --- telegram/_message.py | 9 +++++++++ tests/test_message.py | 2 ++ 2 files changed, 11 insertions(+) diff --git a/telegram/_message.py b/telegram/_message.py index 62848565a3d..1cbc58e0b3c 100644 --- a/telegram/_message.py +++ b/telegram/_message.py @@ -302,6 +302,9 @@ class Message(MaybeInaccessibleMessage): forwarded. .. versionadded:: 13.9 + is_from_offline (:obj:`bool`, optional): :obj:`True`, if the message was sent + by an implicit action, for example, as an away or a greeting business message, + or as a scheduled message. media_group_id (:obj:`str`, optional): The unique identifier of a media message group this message belongs to. text (:obj:`str`, optional): For text messages, the actual UTF-8 text of the message, @@ -581,6 +584,9 @@ class Message(MaybeInaccessibleMessage): forwarded. .. versionadded:: 13.9 + is_from_offline (:obj:`bool`): Optional. :obj:`True`, if the message was sent + by an implicit action, for example, as an away or a greeting business message, + or as a scheduled message. media_group_id (:obj:`str`): Optional. The unique identifier of a media message group this message belongs to. text (:obj:`str`): Optional. For text messages, the actual UTF-8 text of the message, @@ -888,6 +894,7 @@ class Message(MaybeInaccessibleMessage): "group_chat_created", "has_media_spoiler", "has_protected_content", + "is_from_offline", "invoice", "is_automatic_forward", "is_topic_message", @@ -1014,6 +1021,7 @@ def __init__( sender_boost_count: Optional[int] = None, business_connection_id: Optional[str] = None, sender_business_bot: Optional[User] = None, + is_from_offline: Optional[bool] = None, *, api_kwargs: Optional[JSONDict] = None, ): @@ -1111,6 +1119,7 @@ def __init__( self.sender_boost_count: Optional[int] = sender_boost_count self.business_connection_id: Optional[str] = business_connection_id self.sender_business_bot: Optional[User] = sender_business_bot + self.is_from_offline: Optional[bool] = is_from_offline self._effective_attachment = DEFAULT_NONE diff --git a/tests/test_message.py b/tests/test_message.py index dc2a0bfe15f..6b867de05e6 100644 --- a/tests/test_message.py +++ b/tests/test_message.py @@ -263,6 +263,7 @@ def message(bot): {"reply_to_story": Story(Chat(1, Chat.PRIVATE), 0)}, {"boost_added": ChatBoostAdded(100)}, {"sender_boost_count": 1}, + {"is_from_offline": True} {"sender_business_bot": User(1, "BusinessBot", True)}, {"business_connection_id": "123456789"}, ], @@ -332,6 +333,7 @@ def message(bot): "sender_boost_count", "sender_business_bot", "business_connection_id", + "is_from_offline", ], ) def message_params(bot, request): From 3a632486c9a380780fede02e9bd239311f67d3ee Mon Sep 17 00:00:00 2001 From: Mahdyar Hasanpour Date: Tue, 2 Apr 2024 10:24:37 +0330 Subject: [PATCH 2/3] fix: missed comma --- telegram/_message.py | 2 +- tests/test_message.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/telegram/_message.py b/telegram/_message.py index 1cbc58e0b3c..4036511e210 100644 --- a/telegram/_message.py +++ b/telegram/_message.py @@ -894,9 +894,9 @@ class Message(MaybeInaccessibleMessage): "group_chat_created", "has_media_spoiler", "has_protected_content", - "is_from_offline", "invoice", "is_automatic_forward", + "is_from_offline", "is_topic_message", "left_chat_member", "link_preview_options", diff --git a/tests/test_message.py b/tests/test_message.py index 6b867de05e6..bd7dff92d6d 100644 --- a/tests/test_message.py +++ b/tests/test_message.py @@ -263,7 +263,7 @@ def message(bot): {"reply_to_story": Story(Chat(1, Chat.PRIVATE), 0)}, {"boost_added": ChatBoostAdded(100)}, {"sender_boost_count": 1}, - {"is_from_offline": True} + {"is_from_offline": True}, {"sender_business_bot": User(1, "BusinessBot", True)}, {"business_connection_id": "123456789"}, ], From 00bd06f2b0e05ba33090d21786dd45c44bfa1ce6 Mon Sep 17 00:00:00 2001 From: Mahdyar Hasanpour Date: Tue, 2 Apr 2024 11:17:14 +0330 Subject: [PATCH 3/3] fix: ignore `is_from_offline` constant test --- tests/test_constants.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_constants.py b/tests/test_constants.py index 5055f75795c..04dc6700564 100644 --- a/tests/test_constants.py +++ b/tests/test_constants.py @@ -176,6 +176,7 @@ def is_type_attribute(name: str) -> bool: # attribute is deprecated, no need to add it to MessageType "user_shared", "via_bot", + "is_from_offline", }: return False