Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ The following wonderful people contributed directly or indirectly to this projec
- `bimmlerd <https://github.com/bimmlerd>`_
- `Eli Gao <https://github.com/eligao>`_
- `ErgoZ Riftbit Vaper <https://github.com/ergoz>`_
- `Eugene Lisitsky <https://github.com/lisitsky>`_
- `franciscod <https://github.com/franciscod>`_
- `Jacob Bom <https://github.com/bomjacob>`_
- `JASON0916 <https://github.com/JASON0916>`_
Expand Down
6 changes: 4 additions & 2 deletions telegram/utils/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down