From b06422078edad29d34406e1920d11aab212fdee3 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 3229cf14..09706723 100644 --- a/pyrogram/enums/message_service_type.py +++ b/pyrogram/enums/message_service_type.py @@ -60,6 +60,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 a4bbed99..f5163efe 100644 --- a/pyrogram/types/messages_and_media/message.py +++ b/pyrogram/types/messages_and_media/message.py @@ -293,6 +293,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 @@ -409,6 +415,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, @@ -497,6 +505,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 @@ -557,6 +567,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 @@ -605,6 +617,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 @@ -664,6 +686,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,