Skip to content

Commit 0595b32

Browse files
committed
Add is_automatic_forward to Message (#54)
Reference: https://t.me/pyrogramchat/620063
1 parent 7097e0d commit 0595b32

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

docs/source/releases/changes-in-this-fork.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ If you found any issue or have any suggestions, feel free to make `an issue <htt
1414
| Scheme layer used: 184 |
1515
+------------------------+
1616

17+
- Added the ``is_automatic_forward`` to the :obj:`~pyrogram.types.Message`.
1718
- Added the parameters ``offset_id`` to the :meth:`~pyrogram.Client.search_messages` and the parameters ``min_date``, ``max_date``, ``min_id``, ``max_id``, ``saved_messages_topic_id`` to the :meth:`~pyrogram.Client.search_messages_count`.
1819
- Dynamic session ReStart + restart optimizations (`#56 <https://github.com/TelegramPlayGround/pyrogram/pull/56>`__)
1920
- Added the :meth:`~pyrogram.Client.delete_account`, :meth:`~pyrogram.Client.transfer_chat_ownership`, :meth:`~pyrogram.Client.update_status` (`#49 <https://github.com/TelegramPlayGround/pyrogram/pull/49>`__, `#51 <https://github.com/TelegramPlayGround/pyrogram/pull/51>`__)

pyrogram/types/messages_and_media/message.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,8 +418,7 @@ def __init__(
418418
chat: "types.Chat" = None,
419419
forward_origin: "types.MessageOrigin" = None,
420420
is_topic_message: bool = None,
421-
422-
421+
is_automatic_forward: bool = None,
423422
reply_to_message_id: int = None,
424423
reply_to_message: "Message" = None,
425424
external_reply: "types.ExternalReplyInfo" = None,
@@ -597,6 +596,7 @@ def __init__(
597596
self.effect_id = effect_id
598597
self.external_reply = external_reply
599598
self.is_topic_message = is_topic_message
599+
self.is_automatic_forward = is_automatic_forward
600600
self.sender_boost_count = sender_boost_count
601601
self.boost_added = boost_added
602602
self.quote = quote
@@ -1266,6 +1266,20 @@ async def _parse(
12661266

12671267
parsed_message.is_from_offline = getattr(message, "offline", None)
12681268

1269+
is_automatic_forward = None
1270+
if (
1271+
forward_header and
1272+
forward_header.saved_from_peer and
1273+
forward_header.saved_from_msg_id
1274+
):
1275+
saved_from_peer_id = utils.get_raw_peer_id(forward_header.saved_from_peer)
1276+
saved_from_peer_chat = chats.get(saved_from_peer_id)
1277+
if (
1278+
isinstance(saved_from_peer_chat, raw.types.Channel) and
1279+
not saved_from_peer_chat.megagroup
1280+
):
1281+
parsed_message.is_automatic_forward = True
1282+
12691283
if getattr(message, "reply_to", None):
12701284
parsed_message.reply_to_message_id = None
12711285
parsed_message.message_thread_id = None

0 commit comments

Comments
 (0)