2
0
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:
Dan
2019-05-29 09:37:50 +02:00
parent 4eaa891836
commit c2424029b5
6 changed files with 16 additions and 8 deletions

View File

@@ -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)

View File

@@ -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(

View File

@@ -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(

View File

@@ -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.

View File

@@ -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):

View File

@@ -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
)