mirror of
https://github.com/pyrogram/pyrogram
synced 2025-09-02 15:25:41 +00:00
Merge branch 'develop' into asyncio
# Conflicts: # pyrogram/__init__.py # pyrogram/client/methods/chats/get_dialogs.py # pyrogram/client/methods/messages/get_history.py
This commit is contained in:
@@ -31,7 +31,7 @@ __copyright__ = "Copyright (C) 2017-2018 Dan Tès <https://github.com/delivrance
|
||||
"e" if sys.getfilesystemencoding() != "utf-8" else "\xe8"
|
||||
)
|
||||
__license__ = "GNU Lesser General Public License v3 or later (LGPLv3+)"
|
||||
__version__ = "0.9.4.asyncio"
|
||||
__version__ = "0.10.0.asyncio"
|
||||
|
||||
from .api.errors import Error
|
||||
from .client.types import (
|
||||
|
@@ -23,7 +23,7 @@ from ...ext import BaseClient
|
||||
|
||||
class GetDialogs(BaseClient):
|
||||
async def get_dialogs(self,
|
||||
offset_dialog: "pyrogram.Dialog" = None,
|
||||
offset_date: int = 0,
|
||||
limit: int = 100,
|
||||
pinned_only: bool = False) -> "pyrogram.Dialogs":
|
||||
"""Use this method to get the user's dialogs
|
||||
@@ -31,13 +31,13 @@ class GetDialogs(BaseClient):
|
||||
You can get up to 100 dialogs at once.
|
||||
|
||||
Args:
|
||||
offset_dialog (:obj:`Dialog`):
|
||||
Sequential Dialog of the first dialog to be returned.
|
||||
Defaults to None (start from the beginning).
|
||||
offset_date (``int``):
|
||||
The offset date in Unix time taken from the top message of a :obj:`Dialog`.
|
||||
Defaults to 0. Valid for non-pinned dialogs only.
|
||||
|
||||
limit (``str``, *optional*):
|
||||
Limits the number of dialogs to be retrieved.
|
||||
Defaults to 100.
|
||||
Defaults to 100. Valid for non-pinned dialogs only.
|
||||
|
||||
pinned_only (``bool``, *optional*):
|
||||
Pass True if you want to get only pinned dialogs.
|
||||
@@ -55,7 +55,7 @@ class GetDialogs(BaseClient):
|
||||
else:
|
||||
r = await self.send(
|
||||
functions.messages.GetDialogs(
|
||||
offset_date=offset_dialog.top_message.date if offset_dialog else 0,
|
||||
offset_date=offset_date,
|
||||
offset_id=0,
|
||||
offset_peer=types.InputPeerEmpty(),
|
||||
limit=limit,
|
||||
|
@@ -26,10 +26,11 @@ from ...ext import BaseClient
|
||||
class GetHistory(BaseClient):
|
||||
async 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):
|
||||
offset_date: int = 0,
|
||||
reversed: bool = False):
|
||||
"""Use this method to retrieve the history of a chat.
|
||||
|
||||
You can get up to 100 messages at once.
|
||||
@@ -40,20 +41,23 @@ 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.
|
||||
|
||||
@@ -61,14 +65,14 @@ class GetHistory(BaseClient):
|
||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||
"""
|
||||
|
||||
return await pyrogram.Messages._parse(
|
||||
messages = await pyrogram.Messages._parse(
|
||||
self,
|
||||
await self.send(
|
||||
functions.messages.GetHistory(
|
||||
peer=await 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,
|
||||
@@ -76,3 +80,8 @@ class GetHistory(BaseClient):
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
if reversed:
|
||||
messages.messages.reverse()
|
||||
|
||||
return messages
|
||||
|
Reference in New Issue
Block a user