From e3e1ed9ed75ae595e30cd0a616706f216c13aa38 Mon Sep 17 00:00:00 2001 From: Alex Root Junior Date: Sun, 22 Apr 2018 22:02:58 +0300 Subject: [PATCH] Add InvalidStickersSet exception --- aiogram/bot/api.py | 2 ++ aiogram/utils/exceptions.py | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/aiogram/bot/api.py b/aiogram/bot/api.py index 443b5a2e..8d2589e3 100644 --- a/aiogram/bot/api.py +++ b/aiogram/bot/api.py @@ -98,6 +98,8 @@ async def _check_result(method_name, response): exceptions.ToMuchMessages.throw() elif exceptions.InvalidStickersSet.check(description): exceptions.InvalidStickersSet.throw() + elif exceptions.ChatAdminRequired.check(description): + exceptions.ChatAdminRequired.throw() raise exceptions.BadRequest(description) elif response.status == HTTPStatus.NOT_FOUND: if exceptions.MethodNotKnown.check(description): diff --git a/aiogram/utils/exceptions.py b/aiogram/utils/exceptions.py index f9676f1b..c0910e48 100644 --- a/aiogram/utils/exceptions.py +++ b/aiogram/utils/exceptions.py @@ -23,6 +23,7 @@ TelegramAPIError PhotoAsInputFileRequired ToMuchMessages InvalidStickersSet + ChatAdminRequired ConflictError TerminatedByOtherGetUpdates CantGetUpdates @@ -162,16 +163,21 @@ class InvalidStickersSet(BadRequest, _MatchErrorMixin): text = 'Stickers set is invalid' +class ChatAdminRequired(BadRequest, _MatchErrorMixin): + match = 'CHAT_ADMIN_REQUIRED' + text = 'Admin permissions is required!' + + class BadWebhook(BadRequest): pass -class WebhookRequireHTTPS(BadRequest, _MatchErrorMixin): +class WebhookRequireHTTPS(BadWebhook, _MatchErrorMixin): match = 'HTTPS url must be provided for webhook' text = 'bad webhook: ' + match -class BadWebhookPort(BadRequest, _MatchErrorMixin): +class BadWebhookPort(BadWebhook, _MatchErrorMixin): match = 'Webhook can be set up only on ports 80, 88, 443 or 8443' text = 'bad webhook: ' + match