From af4cb18e30326f856a612544f41c296e34bb3d0b Mon Sep 17 00:00:00 2001 From: KurimuzonAkuma Date: Wed, 29 Nov 2023 16:34:23 +0300 Subject: [PATCH] Add requested_chat to service messages --- pyrogram/enums/message_service_type.py | 3 +++ pyrogram/types/messages_and_media/message.py | 17 +++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/pyrogram/enums/message_service_type.py b/pyrogram/enums/message_service_type.py index 303f3101..6914e79a 100644 --- a/pyrogram/enums/message_service_type.py +++ b/pyrogram/enums/message_service_type.py @@ -98,3 +98,6 @@ class MessageServiceType(AutoName): WEB_APP_DATA = auto() "Web app data" + + REQUESTED_CHAT = auto() + "Requested chat" diff --git a/pyrogram/types/messages_and_media/message.py b/pyrogram/types/messages_and_media/message.py index ca768311..0dad0b25 100644 --- a/pyrogram/types/messages_and_media/message.py +++ b/pyrogram/types/messages_and_media/message.py @@ -352,6 +352,9 @@ class Message(Object, Update): gift_code (:obj:`~pyrogram.types.GiftCode`, *optional*): Service message: gift code information. + requested_chat (:obj:`~pyrogram.types.Chat`, *optional*): + Service message: requested chat information. + reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardRemove` | :obj:`~pyrogram.types.ForceReply`, *optional*): Additional interface options. An object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user. @@ -454,6 +457,7 @@ class Message(Object, Update): video_chat_members_invited: "types.VideoChatMembersInvited" = None, web_app_data: "types.WebAppData" = None, gift_code: "types.GiftCode" = None, + requested_chat: "types.Chat" = None, giveaway_launched: bool = None, reply_markup: Union[ "types.InlineKeyboardMarkup", @@ -551,6 +555,7 @@ class Message(Object, Update): self.video_chat_members_invited = video_chat_members_invited self.web_app_data = web_app_data self.gift_code = gift_code + self.requested_chat = requested_chat self.giveaway_launched = giveaway_launched self.reactions = reactions @@ -614,6 +619,7 @@ class Message(Object, Update): web_app_data = None gift_code = None giveaway_launched = None + requested_chat = None service_type = None @@ -692,7 +698,17 @@ class Message(Object, Update): elif isinstance(action, raw.types.MessageActionGiftCode): gift_code = types.GiftCode._parse(client, action, chats) service_type = enums.MessageServiceType.GIFT_CODE + elif isinstance(action, raw.types.MessageActionRequestedPeer): + chat_id = utils.get_raw_peer_id(message.action.peer) + if isinstance(message.peer_id, raw.types.PeerUser): + requested_chat = types.Chat._parse_user_chat(client, users[chat_id]) + + if isinstance(message.peer_id, raw.types.PeerChat): + requested_chat = types.Chat._parse_chat_chat(client, chats[chat_id]) + + requested_chat = types.Chat._parse_channel_chat(client, chats[chat_id]) + service_type = enums.MessageServiceType.REQUESTED_CHAT from_user = types.User._parse(client, users.get(user_id, None)) sender_chat = types.Chat._parse(client, message, users, chats, is_chat=False) if not from_user else None @@ -728,6 +744,7 @@ class Message(Object, Update): web_app_data=web_app_data, giveaway_launched=giveaway_launched, gift_code=gift_code, + requested_chat=requested_chat, client=client # TODO: supergroup_chat_created )