2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-08-28 21:07:59 +00:00

Rename downwards to reversed

This commit is contained in:
Dan 2018-12-27 23:55:56 +01:00
parent d3c87214b6
commit decaa9e7f0

View File

@ -26,13 +26,11 @@ from ...ext import BaseClient
class GetHistory(BaseClient): class GetHistory(BaseClient):
def get_history(self, def get_history(self,
chat_id: Union[int, str], chat_id: Union[int, str],
offset: int = 0,
limit: int = 100, limit: int = 100,
offset: int = 0, offset: int = 0,
offset_id: int = 0, offset_id: int = 0,
offset_date: int = 0, offset_date: int = 0,
add_offset: int = 0, reversed: bool = False):
downwards: bool = False):
"""Use this method to retrieve the history of a chat. """Use this method to retrieve the history of a chat.
You can get up to 100 messages at once. You can get up to 100 messages at once.
@ -43,34 +41,38 @@ class GetHistory(BaseClient):
For your personal cloud (Saved Messages) you can simply use "me" or "self". For your personal cloud (Saved Messages) you can simply use "me" or "self".
For a contact that exists in your Telegram address book you can use his phone number (str). For a contact that exists in your Telegram address book you can use his phone number (str).
offset (``int``, *optional*)
Sequential number of the first message to be returned.
Defaults to 0 (most recent message).
limit (``int``, *optional*): limit (``int``, *optional*):
Limits the number of messages to be retrieved. Limits the number of messages to be retrieved.
By default, the first 100 messages are returned. By default, the first 100 messages are returned.
offset (``int``, *optional*)
Sequential number of the first message to be returned. Defaults to 0 (most recent message).
Negative values are also accepted and become useful in case you set offset_id or offset_date.
offset_id (``int``, *optional*): offset_id (``int``, *optional*):
Pass a message identifier as offset to retrieve only older messages starting from that message. Pass a message identifier as offset to retrieve only older messages starting from that message.
offset_date (``int``, *optional*): offset_date (``int``, *optional*):
Pass a date in Unix time as offset to retrieve only older messages starting from that date. Pass a date in Unix time as offset to retrieve only older messages starting from that date.
reversed (``bool``, *optional*):
Pass True to retrieve the messages in reversed order (from older to most recent).
Returns: Returns:
On success, a :obj:`Messages <pyrogram.Messages>` object is returned. On success, a :obj:`Messages <pyrogram.Messages>` object is returned.
Raises: Raises:
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error. :class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
""" """
return pyrogram.Messages._parse(
messages = pyrogram.Messages._parse(
self, self,
self.send( self.send(
functions.messages.GetHistory( functions.messages.GetHistory(
peer=self.resolve_peer(chat_id), peer=self.resolve_peer(chat_id),
offset_id=offset_id, offset_id=offset_id,
offset_date=offset_date, offset_date=offset_date,
add_offset=offset, add_offset=offset - (limit if reversed else 0),
limit=limit, limit=limit,
max_id=0, max_id=0,
min_id=0, min_id=0,
@ -78,3 +80,8 @@ class GetHistory(BaseClient):
) )
) )
) )
if reversed:
messages.messages.reverse()
return messages