Skip to content
Browse files

Sleep automatically on slow mode error too (#1279)

  • Loading branch information...
Andrebcd4 authored and Lonami committed Sep 24, 2019
1 parent 4f6e5c5 commit 40aa46e72a4a43756e344173cd68861429b447f0
@@ -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
@@ -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]

@@ -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
@@ -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:

0 comments on commit 40aa46e

Please sign in to comment.
You can’t perform that action at this time.