Изменен пример запуска
This commit is contained in:
parent
39fb0c5823
commit
7ea24fe2af
@ -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())
|
||||
|
||||
```
|
||||
---
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user