From 7ea24fe2af09907acd0c1e07cd865e6060a10d75 Mon Sep 17 00:00:00 2001 From: Denis Date: Sun, 27 Jul 2025 02:12:30 +0300 Subject: [PATCH] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD=20?= =?UTF-8?q?=D0=BF=D1=80=D0=B8=D0=BC=D0=B5=D1=80=20=D0=B7=D0=B0=D0=BF=D1=83?= =?UTF-8?q?=D1=81=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wiki/webhook.md | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/wiki/webhook.md b/wiki/webhook.md index b26f8cf..434c209 100644 --- a/wiki/webhook.md +++ b/wiki/webhook.md @@ -81,13 +81,21 @@ async def init_serve(self, bot: Bot, host: str = '0.0.0.0', port: int = 8080, ** import asyncio import logging -from fastapi import Request -from fastapi.responses import JSONResponse +try: + from fastapi import Request + from fastapi.responses import JSONResponse +except ImportError: + raise ImportError( + '\n\t Не установлен fastapi!' + '\n\t Выполните команду для установки fastapi: ' + '\n\t pip install fastapi>=0.68.0' + '\n\t Или сразу все зависимости для работы вебхука:' + '\n\t pip install maxapi[webhook]' + ) from maxapi import Bot, Dispatcher from maxapi.methods.types.getted_updates import process_update_webhook from maxapi.types import MessageCreated -from maxapi.dispatcher import webhook_app logging.basicConfig(level=logging.INFO) @@ -101,7 +109,7 @@ async def handle_message(event: MessageCreated): # Регистрация обработчика # для вебхука -@webhook_app.post('/') +@dp.webhook_post('/') async def _(request: Request): # Сериализация полученного запроса @@ -133,7 +141,6 @@ async def main(): if __name__ == '__main__': asyncio.run(main()) - ``` ---