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:
parent
d3c87214b6
commit
decaa9e7f0
@ -26,13 +26,11 @@ from ...ext import BaseClient
|
||||
class GetHistory(BaseClient):
|
||||
def get_history(self,
|
||||
chat_id: Union[int, str],
|
||||
offset: int = 0,
|
||||
limit: int = 100,
|
||||
offset: int = 0,
|
||||
offset_id: int = 0,
|
||||
offset_date: int = 0,
|
||||
add_offset: int = 0,
|
||||
downwards: bool = False):
|
||||
reversed: bool = False):
|
||||
"""Use this method to retrieve the history of a chat.
|
||||
|
||||
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 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*):
|
||||
Limits the number of messages to be retrieved.
|
||||
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*):
|
||||
Pass a message identifier as offset to retrieve only older messages starting from that message.
|
||||
|
||||
offset_date (``int``, *optional*):
|
||||
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:
|
||||
On success, a :obj:`Messages <pyrogram.Messages>` object is returned.
|
||||
|
||||
Raises:
|
||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||
"""
|
||||
return pyrogram.Messages._parse(
|
||||
|
||||
messages = pyrogram.Messages._parse(
|
||||
self,
|
||||
self.send(
|
||||
functions.messages.GetHistory(
|
||||
peer=self.resolve_peer(chat_id),
|
||||
offset_id=offset_id,
|
||||
offset_date=offset_date,
|
||||
add_offset=offset,
|
||||
add_offset=offset - (limit if reversed else 0),
|
||||
limit=limit,
|
||||
max_id=0,
|
||||
min_id=0,
|
||||
@ -78,3 +80,8 @@ class GetHistory(BaseClient):
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
if reversed:
|
||||
messages.messages.reverse()
|
||||
|
||||
return messages
|
||||
|
Loading…
x
Reference in New Issue
Block a user