Skip to content

Commit

Permalink
Sleep automatically on slow mode error too (LonamiWebs#1279)
Browse files Browse the repository at this point in the history
  • Loading branch information
kittyandrew authored and Lonami committed Sep 24, 2019
1 parent 4f6e5c5 commit 40aa46e
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion telethon/client/telegrambaseclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion telethon/client/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 82,7 @@ async def __call__(self: 'TelegramClient', request, ordered=False):
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]

Expand Down
1 change: 1 addition & 0 deletions telethon_generator/data/errors.csv
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion telethon_generator/parsers/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 40aa46e

Please sign in to comment.