diff --git a/aiogram/dispatcher/webhook.py b/aiogram/dispatcher/webhook.py index ca717202..970fd655 100644 --- a/aiogram/dispatcher/webhook.py +++ b/aiogram/dispatcher/webhook.py @@ -7,6 +7,7 @@ import typing from typing import Dict, List, Optional, Union from aiohttp import web +from aiohttp.web_exceptions import HTTPGone from .. import types from ..bot import api @@ -245,6 +246,19 @@ class WebhookRequestHandler(web.View): context.set_value('TELEGRAM_IP', ip_address) +class GoneRequestHandler(web.View): + """ + If a webhook returns the HTTP error 410 Gone for all requests for more than 23 hours successively, + it can be automatically removed. + """ + + async def get(self): + raise HTTPGone() + + async def post(self): + raise HTTPGone() + + def configure_app(dispatcher, app: web.Application, path=DEFAULT_WEB_PATH): """ You can prepare web.Application for working with webhook handler.