mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-07-12 09:02:24 +03:00
Destroyed Retrieving all dialogs (markdown)
parent
5b9364eea5
commit
3dea080e50
|
@ -1,28 +0,0 @@
|
|||
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
|
||||
from telethon.tl.types import InputPeerEmpty
|
||||
from time import sleep
|
||||
|
||||
dialogs = []
|
||||
users = []
|
||||
chats = []
|
||||
|
||||
last_date = None
|
||||
chunk_size = 20
|
||||
while True:
|
||||
result = client(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)
|
||||
if not result.messages:
|
||||
break
|
||||
last_date = min(msg.date for msg in result.messages)
|
||||
sleep(2)
|
||||
```
|
Loading…
Reference in New Issue
Block a user