From 9211a7d843320d8cace0a253cbc6457a67a293a5 Mon Sep 17 00:00:00 2001 From: xtaodada Date: Fri, 27 Jan 2023 00:24:14 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=91=EF=B8=8F=20fix:=20message=20parse?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pyromod/listen/listen.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/pyromod/listen/listen.py b/pyromod/listen/listen.py index c63caca..8abef9a 100644 --- a/pyromod/listen/listen.py +++ b/pyromod/listen/listen.py @@ -379,13 +379,17 @@ class Message(pyrogram.types.Message): replies: int = 1 ): parsed = await pyrogram.types.Message.old_parse(client, message, users, chats, is_scheduled, replies) # noqa - # forum_topic - parsed.forum_topic = getattr(message.reply_to, "forum_topic", None) - if isinstance(message, pyrogram.raw.types.Message) and message.reply_to \ - and parsed.forum_topic and not message.reply_to.reply_to_top_id: - parsed.reply_to_top_message_id = parsed.reply_to_message_id - parsed.reply_to_message_id = None - parsed.reply_to_message = None + # forum topic + if isinstance(message, pyrogram.raw.types.Message): + parsed.forum_topic = getattr(message.reply_to, "forum_topic", None) + if ( + message.reply_to + and parsed.forum_topic + and not message.reply_to.reply_to_top_id + ): + parsed.reply_to_top_message_id = parsed.reply_to_message_id + parsed.reply_to_message_id = None + parsed.reply_to_message = None # make message.text as message.caption parsed.text = parsed.text or parsed.caption return parsed