Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix for reply_to parsing #46

Merged
merged 2 commits into from
Jul 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 22 additions & 21 deletions hydrogram/types/messages_and_media/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -990,28 +990,29 @@ async def _parse(
)

if message.reply_to:
if message.reply_to.forum_topic:
if message.reply_to.reply_to_top_id:
thread_id = message.reply_to.reply_to_top_id
parsed_message.reply_to_message_id = message.reply_to.reply_to_msg_id
else:
thread_id = message.reply_to.reply_to_msg_id
parsed_message.message_thread_id = thread_id
parsed_message.is_topic_message = True
if topics:
parsed_message.topics = types.ForumTopic._parse(topics[thread_id])
if isinstance(message.reply_to, raw.types.MessageReplyHeader):
if message.reply_to.forum_topic:
if message.reply_to.reply_to_top_id:
thread_id = message.reply_to.reply_to_top_id
parsed_message.reply_to_message_id = message.reply_to.reply_to_msg_id
else:
thread_id = message.reply_to.reply_to_msg_id
parsed_message.message_thread_id = thread_id
parsed_message.is_topic_message = True
if topics:
parsed_message.topics = types.ForumTopic._parse(topics[thread_id])
else:
try:
msg = await client.get_messages(parsed_message.chat.id, message.id)
if getattr(msg, "topics"):
parsed_message.topics = msg.topics
except Exception:
pass
else:
try:
msg = await client.get_messages(parsed_message.chat.id, message.id)
if getattr(msg, "topics"):
parsed_message.topics = msg.topics
except Exception:
pass
else:
parsed_message.reply_to_message_id = message.reply_to.reply_to_msg_id
parsed_message.reply_to_top_message_id = message.reply_to.reply_to_top_id
if isinstance(message.reply_to, raw.types.MessageReplyStoryHeader):
parsed_message.reply_to_message_id = message.reply_to.story_id
parsed_message.reply_to_message_id = message.reply_to.reply_to_msg_id
parsed_message.reply_to_top_message_id = message.reply_to.reply_to_top_id
if isinstance(message.reply_to, raw.types.MessageReplyStoryHeader):
parsed_message.reply_to_message_id = message.reply_to.story_id

if replies:
try:
Expand Down
Loading