mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-28 21:07:59 +00:00
Add support for hidden users in forwarded messages
This commit is contained in:
parent
eb2799ed45
commit
ce0173e7cd
@ -79,6 +79,9 @@ class Message(PyrogramType, Update):
|
|||||||
forward_from (:obj:`User <pyrogram.User>`, *optional*):
|
forward_from (:obj:`User <pyrogram.User>`, *optional*):
|
||||||
For forwarded messages, sender of the original message.
|
For forwarded messages, sender of the original message.
|
||||||
|
|
||||||
|
forward_from_name (``str``, *optional*):
|
||||||
|
For messages forwarded from users who have hidden their accounts, name of the user.
|
||||||
|
|
||||||
forward_from_chat (:obj:`Chat <pyrogram.Chat>`, *optional*):
|
forward_from_chat (:obj:`Chat <pyrogram.Chat>`, *optional*):
|
||||||
For messages forwarded from channels, information about the original channel.
|
For messages forwarded from channels, information about the original channel.
|
||||||
|
|
||||||
@ -264,12 +267,12 @@ class Message(PyrogramType, Update):
|
|||||||
# TODO: Add game missing field. Also invoice, successful_payment, connected_website
|
# TODO: Add game missing field. Also invoice, successful_payment, connected_website
|
||||||
|
|
||||||
__slots__ = [
|
__slots__ = [
|
||||||
"message_id", "date", "chat", "from_user", "forward_from", "forward_from_chat", "forward_from_message_id",
|
"message_id", "date", "chat", "from_user", "forward_from", "forward_from_name", "forward_from_chat",
|
||||||
"forward_signature", "forward_date", "reply_to_message", "mentioned", "empty", "service", "media", "edit_date",
|
"forward_from_message_id", "forward_signature", "forward_date", "reply_to_message", "mentioned", "empty",
|
||||||
"media_group_id", "author_signature", "text", "entities", "caption_entities", "audio", "document", "photo",
|
"service", "media", "edit_date", "media_group_id", "author_signature", "text", "entities", "caption_entities",
|
||||||
"sticker", "animation", "game", "video", "voice", "video_note", "caption", "contact", "location", "venue",
|
"audio", "document", "photo", "sticker", "animation", "game", "video", "voice", "video_note", "caption",
|
||||||
"web_page", "poll", "new_chat_members", "left_chat_member", "new_chat_title", "new_chat_photo",
|
"contact", "location", "venue", "web_page", "poll", "new_chat_members", "left_chat_member", "new_chat_title",
|
||||||
"delete_chat_photo", "group_chat_created", "supergroup_chat_created", "channel_chat_created",
|
"new_chat_photo", "delete_chat_photo", "group_chat_created", "supergroup_chat_created", "channel_chat_created",
|
||||||
"migrate_to_chat_id", "migrate_from_chat_id", "pinned_message", "game_high_score", "views", "via_bot",
|
"migrate_to_chat_id", "migrate_from_chat_id", "pinned_message", "game_high_score", "views", "via_bot",
|
||||||
"outgoing", "matches", "command", "reply_markup"
|
"outgoing", "matches", "command", "reply_markup"
|
||||||
]
|
]
|
||||||
@ -283,6 +286,7 @@ class Message(PyrogramType, Update):
|
|||||||
chat: Chat = None,
|
chat: Chat = None,
|
||||||
from_user: User = None,
|
from_user: User = None,
|
||||||
forward_from: User = None,
|
forward_from: User = None,
|
||||||
|
forward_from_name: str = None,
|
||||||
forward_from_chat: Chat = None,
|
forward_from_chat: Chat = None,
|
||||||
forward_from_message_id: int = None,
|
forward_from_message_id: int = None,
|
||||||
forward_signature: str = None,
|
forward_signature: str = None,
|
||||||
@ -344,6 +348,7 @@ class Message(PyrogramType, Update):
|
|||||||
self.chat = chat
|
self.chat = chat
|
||||||
self.from_user = from_user
|
self.from_user = from_user
|
||||||
self.forward_from = forward_from
|
self.forward_from = forward_from
|
||||||
|
self.forward_from_name = forward_from_name
|
||||||
self.forward_from_chat = forward_from_chat
|
self.forward_from_chat = forward_from_chat
|
||||||
self.forward_from_message_id = forward_from_message_id
|
self.forward_from_message_id = forward_from_message_id
|
||||||
self.forward_signature = forward_signature
|
self.forward_signature = forward_signature
|
||||||
@ -482,18 +487,21 @@ class Message(PyrogramType, Update):
|
|||||||
entities = list(filter(lambda x: x is not None, entities))
|
entities = list(filter(lambda x: x is not None, entities))
|
||||||
|
|
||||||
forward_from = None
|
forward_from = None
|
||||||
|
forward_from_name = None
|
||||||
forward_from_chat = None
|
forward_from_chat = None
|
||||||
forward_from_message_id = None
|
forward_from_message_id = None
|
||||||
forward_signature = None
|
forward_signature = None
|
||||||
forward_date = None
|
forward_date = None
|
||||||
|
|
||||||
forward_header = message.fwd_from
|
forward_header = message.fwd_from # type: types.MessageFwdHeader
|
||||||
|
|
||||||
if forward_header:
|
if forward_header:
|
||||||
forward_date = forward_header.date
|
forward_date = forward_header.date
|
||||||
|
|
||||||
if forward_header.from_id:
|
if forward_header.from_id:
|
||||||
forward_from = User._parse(client, users[forward_header.from_id])
|
forward_from = User._parse(client, users[forward_header.from_id])
|
||||||
|
elif forward_header.from_name:
|
||||||
|
forward_from_name = forward_header.from_name
|
||||||
else:
|
else:
|
||||||
forward_from_chat = Chat._parse_channel_chat(client, chats[forward_header.channel_id])
|
forward_from_chat = Chat._parse_channel_chat(client, chats[forward_header.channel_id])
|
||||||
forward_from_message_id = forward_header.channel_post
|
forward_from_message_id = forward_header.channel_post
|
||||||
@ -599,6 +607,7 @@ class Message(PyrogramType, Update):
|
|||||||
caption_entities=entities or None if media is not None else None,
|
caption_entities=entities or None if media is not None else None,
|
||||||
author_signature=message.post_author,
|
author_signature=message.post_author,
|
||||||
forward_from=forward_from,
|
forward_from=forward_from,
|
||||||
|
forward_from_name=forward_from_name,
|
||||||
forward_from_chat=forward_from_chat,
|
forward_from_chat=forward_from_chat,
|
||||||
forward_from_message_id=forward_from_message_id,
|
forward_from_message_id=forward_from_message_id,
|
||||||
forward_signature=forward_signature,
|
forward_signature=forward_signature,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user