mirror of
https://github.com/TeamPGM/pyrogram.git
synced 2024-11-16 12:51:18 +00:00
Regression fix: limit replies to 1 (Closes #61)
This commit is contained in:
parent
0ed38518e1
commit
4cb7733821
@ -3348,7 +3348,8 @@ class Client:
|
||||
|
||||
def get_messages(self,
|
||||
chat_id: int or str,
|
||||
message_ids: list or int):
|
||||
message_ids: list or int,
|
||||
replies: int = 1):
|
||||
"""Use this method to get messages that belong to a specific chat.
|
||||
You can retrieve up to 200 messages at once.
|
||||
|
||||
@ -3362,6 +3363,9 @@ class Client:
|
||||
message_ids (``list`` | ``int``):
|
||||
A list of Message identifiers in the chat specified in *chat_id* or a single message id, as integer.
|
||||
|
||||
replies (``int``, optional):
|
||||
The number of replies to get for each message. Defaults to 1.
|
||||
|
||||
Returns:
|
||||
On success and in case *message_ids* was a list, the returned value will be a list of the requested
|
||||
:obj:`Messages <pyrogram.api.types.pyrogram.Message>` even if a list contains just one element, otherwise if
|
||||
@ -3395,12 +3399,23 @@ class Client:
|
||||
|
||||
for i in r.messages:
|
||||
if isinstance(i, types.Message):
|
||||
parser = message_parser.parse_message
|
||||
messages.append(
|
||||
message_parser.parse_message(
|
||||
self, i, users, chats,
|
||||
replies=replies
|
||||
)
|
||||
)
|
||||
elif isinstance(i, types.MessageService):
|
||||
parser = message_parser.parse_message_service
|
||||
messages.append(
|
||||
message_parser.parse_message_service(
|
||||
self, i, users, chats
|
||||
)
|
||||
)
|
||||
else:
|
||||
parser = message_parser.parse_message_empty
|
||||
|
||||
messages.append(parser(self, i, users, chats))
|
||||
messages.append(
|
||||
message_parser.parse_message_empty(
|
||||
self, i
|
||||
)
|
||||
)
|
||||
|
||||
return messages if is_list else messages[0]
|
||||
|
@ -480,7 +480,7 @@ def parse_message(
|
||||
)
|
||||
|
||||
if message.reply_to_msg_id and replies:
|
||||
m.reply_to_message = client.get_messages(m.chat.id, message.reply_to_msg_id)
|
||||
m.reply_to_message = client.get_messages(m.chat.id, message.reply_to_msg_id, replies=replies - 1)
|
||||
m.reply_to_message = m.reply_to_message
|
||||
|
||||
return m
|
||||
@ -588,8 +588,6 @@ def parse_message_service(
|
||||
|
||||
def parse_message_empty(
|
||||
client,
|
||||
message: types.MessageEmpty,
|
||||
users: dict,
|
||||
chats: dict
|
||||
message: types.MessageEmpty
|
||||
) -> pyrogram_types.Message:
|
||||
return pyrogram_types.Message(message_id=message.id)
|
||||
|
Loading…
Reference in New Issue
Block a user