From 403a37692c0b09f409b9979b877136f7a110b337 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Wed, 7 Feb 2018 03:35:34 +0100 Subject: [PATCH] Handle GetDialogs FloodWait errors --- pyrogram/client/client.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/pyrogram/client/client.py b/pyrogram/client/client.py index 2b9318a1..d5a69e73 100644 --- a/pyrogram/client/client.py +++ b/pyrogram/client/client.py @@ -495,12 +495,17 @@ class Client: log.info("Dialogs count: {}".format(len(peers))) while len(dialogs.dialogs) == self.DIALOGS_AT_ONCE: - dialogs = self.send( - functions.messages.GetDialogs( - offset_date, 0, types.InputPeerEmpty(), - self.DIALOGS_AT_ONCE, True + try: + dialogs = self.send( + functions.messages.GetDialogs( + offset_date, 0, types.InputPeerEmpty(), + self.DIALOGS_AT_ONCE, True + ) ) - ) + except FloodWait as e: + log.info("Get dialogs flood wait: {}".format(e.x)) + time.sleep(e.x) + continue offset_date = parse_dialogs(dialogs) log.info("Dialogs count: {}".format(len(peers)))