Sleep automatically on slow mode error too (#1279)

This commit is contained in:
Andrebcd4 2019-09-24 12:37:41 +03:00 committed by Lonami
parent 4f6e5c5f5a
commit 40aa46e72a
4 changed files with 5 additions and 3 deletions

View File

@ -118,7 +118,7 @@ class TelegramBaseClient(abc.ABC):
flood_sleep_threshold (`int` | `float`, optional): flood_sleep_threshold (`int` | `float`, optional):
The threshold below which the library should automatically 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` ``FloodWaitError`` for 17s occurs and `flood_sleep_threshold`
is 20s, the library will ``sleep`` automatically. If the error is 20s, the library will ``sleep`` automatically. If the error
was for 21s, it would ``raise FloodWaitError`` instead. Values was for 21s, it would ``raise FloodWaitError`` instead. Values

View File

@ -82,7 +82,7 @@ class UserMethods:
e.__class__.__name__, e) e.__class__.__name__, e)
await asyncio.sleep(2) 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): if utils.is_list_like(request):
request = request[request_index] request = request[request_index]

View File

@ -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" 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 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 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_EMPTY,400,The start parameter is empty
START_PARAM_INVALID,400,Start parameter invalid START_PARAM_INVALID,400,Start parameter invalid
STICKERSET_INVALID,400,The provided sticker set is invalid STICKERSET_INVALID,400,The provided sticker set is invalid

1 name codes description
228 SESSION_REVOKED 401 The authorization has been invalidated, because of the user terminating all sessions
229 SHA256_HASH_INVALID 400 The provided SHA256 hash is invalid
230 SHORTNAME_OCCUPY_FAILED 400 An error occurred when trying to register the short-name used for the sticker pack. Try a different name
231 SLOWMODE_WAIT_X 420 A wait of {seconds} seconds is required before sending another message in this chat
232 START_PARAM_EMPTY 400 The start parameter is empty
233 START_PARAM_INVALID 400 Start parameter invalid
234 STICKERSET_INVALID 400 The provided sticker set is invalid

View File

@ -28,7 +28,8 @@ def _get_class_name(error_code):
) )
return snake_to_camel_case( 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: class Error: