From 8a5743ef0cff326423310f2c5748eb103e791b72 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Tue, 22 May 2018 16:16:28 +0200 Subject: [PATCH] Allow FloodWait to be raised in case of non-interactive sign-ins --- pyrogram/client/client.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/pyrogram/client/client.py b/pyrogram/client/client.py index 209488f7..8721f925 100644 --- a/pyrogram/client/client.py +++ b/pyrogram/client/client.py @@ -399,8 +399,11 @@ class Client(Methods, BaseClient): print(e.MESSAGE) self.phone_number = None except FloodWait as e: - print(e.MESSAGE.format(x=e.x)) - time.sleep(e.x) + if phone_number_invalid_raises: + raise + else: + print(e.MESSAGE.format(x=e.x)) + time.sleep(e.x) except Exception as e: log.error(e, exc_info=True) else: @@ -493,16 +496,22 @@ class Client(Methods, BaseClient): print(e.MESSAGE) self.password = None except FloodWait as e: - print(e.MESSAGE.format(x=e.x)) - time.sleep(e.x) + if password_hash_invalid_raises: + raise + else: + print(e.MESSAGE.format(x=e.x)) + time.sleep(e.x) except Exception as e: log.error(e, exc_info=True) else: break break except FloodWait as e: - print(e.MESSAGE.format(x=e.x)) - time.sleep(e.x) + if phone_code_invalid_raises or first_name_invalid_raises: + raise + else: + print(e.MESSAGE.format(x=e.x)) + time.sleep(e.x) except Exception as e: log.error(e, exc_info=True) else: