Skip to content

Commit c39545f

Browse files
authored
Add chat_list to the methods get_dialogs and get_dialogs_count
1 parent c7476f2 commit c39545f

3 files changed

Lines changed: 16 additions & 5 deletions

File tree

docs/source/releases/changes-in-this-fork.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ If you found any issue or have any suggestions, feel free to make `an issue <htt
1414
| Scheme layer used: 185 |
1515
+------------------------+
1616

17+
- Added the parameter ``chat_list`` to the methods :meth:`~pyrogram.Client.get_dialogs` and :meth:`~pyrogram.Client.get_dialogs_count`.
1718
- Added ``gifted_stars`` service message to the class :obj:`~pyrogram.types.Message`.
1819
- Added the fields ``have_access``, ``has_main_web_app``, ``active_user_count`` to the class :obj:`~pyrogram.types.User`, which is returned in response to :meth:`~pyrogram.Client.get_me`.
1920
- Added the parameter ``business_connection_id`` to the methods :meth:`~pyrogram.Client.pin_chat_message` and :meth:`~pyrogram.Client.unpin_chat_message`, allowing bots to manage pinned messages on behalf of a business account.

pyrogram/methods/chats/get_dialogs.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
class GetDialogs:
2626
async def get_dialogs(
2727
self: "pyrogram.Client",
28-
limit: int = 0
28+
limit: int = 0,
29+
chat_list: int = 0
2930
) -> Optional[AsyncGenerator["types.Dialog", None]]:
3031
"""Get a user's dialogs sequentially.
3132
@@ -35,6 +36,9 @@ async def get_dialogs(
3536
limit (``int``, *optional*):
3637
Limits the number of dialogs to be retrieved.
3738
By default, no limit is applied and all dialogs are returned.
39+
40+
chat_list (``int``, *optional*):
41+
Chat list in which to search messages; Only Main (0) and Archive (1) chat lists are supported. Defaults to (0) Main chat list.
3842
3943
Returns:
4044
``Generator``: A generator yielding :obj:`~pyrogram.types.Dialog` objects.
@@ -61,7 +65,8 @@ async def get_dialogs(
6165
offset_id=offset_id,
6266
offset_peer=offset_peer,
6367
limit=limit,
64-
hash=0
68+
hash=0,
69+
folder_id=chat_list
6570
),
6671
sleep_threshold=60
6772
)

pyrogram/methods/chats/get_dialogs_count.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
class GetDialogsCount:
2424
async def get_dialogs_count(
2525
self: "pyrogram.Client",
26-
pinned_only: bool = False
26+
pinned_only: bool = False,
27+
chat_list: int = 0
2728
) -> int:
2829
"""Get the total count of your dialogs.
2930
@@ -33,6 +34,9 @@ async def get_dialogs_count(
3334
pinned_only (``bool``, *optional*):
3435
Pass True if you want to count only pinned dialogs.
3536
Defaults to False.
37+
38+
chat_list (``int``, *optional*):
39+
Chat list in which to search messages; Only Main (0) and Archive (1) chat lists are supported. Defaults to (0) Main chat list.
3640
3741
Returns:
3842
``int``: On success, the dialogs count is returned.
@@ -45,15 +49,16 @@ async def get_dialogs_count(
4549
"""
4650

4751
if pinned_only:
48-
return len((await self.invoke(raw.functions.messages.GetPinnedDialogs(folder_id=0))).dialogs)
52+
return len((await self.invoke(raw.functions.messages.GetPinnedDialogs(folder_id=chat_list))).dialogs)
4953
else:
5054
r = await self.invoke(
5155
raw.functions.messages.GetDialogs(
5256
offset_date=0,
5357
offset_id=0,
5458
offset_peer=raw.types.InputPeerEmpty(),
5559
limit=1,
56-
hash=0
60+
hash=0,
61+
folder_id=chat_list
5762
)
5863
)
5964

0 commit comments

Comments
 (0)