diff --git a/AUTHORS.rst b/AUTHORS.rst index c146e5be1..9c33bc522 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 0aa071c84..85f82becf 100644 --- a/telegram/utils/request.py +++ b/telegram/utils/request.py @@ -31,8 +31,8 @@ import urllib3 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 @@ class Request(object): 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 e598c4ded..ed7d37c09 100644 --- a/tests/test_bot.py +++ b/tests/test_bot.py @@ -227,7 +227,7 @@ class BotTest(BaseTest, unittest.TestCase): 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))