diff --git a/mautrix_telegram/web/common/auth_api.py b/mautrix_telegram/web/common/auth_api.py index 08b6ffa4..3fba40db 100644 --- a/mautrix_telegram/web/common/auth_api.py +++ b/mautrix_telegram/web/common/auth_api.py @@ -289,6 +289,17 @@ class AuthAPI(abc.ABC): errcode="phone_number_unoccupied", error="That phone number has not been registered.", ) + except FloodWaitError as e: + return self.get_login_response( + mxid=user.mxid, + state="code", + status=429, + errcode="flood_wait", + error=( + "You tried to enter your phone code too many times. " + f"Please wait for {format_duration(e.seconds)} before trying again." + ), + ) except SessionPasswordNeededError: if not password_in_data: if user.command_status and user.command_status["action"] == "Login": @@ -354,6 +365,17 @@ class AuthAPI(abc.ABC): "terminated via the Telegram app." ), ) + except FloodWaitError as e: + return self.get_login_response( + mxid=user.mxid, + state="password", + status=429, + errcode="flood_wait", + error=( + "You tried to enter your password too many times. " + f"Please wait for {format_duration(e.seconds)} before trying again." + ), + ) except Exception as e: self.log.exception("Error sending password") if isinstance(e, ValueError) and "You must provide a phone and a code" in str(e):