diff --git a/telethon/client/telegrambaseclient.py b/telethon/client/telegrambaseclient.py index d3abbc3c..b0882e6c 100644 --- a/telethon/client/telegrambaseclient.py +++ b/telethon/client/telegrambaseclient.py @@ -118,7 +118,7 @@ class TelegramBaseClient(abc.ABC): flood_sleep_threshold (`int` | `float`, optional): The threshold below which the library should automatically - sleep on flood wait errors (inclusive). For instance, if a + sleep on flood wait and slow mode wait errors (inclusive). For instance, if a ``FloodWaitError`` for 17s occurs and `flood_sleep_threshold` is 20s, the library will ``sleep`` automatically. If the error was for 21s, it would ``raise FloodWaitError`` instead. Values diff --git a/telethon/client/users.py b/telethon/client/users.py index 685f6134..15fcf771 100644 --- a/telethon/client/users.py +++ b/telethon/client/users.py @@ -82,7 +82,7 @@ class UserMethods: e.__class__.__name__, e) await asyncio.sleep(2) - except (errors.FloodWaitError, errors.FloodTestPhoneWaitError) as e: + except (errors.FloodWaitError, errors.SlowModeWaitError, errors.FloodTestPhoneWaitError) as e: if utils.is_list_like(request): request = request[request_index] diff --git a/telethon_generator/data/errors.csv b/telethon_generator/data/errors.csv index aab5bddd..38ef5816 100644 --- a/telethon_generator/data/errors.csv +++ b/telethon_generator/data/errors.csv @@ -228,6 +228,7 @@ SESSION_PASSWORD_NEEDED,401,Two-steps verification is enabled and a password is SESSION_REVOKED,401,"The authorization has been invalidated, because of the user terminating all sessions" SHA256_HASH_INVALID,400,The provided SHA256 hash is invalid SHORTNAME_OCCUPY_FAILED,400,An error occurred when trying to register the short-name used for the sticker pack. Try a different name +SLOWMODE_WAIT_X,420,A wait of {seconds} seconds is required before sending another message in this chat START_PARAM_EMPTY,400,The start parameter is empty START_PARAM_INVALID,400,Start parameter invalid STICKERSET_INVALID,400,The provided sticker set is invalid diff --git a/telethon_generator/parsers/errors.py b/telethon_generator/parsers/errors.py index 4fb9d43d..df352999 100644 --- a/telethon_generator/parsers/errors.py +++ b/telethon_generator/parsers/errors.py @@ -28,7 +28,8 @@ def _get_class_name(error_code): ) return snake_to_camel_case( - error_code.replace('FIRSTNAME', 'FIRST_NAME').lower(), suffix='Error') + error_code.replace('FIRSTNAME', 'FIRST_NAME')\ + .replace('SLOWMODE', 'SLOW_MODE').lower(), suffix='Error') class Error: