Fix timeout error not being excepted on Button.click

This commit is contained in:
Lonami Exo 2019-05-05 19:57:09 +02:00
parent b20dc3b804
commit 5ed7bf7815
3 changed files with 8 additions and 4 deletions

View File

@ -108,7 +108,7 @@ class ServerError(RPCError):
self.message = message self.message = message
class BotTimeout(RPCError): class TimedOutError(RPCError):
""" """
Clicking the inline buttons of bots that never (or take to long to) Clicking the inline buttons of bots that never (or take to long to)
call ``answerCallbackQuery`` will result in this "special" RPCError. call ``answerCallbackQuery`` will result in this "special" RPCError.
@ -121,6 +121,9 @@ class BotTimeout(RPCError):
self.message = message self.message = message
BotTimeout = TimedOutError
class BadMessageError(Exception): class BadMessageError(Exception):
"""Occurs when handling a bad_message_notification.""" """Occurs when handling a bad_message_notification."""
ErrorMessages = { ErrorMessages = {

View File

@ -1,3 +1,3 @@
# Versions should comply with PEP440. # Versions should comply with PEP440.
# This line is parsed in setup.py: # This line is parsed in setup.py:
__version__ = '1.7.4' __version__ = '1.7.5'

View File

@ -13,6 +13,7 @@ KNOWN_BASE_CLASSES = {
406: 'AuthKeyError', 406: 'AuthKeyError',
420: 'FloodError', 420: 'FloodError',
500: 'ServerError', 500: 'ServerError',
503: 'TimedOutError'
} }
@ -23,7 +24,7 @@ def _get_class_name(error_code):
""" """
if isinstance(error_code, int): if isinstance(error_code, int):
return KNOWN_BASE_CLASSES.get( return KNOWN_BASE_CLASSES.get(
error_code, 'RPCError' + str(error_code).replace('-', 'Neg') abs(error_code), 'RPCError' + str(error_code).replace('-', 'Neg')
) )
return snake_to_camel_case( return snake_to_camel_case(
@ -38,7 +39,7 @@ class Error:
self.int_code = codes[0] self.int_code = codes[0]
self.str_code = name self.str_code = name
self.subclass = _get_class_name(codes[0]) self.subclass = _get_class_name(codes[0])
self.subclass_exists = codes[0] in KNOWN_BASE_CLASSES self.subclass_exists = abs(codes[0]) in KNOWN_BASE_CLASSES
self.description = description self.description = description
self.has_captures = '_X' in name self.has_captures = '_X' in name