diff --git a/AUTHORS.rst b/AUTHORS.rst index 01274656a17..183af378ace 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -13,6 +13,7 @@ The following wonderful people contributed directly or indirectly to this projec - `bimmlerd `_ - `Eli Gao `_ - `ErgoZ Riftbit Vaper `_ +- `Eugene Lisitsky `_ - `franciscod `_ - `Jacob Bom `_ - `JASON0916 `_ diff --git a/telegram/utils/request.py b/telegram/utils/request.py index 0aa071c84d6..85f82becfea 100644 --- a/telegram/utils/request.py +++ b/telegram/utils/request.py @@ -31,8 +31,8 @@ from urllib3.connection import HTTPConnection from telegram import (InputFile, TelegramError) -from telegram.error import Unauthorized, NetworkError, TimedOut, BadRequest, ChatMigrated, \ - RetryAfter +from telegram.error import Unauthorized, InvalidToken, NetworkError, TimedOut, BadRequest, \ + ChatMigrated, RetryAfter logging.getLogger('urllib3').setLevel(logging.WARNING) @@ -150,6 +150,8 @@ def _request_wrapper(self, *args, **kwargs): raise Unauthorized() elif resp.status == 400: raise BadRequest(repr(message)) + elif resp.status == 404: + raise InvalidToken() elif resp.status == 502: raise NetworkError('Bad Gateway') else: diff --git a/tests/test_bot.py b/tests/test_bot.py index e598c4dedbe..ed7d37c0990 100644 --- a/tests/test_bot.py +++ b/tests/test_bot.py @@ -227,7 +227,7 @@ def testUnauthToken(self): bot.getMe() def testInvalidSrvResp(self): - with self.assertRaisesRegexp(telegram.TelegramError, 'Invalid server response'): + with self.assertRaisesRegexp(telegram.error.InvalidToken, 'Invalid token'): # bypass the valid token check newbot_cls = type( 'NoTokenValidateBot', (telegram.Bot,), dict(_validate_token=lambda x, y: None))