mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-31 06:16:06 +00:00
Fix dialogs after L100 update
This commit is contained in:
@@ -313,7 +313,7 @@ class Client(Methods, BaseClient):
|
||||
self.get_initial_dialogs()
|
||||
self.get_contacts()
|
||||
else:
|
||||
self.send(functions.messages.GetPinnedDialogs())
|
||||
self.send(functions.messages.GetPinnedDialogs(folder_id=0))
|
||||
self.get_initial_dialogs_chunk()
|
||||
else:
|
||||
self.send(functions.updates.GetState())
|
||||
@@ -1325,7 +1325,7 @@ class Client(Methods, BaseClient):
|
||||
return r
|
||||
|
||||
def get_initial_dialogs(self):
|
||||
self.send(functions.messages.GetPinnedDialogs())
|
||||
self.send(functions.messages.GetPinnedDialogs(folder_id=0))
|
||||
|
||||
dialogs = self.get_initial_dialogs_chunk()
|
||||
offset_date = utils.get_offset_date(dialogs)
|
||||
|
@@ -62,7 +62,7 @@ class GetDialogs(BaseClient):
|
||||
while True:
|
||||
try:
|
||||
if pinned_only:
|
||||
r = self.send(functions.messages.GetPinnedDialogs())
|
||||
r = self.send(functions.messages.GetPinnedDialogs(folder_id=0))
|
||||
else:
|
||||
r = self.send(
|
||||
functions.messages.GetDialogs(
|
||||
|
@@ -36,7 +36,7 @@ class GetDialogsCount(BaseClient):
|
||||
"""
|
||||
|
||||
if pinned_only:
|
||||
return len(self.send(functions.messages.GetPinnedDialogs()).dialogs)
|
||||
return len(self.send(functions.messages.GetPinnedDialogs(folder_id=0)).dialogs)
|
||||
else:
|
||||
r = self.send(
|
||||
functions.messages.GetDialogs(
|
||||
|
@@ -26,7 +26,7 @@ class IterDialogs(BaseClient):
|
||||
def iter_dialogs(
|
||||
self,
|
||||
offset_date: int = 0,
|
||||
limit: int = 0
|
||||
limit: int = None
|
||||
) -> Generator["pyrogram.Dialog", None, None]:
|
||||
"""Iterate through a user's dialogs sequentially.
|
||||
|
||||
|
@@ -69,7 +69,7 @@ class Dialog(PyrogramType):
|
||||
self.is_pinned = is_pinned
|
||||
|
||||
@staticmethod
|
||||
def _parse(client, dialog, messages, users, chats) -> "Dialog":
|
||||
def _parse(client, dialog: types.Dialog, messages, users, chats) -> "Dialog":
|
||||
chat_id = dialog.peer
|
||||
|
||||
if isinstance(chat_id, types.PeerUser):
|
||||
|
@@ -51,7 +51,7 @@ class Dialogs(PyrogramType):
|
||||
self.dialogs = dialogs
|
||||
|
||||
@staticmethod
|
||||
def _parse(client, dialogs) -> "Dialogs":
|
||||
def _parse(client, dialogs: types.messages.Dialogs) -> "Dialogs":
|
||||
users = {i.id: i for i in dialogs.users}
|
||||
chats = {i.id: i for i in dialogs.chats}
|
||||
|
||||
@@ -72,8 +72,16 @@ class Dialogs(PyrogramType):
|
||||
|
||||
messages[chat_id] = Message._parse(client, message, users, chats)
|
||||
|
||||
parsed_dialogs = []
|
||||
|
||||
for dialog in dialogs.dialogs:
|
||||
if not isinstance(dialog, types.Dialog):
|
||||
continue
|
||||
|
||||
parsed_dialogs.append(Dialog._parse(client, dialog, messages, users, chats))
|
||||
|
||||
return Dialogs(
|
||||
total_count=getattr(dialogs, "count", len(dialogs.dialogs)),
|
||||
dialogs=[Dialog._parse(client, dialog, messages, users, chats) for dialog in dialogs.dialogs],
|
||||
dialogs=parsed_dialogs,
|
||||
client=client
|
||||
)
|
||||
|
Reference in New Issue
Block a user