diff --git a/app/main.py b/app/main.py index 4a2437b..3523f2c 100644 --- a/app/main.py +++ b/app/main.py @@ -22,16 +22,11 @@ from app.settings import ( WEBHOOK_URL, ) -queue: asyncio.Queue = asyncio.Queue() # type: ignore - async def bot_startup() -> None: await bot.set_webhook(WEBHOOK_URL) logger.info(f'Webhook set to {WEBHOOK_URL}'.replace(API_TOKEN, '{BOT_API_TOKEN}')) asyncio_schedule() - logger.info('Scheduler started') - await worker() - logger.info('Worker started') async def bot_shutdown() -> None: @@ -88,22 +83,13 @@ async def webhook(request: web.Request) -> web.Response: """ data = await request.json() tg_update = Update(**data) - logger.info(tg_update) - queue.put_nowait(tg_update) - logger.info('Put in queue') - return web.Response(status=HTTPStatus.ACCEPTED) - -async def worker() -> None: Dispatcher.set_current(dispatcher) Bot.set_current(dispatcher.bot) - await asyncio.sleep(3) - logger.info('Worker is working') - while True: - await asyncio.sleep(4) - update = await queue.get() - logger.warning(f"Get update {update}") - await dispatcher.process_update(update) + + await dispatcher.process_update(tg_update) + + return web.Response(status=HTTPStatus.OK) async def create_app() -> web.Application: