Add missing attributes to Dialog class and get_dialogs method

This commit is contained in:
KurimuzonAkuma 2024-08-05 16:15:31 +03:00
parent 99efba3c5a
commit 7232e2d751
2 changed files with 37 additions and 3 deletions

View File

@ -25,7 +25,9 @@ from pyrogram import types, raw, utils
class GetDialogs:
async def get_dialogs(
self: "pyrogram.Client",
limit: int = 0
limit: int = 0,
exclude_pinned: bool = None,
folder_id: bool = None
) -> AsyncGenerator["types.Dialog", None]:
"""Get a user's dialogs sequentially.
@ -36,6 +38,12 @@ class GetDialogs:
Limits the number of dialogs to be retrieved.
By default, no limit is applied and all dialogs are returned.
exclude_pinned (``bool``, *optional*):
Exclude pinned dialogs.
folder_id (``int``, *optional*):
Unique identifier (int) of the target folder.
Returns:
``Generator``: A generator yielding :obj:`~pyrogram.types.Dialog` objects.
@ -61,7 +69,9 @@ class GetDialogs:
offset_id=offset_id,
offset_peer=offset_peer,
limit=limit,
hash=0
hash=0,
exclude_pinned=exclude_pinned,
folder_id=folder_id
),
sleep_threshold=60
)

View File

@ -39,11 +39,23 @@ class Dialog(Object):
unread_mentions_count (``int``):
Amount of unread messages containing a mention in this dialog.
unread_reactions_count (``int``):
Amount of unread messages containing a reaction in this dialog.
unread_mark (``bool``):
True, if the dialog has the unread mark set.
is_pinned (``bool``):
True, if the dialog is pinned.
folder_id (``int``, *optional*):
Unique identifier (int) of the folder.
ttl_period (``int``, *optional*)
Time-to-live of all messages sent in this dialog (in seconds).
raw (:obj:`~pyrogram.raw.types.Dialog`, *optional*):
The raw object, as received from the Telegram API.
"""
def __init__(
@ -54,8 +66,12 @@ class Dialog(Object):
top_message: "types.Message",
unread_messages_count: int,
unread_mentions_count: int,
unread_reactions_count: int,
unread_mark: bool,
is_pinned: bool
is_pinned: bool,
folder_id: int = None,
ttl_period: int = None,
raw: "raw.types.Dialog" = None
):
super().__init__(client)
@ -63,8 +79,12 @@ class Dialog(Object):
self.top_message = top_message
self.unread_messages_count = unread_messages_count
self.unread_mentions_count = unread_mentions_count
self.unread_reactions_count = unread_reactions_count
self.unread_mark = unread_mark
self.is_pinned = is_pinned
self.folder_id = folder_id
self.ttl_period = ttl_period
self.raw = raw
@staticmethod
def _parse(client, dialog: "raw.types.Dialog", messages, users, chats) -> "Dialog":
@ -73,7 +93,11 @@ class Dialog(Object):
top_message=messages.get(utils.get_peer_id(dialog.peer)),
unread_messages_count=dialog.unread_count,
unread_mentions_count=dialog.unread_mentions_count,
unread_reactions_count=dialog.unread_reactions_count,
unread_mark=dialog.unread_mark,
is_pinned=dialog.pinned,
folder_id=getattr(dialog, "folder_id", None),
ttl_period=getattr(dialog, "ttl_period", None),
raw=dialog,
client=client
)