From 29355722fa7933b9b73114daeba08674bce6bce6 Mon Sep 17 00:00:00 2001 From: Dmitry Afanasyev Date: Sun, 24 Sep 2023 09:29:10 +0300 Subject: [PATCH] switch to desktop --- bot_microservice/core/handlers.py | 10 +++++----- bot_microservice/main.py | 4 ++-- bot_microservice/tests/integration/bot/conftest.py | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/bot_microservice/core/handlers.py b/bot_microservice/core/handlers.py index 0174b98..0712005 100644 --- a/bot_microservice/core/handlers.py +++ b/bot_microservice/core/handlers.py @@ -6,15 +6,15 @@ from telegram.ext import CommandHandler, MessageHandler, filters @dataclass -class CommandHandlers: +class BotEventHandlers: handlers: list[Any] = field(default_factory=list[Any]) def add_handler(self, handler: Any) -> None: self.handlers.append(handler) -command_handlers = CommandHandlers() +bot_event_handlers = BotEventHandlers() -command_handlers.add_handler(CommandHandler("help", help_command)) -command_handlers.add_handler(MessageHandler(filters.TEXT & ~filters.COMMAND, ask_question)) -command_handlers.add_handler(MessageHandler(filters.VOICE | filters.AUDIO, voice_recognize)) +bot_event_handlers.add_handler(CommandHandler("help", help_command)) +bot_event_handlers.add_handler(MessageHandler(filters.TEXT & ~filters.COMMAND, ask_question)) +bot_event_handlers.add_handler(MessageHandler(filters.VOICE | filters.AUDIO, voice_recognize)) diff --git a/bot_microservice/main.py b/bot_microservice/main.py index e6144ff..25fcc37 100644 --- a/bot_microservice/main.py +++ b/bot_microservice/main.py @@ -3,7 +3,7 @@ from functools import cached_property import sentry_sdk from core.bot import BotApplication, BotQueue -from core.handlers import command_handlers +from core.handlers import bot_event_handlers from fastapi import FastAPI from fastapi.responses import UJSONResponse from routers import api_router @@ -59,7 +59,7 @@ class Application: def create_app(settings: AppSettings | None = None) -> FastAPI: settings = settings or get_settings() - bot_app = BotApplication(settings=settings, handlers=command_handlers.handlers) + bot_app = BotApplication(settings=settings, handlers=bot_event_handlers.handlers) return Application(settings=settings, bot_app=bot_app).fastapi_app diff --git a/bot_microservice/tests/integration/bot/conftest.py b/bot_microservice/tests/integration/bot/conftest.py index e2afffe..e7c68dc 100644 --- a/bot_microservice/tests/integration/bot/conftest.py +++ b/bot_microservice/tests/integration/bot/conftest.py @@ -10,7 +10,7 @@ from typing import Any, AsyncGenerator import pytest import pytest_asyncio from core.bot import BotApplication -from core.handlers import command_handlers +from core.handlers import bot_event_handlers from fastapi import FastAPI from httpx import AsyncClient from main import Application as AppApplication @@ -229,7 +229,7 @@ async def main_application( bot_app = BotApplication( application=bot_application, settings=test_settings, - handlers=command_handlers.handlers, + handlers=bot_event_handlers.handlers, ) fast_api_app = AppApplication(settings=test_settings, bot_app=bot_app).fastapi_app yield fast_api_app