mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-22 09:26:37 +03:00
Sleep automatically on slow mode error too (#1279)
This commit is contained in:
parent
4f6e5c5f5a
commit
40aa46e72a
|
@ -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
|
||||||
|
|
|
@ -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]
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
|
@ -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:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user