From 6b45a89f2b4814ed1555637a5a2cc37d6547cf62 Mon Sep 17 00:00:00 2001 From: wulan17 Date: Thu, 3 Aug 2023 14:00:06 +0700 Subject: [PATCH] Pyrofork: Add channel_shared and user_shared service message types Signed-off-by: wulan17 --- pyrogram/enums/message_service_type.py | 6 +++++ pyrogram/types/messages_and_media/message.py | 24 ++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/pyrogram/enums/message_service_type.py b/pyrogram/enums/message_service_type.py index 2b75ad58..5a63ecc6 100644 --- a/pyrogram/enums/message_service_type.py +++ b/pyrogram/enums/message_service_type.py @@ -61,6 +61,12 @@ class MessageServiceType(AutoName): GAME_HIGH_SCORE = auto() "Game high score" + ChannelShared = auto() + "a shared chat/channel" + + UserShared = auto() + "a shared user" + FORUM_TOPIC_CREATED = auto() "a new forum topic created in the chat" diff --git a/pyrogram/types/messages_and_media/message.py b/pyrogram/types/messages_and_media/message.py index 1a796b2d..98d654cd 100644 --- a/pyrogram/types/messages_and_media/message.py +++ b/pyrogram/types/messages_and_media/message.py @@ -294,6 +294,12 @@ class Message(Object, Update): E.g.: "/start 1 2 3" would produce ["start", "1", "2", "3"]. Only applicable when using :obj:`~pyrogram.filters.command`. + channel_shared (``int``, *optional*): + Service message: chat/channel shared + + user_shared (``int``, *optional*): + Service message: user shared + forum_topic_created (:obj:`~pyrogram.types.ForumTopicCreated`, *optional*): Service message: forum topic created @@ -410,6 +416,8 @@ class Message(Object, Update): outgoing: bool = None, matches: List[Match] = None, command: List[str] = None, + channel_shared: int = None, + user_shared: int = None, forum_topic_created: "types.ForumTopicCreated" = None, forum_topic_closed: "types.ForumTopicClosed" = None, forum_topic_reopened: "types.ForumTopicReopened" = None, @@ -498,6 +506,8 @@ class Message(Object, Update): self.matches = matches self.command = command self.reply_markup = reply_markup + self.channel_shared = channel_shared + self.user_shared = user_shared self.forum_topic_created = forum_topic_created self.forum_topic_closed = forum_topic_closed self.forum_topic_reopened = forum_topic_reopened @@ -558,6 +568,8 @@ class Message(Object, Update): group_chat_created = None channel_chat_created = None new_chat_photo = None + channel_shared = None + user_shared = None is_topic_message = None forum_topic_created = None forum_topic_closed = None @@ -606,6 +618,16 @@ class Message(Object, Update): elif isinstance(action, raw.types.MessageActionChatEditPhoto): new_chat_photo = types.Photo._parse(client, action.photo) service_type = enums.MessageServiceType.NEW_CHAT_PHOTO + elif isinstance(action, raw.types.MessageActionRequestedPeer): + if isinstance(action.peer, raw.types.PeerChannel): + channel_shared = int(f"-100{action.peer.channel_id}") + service_type = enums.MessageServiceType.ChannelShared + elif isinstance(action.peer, raw.types.PeerChat): + channel_shared = int(f"-100{action.peer.chat_id}") + service_type = enums.MessageServiceType.ChannelShared + elif isinstance(action.peer, raw.types.PeerUser): + user_shared = action.peer.user_id + service_type = enums.MessageServiceType.UserShared elif isinstance(action, raw.types.MessageActionTopicCreate): forum_topic_created = types.ForumTopicCreated._parse(action) service_type = enums.MessageServiceType.FORUM_TOPIC_CREATED @@ -665,6 +687,8 @@ class Message(Object, Update): migrate_from_chat_id=-migrate_from_chat_id if migrate_from_chat_id else None, group_chat_created=group_chat_created, channel_chat_created=channel_chat_created, + channel_shared=channel_shared, + user_shared=user_shared, is_topic_message=is_topic_message, forum_topic_created=forum_topic_created, forum_topic_closed=forum_topic_closed,