mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-29 05:18:10 +00:00
Handle flood wait when getting dialogs chunks
This commit is contained in:
parent
70173adca9
commit
83c4ba8a78
@ -888,14 +888,19 @@ class Client:
|
|||||||
)
|
)
|
||||||
|
|
||||||
def get_dialogs_chunk(self, offset_date):
|
def get_dialogs_chunk(self, offset_date):
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
r = self.send(
|
r = self.send(
|
||||||
functions.messages.GetDialogs(
|
functions.messages.GetDialogs(
|
||||||
offset_date, 0, types.InputPeerEmpty(),
|
offset_date, 0, types.InputPeerEmpty(),
|
||||||
self.DIALOGS_AT_ONCE, True
|
self.DIALOGS_AT_ONCE, True
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
except FloodWait as e:
|
||||||
|
log.warning("get_dialogs flood: waiting {} seconds".format(e.x))
|
||||||
|
time.sleep(e.x)
|
||||||
|
else:
|
||||||
log.info("Total peers: {}".format(len(self.peers_by_id)))
|
log.info("Total peers: {}".format(len(self.peers_by_id)))
|
||||||
|
|
||||||
return r
|
return r
|
||||||
|
|
||||||
def get_dialogs(self):
|
def get_dialogs(self):
|
||||||
@ -905,13 +910,7 @@ class Client:
|
|||||||
offset_date = utils.get_offset_date(dialogs)
|
offset_date = utils.get_offset_date(dialogs)
|
||||||
|
|
||||||
while len(dialogs.dialogs) == self.DIALOGS_AT_ONCE:
|
while len(dialogs.dialogs) == self.DIALOGS_AT_ONCE:
|
||||||
try:
|
|
||||||
dialogs = self.get_dialogs_chunk(offset_date)
|
dialogs = self.get_dialogs_chunk(offset_date)
|
||||||
except FloodWait as e:
|
|
||||||
log.warning("get_dialogs flood: waiting {} seconds".format(e.x))
|
|
||||||
time.sleep(e.x)
|
|
||||||
continue
|
|
||||||
|
|
||||||
offset_date = utils.get_offset_date(dialogs)
|
offset_date = utils.get_offset_date(dialogs)
|
||||||
|
|
||||||
self.get_dialogs_chunk(0)
|
self.get_dialogs_chunk(0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user