mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2026-01-03 14:04:51 +00:00
pyrofork: fix MESSAGE_IDS_EMPTY error on get_scheduled_messages method
Signed-off-by: wulan17 <wulan17@komodos.id>
This commit is contained in:
parent
57feed8b45
commit
99e6005cf1
2 changed files with 67 additions and 54 deletions
|
|
@ -78,6 +78,6 @@ class GetScheduledMessages:
|
||||||
|
|
||||||
r = await self.invoke(rpc, sleep_threshold=-1)
|
r = await self.invoke(rpc, sleep_threshold=-1)
|
||||||
|
|
||||||
messages = await utils.parse_messages(self, r)
|
messages = await utils.parse_messages(self, r, is_scheduled=True)
|
||||||
|
|
||||||
return messages if is_iterable else messages[0] if messages else None
|
return messages if is_iterable else messages[0] if messages else None
|
||||||
|
|
|
||||||
|
|
@ -103,7 +103,8 @@ async def parse_messages(
|
||||||
client,
|
client,
|
||||||
messages: "raw.types.messages.Messages",
|
messages: "raw.types.messages.Messages",
|
||||||
replies: int = 1,
|
replies: int = 1,
|
||||||
business_connection_id: str = None
|
business_connection_id: str = None,
|
||||||
|
is_scheduled: bool = False
|
||||||
) -> List["types.Message"]:
|
) -> List["types.Message"]:
|
||||||
users = {i.id: i for i in messages.users}
|
users = {i.id: i for i in messages.users}
|
||||||
chats = {i.id: i for i in messages.chats}
|
chats = {i.id: i for i in messages.chats}
|
||||||
|
|
@ -120,6 +121,7 @@ async def parse_messages(
|
||||||
parsed_messages.append(await types.Message._parse(client, message, users, chats, topics, replies=0, business_connection_id=business_connection_id))
|
parsed_messages.append(await types.Message._parse(client, message, users, chats, topics, replies=0, business_connection_id=business_connection_id))
|
||||||
|
|
||||||
if replies:
|
if replies:
|
||||||
|
if not is_scheduled:
|
||||||
messages_with_replies = {
|
messages_with_replies = {
|
||||||
i.id: i.reply_to.reply_to_msg_id
|
i.id: i.reply_to.reply_to_msg_id
|
||||||
for i in messages.messages
|
for i in messages.messages
|
||||||
|
|
@ -178,6 +180,17 @@ async def parse_messages(
|
||||||
for message in parsed_messages:
|
for message in parsed_messages:
|
||||||
if message.id in reply_messages:
|
if message.id in reply_messages:
|
||||||
message.reply_to_story = reply_messages[message.id]
|
message.reply_to_story = reply_messages[message.id]
|
||||||
|
else:
|
||||||
|
for message in parsed_messages:
|
||||||
|
if (
|
||||||
|
message.reply_to_message_id
|
||||||
|
and not message.external_reply
|
||||||
|
):
|
||||||
|
message.reply_to_message = await client.get_messages(
|
||||||
|
message.chat.id,
|
||||||
|
message_ids=message.reply_to_message_id,
|
||||||
|
replies=replies - 1
|
||||||
|
)
|
||||||
|
|
||||||
return types.List(parsed_messages)
|
return types.List(parsed_messages)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue