Skip to content

Commit ce0173e

Browse files
committed
Add support for hidden users in forwarded messages
1 parent eb2799e commit ce0173e

1 file changed

Lines changed: 16 additions & 7 deletions

File tree

  • pyrogram/client/types/messages_and_media

pyrogram/client/types/messages_and_media/message.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ class Message(PyrogramType, Update):
7979
forward_from (:obj:`User <pyrogram.User>`, *optional*):
8080
For forwarded messages, sender of the original message.
8181
82+
forward_from_name (``str``, *optional*):
83+
For messages forwarded from users who have hidden their accounts, name of the user.
84+
8285
forward_from_chat (:obj:`Chat <pyrogram.Chat>`, *optional*):
8386
For messages forwarded from channels, information about the original channel.
8487
@@ -264,12 +267,12 @@ class Message(PyrogramType, Update):
264267
# TODO: Add game missing field. Also invoice, successful_payment, connected_website
265268

266269
__slots__ = [
267-
"message_id", "date", "chat", "from_user", "forward_from", "forward_from_chat", "forward_from_message_id",
268-
"forward_signature", "forward_date", "reply_to_message", "mentioned", "empty", "service", "media", "edit_date",
269-
"media_group_id", "author_signature", "text", "entities", "caption_entities", "audio", "document", "photo",
270-
"sticker", "animation", "game", "video", "voice", "video_note", "caption", "contact", "location", "venue",
271-
"web_page", "poll", "new_chat_members", "left_chat_member", "new_chat_title", "new_chat_photo",
272-
"delete_chat_photo", "group_chat_created", "supergroup_chat_created", "channel_chat_created",
270+
"message_id", "date", "chat", "from_user", "forward_from", "forward_from_name", "forward_from_chat",
271+
"forward_from_message_id", "forward_signature", "forward_date", "reply_to_message", "mentioned", "empty",
272+
"service", "media", "edit_date", "media_group_id", "author_signature", "text", "entities", "caption_entities",
273+
"audio", "document", "photo", "sticker", "animation", "game", "video", "voice", "video_note", "caption",
274+
"contact", "location", "venue", "web_page", "poll", "new_chat_members", "left_chat_member", "new_chat_title",
275+
"new_chat_photo", "delete_chat_photo", "group_chat_created", "supergroup_chat_created", "channel_chat_created",
273276
"migrate_to_chat_id", "migrate_from_chat_id", "pinned_message", "game_high_score", "views", "via_bot",
274277
"outgoing", "matches", "command", "reply_markup"
275278
]
@@ -283,6 +286,7 @@ def __init__(
283286
chat: Chat = None,
284287
from_user: User = None,
285288
forward_from: User = None,
289+
forward_from_name: str = None,
286290
forward_from_chat: Chat = None,
287291
forward_from_message_id: int = None,
288292
forward_signature: str = None,
@@ -344,6 +348,7 @@ def __init__(
344348
self.chat = chat
345349
self.from_user = from_user
346350
self.forward_from = forward_from
351+
self.forward_from_name = forward_from_name
347352
self.forward_from_chat = forward_from_chat
348353
self.forward_from_message_id = forward_from_message_id
349354
self.forward_signature = forward_signature
@@ -482,18 +487,21 @@ def _parse(client, message: types.Message or types.MessageService or types.Messa
482487
entities = list(filter(lambda x: x is not None, entities))
483488

484489
forward_from = None
490+
forward_from_name = None
485491
forward_from_chat = None
486492
forward_from_message_id = None
487493
forward_signature = None
488494
forward_date = None
489495

490-
forward_header = message.fwd_from
496+
forward_header = message.fwd_from # type: types.MessageFwdHeader
491497

492498
if forward_header:
493499
forward_date = forward_header.date
494500

495501
if forward_header.from_id:
496502
forward_from = User._parse(client, users[forward_header.from_id])
503+
elif forward_header.from_name:
504+
forward_from_name = forward_header.from_name
497505
else:
498506
forward_from_chat = Chat._parse_channel_chat(client, chats[forward_header.channel_id])
499507
forward_from_message_id = forward_header.channel_post
@@ -599,6 +607,7 @@ def _parse(client, message: types.Message or types.MessageService or types.Messa
599607
caption_entities=entities or None if media is not None else None,
600608
author_signature=message.post_author,
601609
forward_from=forward_from,
610+
forward_from_name=forward_from_name,
602611
forward_from_chat=forward_from_chat,
603612
forward_from_message_id=forward_from_message_id,
604613
forward_signature=forward_signature,

0 commit comments

Comments
 (0)