mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2024-11-22 07:06:26 +01:00
Fix telegram API change, returning '404 Not found' (#461)
* Fix telegram API change, returning '404 Not found' with raising own TelegramError rather native exception * Change exception to InvalidToken in test and request util * Added myself to AUTHORS. Thx for appreciation :)
This commit is contained in:
parent
68e87db909
commit
a2fddbe85c
3 changed files with 6 additions and 3 deletions
|
@ -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>`_
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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))
|
||||
|
|
Loading…
Reference in a new issue