From 44d04256a201a815e8bcda8ce3a58c01102bfe45 Mon Sep 17 00:00:00 2001 From: "oleg.vodyanov91@gmail.com" Date: Sun, 1 Jun 2025 14:58:02 +0400 Subject: [PATCH] devide project --- src/docbot/handlers/admins/__init__.py | 0 src/docbot/handlers/{ => admins}/doctors_handler.py | 0 src/docbot/handlers/{ => admins}/generate_ref.py | 0 src/docbot/handlers/admins_handler.py | 10 ---------- src/docbot/handlers/doctors/__init__.py | 0 src/docbot/handlers/{ => doctors}/register_handler.py | 2 +- src/docbot/handlers/get_form_handler.py | 2 +- src/docbot/handlers/patients/__init__.py | 0 .../handlers/{ => patients}/send_form_handler.py | 2 +- src/docbot/handlers/utils/__init__.py | 0 src/docbot/handlers/{ => utils}/cancel_handler.py | 0 src/docbot/handlers/{ => utils}/help.py | 4 +--- src/docbot/handlers/{ => utils}/unknown.py | 2 +- src/docbot/main.py | 10 +++++----- src/docbot/services/admins_service.py | 9 +++++++++ 15 files changed, 19 insertions(+), 22 deletions(-) create mode 100644 src/docbot/handlers/admins/__init__.py rename src/docbot/handlers/{ => admins}/doctors_handler.py (100%) rename src/docbot/handlers/{ => admins}/generate_ref.py (100%) delete mode 100644 src/docbot/handlers/admins_handler.py create mode 100644 src/docbot/handlers/doctors/__init__.py rename src/docbot/handlers/{ => doctors}/register_handler.py (98%) create mode 100644 src/docbot/handlers/patients/__init__.py rename src/docbot/handlers/{ => patients}/send_form_handler.py (97%) create mode 100644 src/docbot/handlers/utils/__init__.py rename src/docbot/handlers/{ => utils}/cancel_handler.py (100%) rename src/docbot/handlers/{ => utils}/help.py (95%) rename src/docbot/handlers/{ => utils}/unknown.py (88%) diff --git a/src/docbot/handlers/admins/__init__.py b/src/docbot/handlers/admins/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/docbot/handlers/doctors_handler.py b/src/docbot/handlers/admins/doctors_handler.py similarity index 100% rename from src/docbot/handlers/doctors_handler.py rename to src/docbot/handlers/admins/doctors_handler.py diff --git a/src/docbot/handlers/generate_ref.py b/src/docbot/handlers/admins/generate_ref.py similarity index 100% rename from src/docbot/handlers/generate_ref.py rename to src/docbot/handlers/admins/generate_ref.py diff --git a/src/docbot/handlers/admins_handler.py b/src/docbot/handlers/admins_handler.py deleted file mode 100644 index c678521..0000000 --- a/src/docbot/handlers/admins_handler.py +++ /dev/null @@ -1,10 +0,0 @@ -from telegram import Update -from telegram.ext import ( - ContextTypes, - ConversationHandler, - CommandHandler, - MessageHandler, - filters, -) - - diff --git a/src/docbot/handlers/doctors/__init__.py b/src/docbot/handlers/doctors/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/docbot/handlers/register_handler.py b/src/docbot/handlers/doctors/register_handler.py similarity index 98% rename from src/docbot/handlers/register_handler.py rename to src/docbot/handlers/doctors/register_handler.py index 8433387..791c08f 100644 --- a/src/docbot/handlers/register_handler.py +++ b/src/docbot/handlers/doctors/register_handler.py @@ -7,7 +7,7 @@ from telegram.ext import ( filters, ) -from docbot.handlers.cancel_handler import get_cancel_handler +from docbot.handlers.utils.cancel_handler import get_cancel_handler from docbot.services.referral_service import validate_referral_code, mark_referral_code_as_used from core.enums.consultation_types import Consultation diff --git a/src/docbot/handlers/get_form_handler.py b/src/docbot/handlers/get_form_handler.py index 6f70cd2..bf72b7f 100644 --- a/src/docbot/handlers/get_form_handler.py +++ b/src/docbot/handlers/get_form_handler.py @@ -7,7 +7,7 @@ from telegram.ext import ( filters, ) from docbot.services.session_service import create_session_code, get_pending_session -from docbot.handlers.cancel_handler import get_cancel_handler +from docbot.handlers.utils.cancel_handler import get_cancel_handler ASK_LINK = 1 diff --git a/src/docbot/handlers/patients/__init__.py b/src/docbot/handlers/patients/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/docbot/handlers/send_form_handler.py b/src/docbot/handlers/patients/send_form_handler.py similarity index 97% rename from src/docbot/handlers/send_form_handler.py rename to src/docbot/handlers/patients/send_form_handler.py index 5a75f90..dacda34 100644 --- a/src/docbot/handlers/send_form_handler.py +++ b/src/docbot/handlers/patients/send_form_handler.py @@ -7,7 +7,7 @@ from telegram.ext import ( filters, ) from docbot.services.session_service import create_session_code, get_pending_session -from docbot.handlers.cancel_handler import get_cancel_handler +from docbot.handlers.utils.cancel_handler import get_cancel_handler ASK_LINK = 1 diff --git a/src/docbot/handlers/utils/__init__.py b/src/docbot/handlers/utils/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/docbot/handlers/cancel_handler.py b/src/docbot/handlers/utils/cancel_handler.py similarity index 100% rename from src/docbot/handlers/cancel_handler.py rename to src/docbot/handlers/utils/cancel_handler.py diff --git a/src/docbot/handlers/help.py b/src/docbot/handlers/utils/help.py similarity index 95% rename from src/docbot/handlers/help.py rename to src/docbot/handlers/utils/help.py index 1d6ea3f..f7cb2eb 100644 --- a/src/docbot/handlers/help.py +++ b/src/docbot/handlers/utils/help.py @@ -1,8 +1,6 @@ from telegram import Update, ReplyKeyboardMarkup -from telegram.ext import ContextTypes, CommandHandler +from telegram.ext import ContextTypes -from core.config import settings -from docbot.services.referral_service import ReferralService from docbot.services.admins_service import get_admin_info from docbot.services.doctors_service import get_doctor_info diff --git a/src/docbot/handlers/unknown.py b/src/docbot/handlers/utils/unknown.py similarity index 88% rename from src/docbot/handlers/unknown.py rename to src/docbot/handlers/utils/unknown.py index c4d6832..753817f 100644 --- a/src/docbot/handlers/unknown.py +++ b/src/docbot/handlers/utils/unknown.py @@ -1,5 +1,5 @@ from telegram import Update -from telegram.ext import ContextTypes, CommandHandler, MessageHandler, filters +from telegram.ext import ContextTypes, MessageHandler, filters async def unknown_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: diff --git a/src/docbot/main.py b/src/docbot/main.py index 4f40b39..bb51501 100644 --- a/src/docbot/main.py +++ b/src/docbot/main.py @@ -3,11 +3,11 @@ from telegram.ext import ApplicationBuilder, PicklePersistence, ExtBot from core.config import settings from docbot.handlers.start_handler import get_start_handler -from docbot.handlers.send_form_handler import get_send_form_handler -from docbot.handlers.doctors_handler import get_doctors_handler -from docbot.handlers.register_handler import get_register_doctor_handler -from docbot.handlers.generate_ref import get_referral_handlers -from docbot.handlers.unknown import get_unknown_handler +from docbot.handlers.patients.send_form_handler import get_send_form_handler +from docbot.handlers.admins.doctors_handler import get_doctors_handler +from docbot.handlers.doctors.register_handler import get_register_doctor_handler +from docbot.handlers.admins.generate_ref import get_referral_handlers +from docbot.handlers.utils.unknown import get_unknown_handler def main(): diff --git a/src/docbot/services/admins_service.py b/src/docbot/services/admins_service.py index f58ae03..4e3abaa 100644 --- a/src/docbot/services/admins_service.py +++ b/src/docbot/services/admins_service.py @@ -6,6 +6,15 @@ from db.models import Admins async def get_admin_info(telegram_id: int) -> Admins | None: + async with AsyncSessionLocal() as session: + result = await session.execute( + select(Admins.telegram_id) + .where(Admins.telegram_id.match(str(telegram_id))) + ) + return result.scalar_one_or_none() + + +async def mark_doctor_inactive(telegram_id: int) -> Admins | None: async with AsyncSessionLocal() as session: result = await session.execute( select(Admins.telegram_id)