2023-01-27 12:36:41 +00:00
|
|
|
import pyrogram
|
|
|
|
|
|
|
|
|
|
|
|
async def fix_topic(
|
2023-07-03 14:39:52 +00:00
|
|
|
client: "pyrogram.Client",
|
|
|
|
message: pyrogram.raw.base.Message,
|
|
|
|
users: dict,
|
|
|
|
chats: dict,
|
|
|
|
is_scheduled: bool = False,
|
|
|
|
replies: int = 1,
|
2023-01-27 12:36:41 +00:00
|
|
|
):
|
2023-07-03 14:39:52 +00:00
|
|
|
parsed = await pyrogram.types.Message.old_parse(
|
|
|
|
client, message, users, chats, is_scheduled, replies
|
|
|
|
) # noqa
|
2023-01-27 12:36:41 +00:00
|
|
|
if isinstance(message, pyrogram.raw.types.Message):
|
|
|
|
parsed.forum_topic = getattr(message.reply_to, "forum_topic", None)
|
|
|
|
if (
|
2023-07-03 14:39:52 +00:00
|
|
|
message.reply_to
|
|
|
|
and parsed.forum_topic
|
|
|
|
and not message.reply_to.reply_to_top_id
|
2023-01-27 12:36:41 +00:00
|
|
|
):
|
|
|
|
parsed.reply_to_top_message_id = parsed.reply_to_message_id
|
|
|
|
parsed.reply_to_message_id = None
|
|
|
|
parsed.reply_to_message = None
|
|
|
|
return parsed
|