From 91beb214e9cd3ff4cf71425f245b3fd327536bbb Mon Sep 17 00:00:00 2001 From: Furoin Date: Tue, 6 Nov 2018 17:11:35 +0300 Subject: [PATCH 1/5] added message.mentioned --- pyrogram/client/ext/utils.py | 3 +++ pyrogram/client/types/messages_and_media/message.py | 2 ++ 2 files changed, 5 insertions(+) diff --git a/pyrogram/client/ext/utils.py b/pyrogram/client/ext/utils.py index bc908165..0d0c5abf 100644 --- a/pyrogram/client/ext/utils.py +++ b/pyrogram/client/ext/utils.py @@ -591,6 +591,8 @@ def parse_messages( else: reply_markup = None + mentioned = message.mentioned + m = pyrogram_types.Message( message_id=message.id, date=message.date, @@ -606,6 +608,7 @@ def parse_messages( forward_from_message_id=forward_from_message_id, forward_signature=forward_signature, forward_date=forward_date, + mentioned=mentioned, edit_date=message.edit_date, media_group_id=message.grouped_id, photo=photo, diff --git a/pyrogram/client/types/messages_and_media/message.py b/pyrogram/client/types/messages_and_media/message.py index 86bb57bc..59776859 100644 --- a/pyrogram/client/types/messages_and_media/message.py +++ b/pyrogram/client/types/messages_and_media/message.py @@ -206,6 +206,7 @@ class Message(Object): forward_signature: str = None, forward_date: int = None, reply_to_message=None, + mentioned=None, edit_date: int = None, media_group_id: str = None, author_signature: str = None, @@ -253,6 +254,7 @@ class Message(Object): self.forward_signature = forward_signature # flags.4?string self.forward_date = forward_date # flags.5?int self.reply_to_message = reply_to_message # flags.6?Message + self.mentioned = mentioned self.edit_date = edit_date # flags.7?int self.media_group_id = media_group_id # flags.8?string self.author_signature = author_signature # flags.9?string From 2d0ffcb0f48117af882213da8f056056f2cfa59b Mon Sep 17 00:00:00 2001 From: Furoin Date: Tue, 6 Nov 2018 17:13:37 +0300 Subject: [PATCH 2/5] added Filters.mentioned --- pyrogram/client/filters/filters.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pyrogram/client/filters/filters.py b/pyrogram/client/filters/filters.py index aeb730a7..6b9e9fd2 100644 --- a/pyrogram/client/filters/filters.py +++ b/pyrogram/client/filters/filters.py @@ -168,6 +168,8 @@ class Filters: dan = create("Dan", lambda _, m: bool(m.from_user and m.from_user.id == 23122162)) + mentioned = create("Mentioned", lambda _, m: bool(m.mentioned)) + @staticmethod def command(command: str or list, prefix: str or list = "/", From 5da5cabf4ca708f5aeb067f76f9528ff6acc3131 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Tue, 6 Nov 2018 17:31:04 +0100 Subject: [PATCH 3/5] Remove useless variable --- pyrogram/client/ext/utils.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pyrogram/client/ext/utils.py b/pyrogram/client/ext/utils.py index 0d0c5abf..6fc2552a 100644 --- a/pyrogram/client/ext/utils.py +++ b/pyrogram/client/ext/utils.py @@ -591,8 +591,6 @@ def parse_messages( else: reply_markup = None - mentioned = message.mentioned - m = pyrogram_types.Message( message_id=message.id, date=message.date, @@ -608,7 +606,7 @@ def parse_messages( forward_from_message_id=forward_from_message_id, forward_signature=forward_signature, forward_date=forward_date, - mentioned=mentioned, + mentioned=message.mentioned, edit_date=message.edit_date, media_group_id=message.grouped_id, photo=photo, From 0943761a911ae2a0f29127f1b29860ff8b308ddd Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Tue, 6 Nov 2018 17:32:46 +0100 Subject: [PATCH 4/5] Update filters.py --- pyrogram/client/filters/filters.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pyrogram/client/filters/filters.py b/pyrogram/client/filters/filters.py index 6b9e9fd2..48f0965d 100644 --- a/pyrogram/client/filters/filters.py +++ b/pyrogram/client/filters/filters.py @@ -169,6 +169,7 @@ class Filters: dan = create("Dan", lambda _, m: bool(m.from_user and m.from_user.id == 23122162)) mentioned = create("Mentioned", lambda _, m: bool(m.mentioned)) + """Filter messages containing mentions""" @staticmethod def command(command: str or list, From 5571888143dc310168b3383a8718209510f103e0 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Tue, 6 Nov 2018 17:37:32 +0100 Subject: [PATCH 5/5] Add mentioned docstrings --- pyrogram/client/types/messages_and_media/message.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pyrogram/client/types/messages_and_media/message.py b/pyrogram/client/types/messages_and_media/message.py index 59776859..d224a9c6 100644 --- a/pyrogram/client/types/messages_and_media/message.py +++ b/pyrogram/client/types/messages_and_media/message.py @@ -55,6 +55,9 @@ class Message(Object): For replies, the original message. Note that the Message object in this field will not contain further reply_to_message fields even if it itself is a reply. + mentioned (``bool``, *optional*): + The message contains a mention. + edit_date (``int``, *optional*): Date the message was last edited in Unix time.