Add requested_chat to service messages

This commit is contained in:
KurimuzonAkuma 2023-11-29 16:34:23 +03:00
parent 9f10b554f1
commit af4cb18e30
2 changed files with 20 additions and 0 deletions

View File

@ -98,3 +98,6 @@ class MessageServiceType(AutoName):
WEB_APP_DATA = auto()
"Web app data"
REQUESTED_CHAT = auto()
"Requested chat"

View File

@ -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
)