mirror of
https://github.com/pyrogram/pyrogram
synced 2025-09-02 07:15:23 +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_initial_dialogs()
|
||||||
self.get_contacts()
|
self.get_contacts()
|
||||||
else:
|
else:
|
||||||
self.send(functions.messages.GetPinnedDialogs())
|
self.send(functions.messages.GetPinnedDialogs(folder_id=0))
|
||||||
self.get_initial_dialogs_chunk()
|
self.get_initial_dialogs_chunk()
|
||||||
else:
|
else:
|
||||||
self.send(functions.updates.GetState())
|
self.send(functions.updates.GetState())
|
||||||
@@ -1325,7 +1325,7 @@ class Client(Methods, BaseClient):
|
|||||||
return r
|
return r
|
||||||
|
|
||||||
def get_initial_dialogs(self):
|
def get_initial_dialogs(self):
|
||||||
self.send(functions.messages.GetPinnedDialogs())
|
self.send(functions.messages.GetPinnedDialogs(folder_id=0))
|
||||||
|
|
||||||
dialogs = self.get_initial_dialogs_chunk()
|
dialogs = self.get_initial_dialogs_chunk()
|
||||||
offset_date = utils.get_offset_date(dialogs)
|
offset_date = utils.get_offset_date(dialogs)
|
||||||
|
@@ -62,7 +62,7 @@ class GetDialogs(BaseClient):
|
|||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
if pinned_only:
|
if pinned_only:
|
||||||
r = self.send(functions.messages.GetPinnedDialogs())
|
r = self.send(functions.messages.GetPinnedDialogs(folder_id=0))
|
||||||
else:
|
else:
|
||||||
r = self.send(
|
r = self.send(
|
||||||
functions.messages.GetDialogs(
|
functions.messages.GetDialogs(
|
||||||
|
@@ -36,7 +36,7 @@ class GetDialogsCount(BaseClient):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
if pinned_only:
|
if pinned_only:
|
||||||
return len(self.send(functions.messages.GetPinnedDialogs()).dialogs)
|
return len(self.send(functions.messages.GetPinnedDialogs(folder_id=0)).dialogs)
|
||||||
else:
|
else:
|
||||||
r = self.send(
|
r = self.send(
|
||||||
functions.messages.GetDialogs(
|
functions.messages.GetDialogs(
|
||||||
|
@@ -26,7 +26,7 @@ class IterDialogs(BaseClient):
|
|||||||
def iter_dialogs(
|
def iter_dialogs(
|
||||||
self,
|
self,
|
||||||
offset_date: int = 0,
|
offset_date: int = 0,
|
||||||
limit: int = 0
|
limit: int = None
|
||||||
) -> Generator["pyrogram.Dialog", None, None]:
|
) -> Generator["pyrogram.Dialog", None, None]:
|
||||||
"""Iterate through a user's dialogs sequentially.
|
"""Iterate through a user's dialogs sequentially.
|
||||||
|
|
||||||
|
@@ -69,7 +69,7 @@ class Dialog(PyrogramType):
|
|||||||
self.is_pinned = is_pinned
|
self.is_pinned = is_pinned
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _parse(client, dialog, messages, users, chats) -> "Dialog":
|
def _parse(client, dialog: types.Dialog, messages, users, chats) -> "Dialog":
|
||||||
chat_id = dialog.peer
|
chat_id = dialog.peer
|
||||||
|
|
||||||
if isinstance(chat_id, types.PeerUser):
|
if isinstance(chat_id, types.PeerUser):
|
||||||
|
@@ -51,7 +51,7 @@ class Dialogs(PyrogramType):
|
|||||||
self.dialogs = dialogs
|
self.dialogs = dialogs
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _parse(client, dialogs) -> "Dialogs":
|
def _parse(client, dialogs: types.messages.Dialogs) -> "Dialogs":
|
||||||
users = {i.id: i for i in dialogs.users}
|
users = {i.id: i for i in dialogs.users}
|
||||||
chats = {i.id: i for i in dialogs.chats}
|
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)
|
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(
|
return Dialogs(
|
||||||
total_count=getattr(dialogs, "count", len(dialogs.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
|
client=client
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user