mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-22 17:36:34 +03:00
Created Retrieving all dialogs (markdown)
parent
ad4ad3d4ac
commit
e5df84dbed
26
Retrieving-all-dialogs.md
Normal file
26
Retrieving-all-dialogs.md
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
There are several `offset_xyz=` parameters that have no effect at all, but there's not much one can do since this is something the server should handle. Currently, the only way to get all dialogs (open chats, conversations, etc.) is by using the `offset_date`:
|
||||||
|
|
||||||
|
```python
|
||||||
|
from telethon.tl.functions.messages import GetDialogsRequest
|
||||||
|
|
||||||
|
|
||||||
|
dialogs = []
|
||||||
|
users = []
|
||||||
|
chats = []
|
||||||
|
|
||||||
|
last_date = None
|
||||||
|
chunk_size = 20
|
||||||
|
while True:
|
||||||
|
result = client.invoke(GetDialogsRequest(
|
||||||
|
offset_date=last_date,
|
||||||
|
offset_id=0,
|
||||||
|
offset_peer=InputPeerEmpty(),
|
||||||
|
limit=chunk_size
|
||||||
|
))
|
||||||
|
dialogs.extend(result.dialogs)
|
||||||
|
users.extend(result.users)
|
||||||
|
chats.extend(result.chats)
|
||||||
|
last_date = min(msg.date for msg in result.messages)
|
||||||
|
if not result.dialogs:
|
||||||
|
break
|
||||||
|
```
|
Loading…
Reference in New Issue
Block a user