Skip to content

Commit 6217397

Browse files
committed
1 parent 8087cbc commit 6217397

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

pyrogram/types/messages_and_media/message.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class Message(Object, Update):
6464
Unique message identifier inside this chat.
6565
6666
message_thread_id (``int``, *optional*):
67-
Unique identifier of a message thread to which the message belongs; for supergroups only
67+
Unique identifier of a message thread or forum topic to which the message belongs; for supergroups and private chats only.
6868
6969
direct_messages_topic (:obj:`~pyrogram.types.DirectMessagesTopic`, *optional*):
7070
Information about the direct messages chat topic that contains the message.
@@ -1522,28 +1522,25 @@ async def _parse(
15221522
if getattr(message, "reply_to", None):
15231523
parsed_message.reply_to_message_id = None
15241524
parsed_message.message_thread_id = None
1525+
1526+
if isinstance(message.reply_to, raw.types.MessageReplyStoryHeader):
1527+
parsed_message.reply_to_story = await types.Story._parse(client, users, chats, None, message.reply_to, None, None, None)
1528+
15251529
if isinstance(message.reply_to, raw.types.MessageReplyHeader):
15261530
parsed_message.reply_to_checklist_task_id = message.reply_to.todo_item_id
15271531
parsed_message.reply_to_message_id = message.reply_to.reply_to_msg_id
15281532
parsed_message.message_thread_id = message.reply_to.reply_to_top_id
15291533
if message.reply_to.forum_topic:
15301534
parsed_message.is_topic_message = True
1531-
if message.reply_to.reply_to_top_id:
1532-
parsed_message.message_thread_id = message.reply_to.reply_to_top_id
1533-
else:
1535+
if not message.reply_to.reply_to_top_id:
15341536
parsed_message.message_thread_id = message.reply_to.reply_to_msg_id
1535-
if not parsed_message.message_thread_id:
1536-
parsed_message.message_thread_id = 1 # https://t.me/c/1279877202/31475
15371537
parsed_message.quote = types.TextQuote._parse(
15381538
client,
15391539
chats,
15401540
users,
15411541
message.reply_to
15421542
)
15431543

1544-
if isinstance(message.reply_to, raw.types.MessageReplyStoryHeader):
1545-
parsed_message.reply_to_story = await types.Story._parse(client, users, chats, None, message.reply_to, None, None, None)
1546-
15471544
if replies:
15481545
try:
15491546
key = (parsed_message.chat.id, parsed_message.reply_to_message_id)
@@ -1596,11 +1593,16 @@ def link(self) -> str:
15961593
}
15971594
):
15981595
if self.chat.username:
1596+
if self.chat.is_forum and self.is_topic_message:
1597+
return f"https://t.me/{self.chat.username}/{self.message_thread_id}/{self.id}"
15991598
if self.chat.is_forum:
1600-
return f"https://t.me/{self.chat.username}{f'/{self.message_thread_id}' if self.message_thread_id else ''}/{self.id}"
1599+
return f"https://t.me/{self.chat.username}/1/{self.id}"
16011600
return f"https://t.me/{self.chat.username}/{self.id}"
1601+
if self.chat.is_forum and self.is_topic_message:
1602+
return f"https://t.me/c/{utils.get_channel_id(self.chat.id)}/{self.message_thread_id}/{self.id}"
1603+
# https://t.me/c/1279877202/31475
16021604
if self.chat.is_forum:
1603-
return f"https://t.me/c/{utils.get_channel_id(self.chat.id)}{f'/{self.message_thread_id}' if self.message_thread_id else ''}/{self.id}"
1605+
return f"https://t.me/{self.chat.username}/1/{self.id}"
16041606
return f"https://t.me/c/{utils.get_channel_id(self.chat.id)}/{self.id}"
16051607

16061608
@property

0 commit comments

Comments
 (0)