🧹 Конфиг: услуги, мастера и время вынесены в config.py

- SERVICES, MASTERS, TIME_SLOTS в config.py
- Клавиатуры services.py, masters.py, time_slots.py берут данные из config
- booking.py импортирует services/masters из config вместо хардкода
- time_slots отображает занятые слоты как , свободные как 
This commit is contained in:
DevProject Agent
2026-06-14 19:23:52 +04:00
parent 8efd5d09d5
commit cff1b2bc91
6 changed files with 70 additions and 112 deletions
View File
+24 -2
View File
@@ -1,9 +1,31 @@
import os
import json
from dotenv import load_dotenv
load_dotenv()
BOT_TOKEN = os.getenv("BOT_TOKEN")
BOT_TOKEN = os.getenv(BOT_TOKEN)
if not BOT_TOKEN:
raise ValueError("BOT_TOKEN не найден")
raise ValueError(BOT_TOKEN не найден)
# ——— Данные для клавиатур ———
SERVICES = {
service_massage: Массаж,
service_spa: SPA,
service_cosmetology: Косметология,
}
MASTERS = {
master_anna: Анна,
master_maria: Мария,
master_alex: Алексей,
}
TIME_SLOTS = [
09:00, 10:00, 11:00,
12:00, 13:00, 14:00,
15:00, 16:00, 17:00,
18:00,
]
+16 -22
View File
@@ -51,11 +51,8 @@ async def choose_service(
callback: CallbackQuery,
state: FSMContext
):
services = {
"service_massage": "Массаж",
"service_spa": "SPA",
"service_cosmetology": "Косметология"
}
from app.config import SERVICES
services = SERVICES
service_name = services[callback.data]
@@ -83,11 +80,8 @@ async def choose_master(
state: FSMContext
):
masters = {
"master_anna": "Анна",
"master_maria": "Мария",
"master_alex": "Алексей"
}
from app.config import MASTERS
masters = MASTERS
master_name = masters[callback.data]
@@ -128,7 +122,7 @@ async def choose_date(
data = await state.get_data()
busy_times = get_busy_times(
master=data.get("master", "?"),
master=data.get('master', '?'),
date=selected_date
)
@@ -171,9 +165,9 @@ async def choose_time(
await callback.message.edit_text(
f"📋 Проверьте запись:\n\n"
f"💆 Услуга: {data.get("service", "?")}\n"
f"📅 Дата: {data.get("date", "?")}\n"
f"👤 Мастер:{data.get("master", "?")}\n"
f"💆 Услуга: {data.get('service', '?')}\n"
f"📅 Дата: {data.get('date', '?')}\n"
f"👤 Мастер:{data.get('master', '?')}\n"
f"🕒 Время: {selected_time}",
reply_markup=get_confirm_booking_keyboard()
)
@@ -200,10 +194,10 @@ async def confirm_booking_callback(
update_booking(
booking_id=editing_booking_id,
service=data.get("service", "?"),
master=data.get("master", "?"),
date=data.get("date", "?"),
time=data.get("time", "?")
service=data.get('service', '?'),
master=data.get('master', '?'),
date=data.get('date', '?'),
time=data.get('time', '?')
)
result_text = "✅ Запись успешно обновлена"
@@ -212,10 +206,10 @@ async def confirm_booking_callback(
create_booking(
user_id=callback.from_user.id,
service=data.get("service", "?"),
master=data.get("master", "?"),
date=data.get("date", "?"),
time=data.get("time", "?")
service=data.get('service', '?'),
master=data.get('master', '?'),
date=data.get('date', '?'),
time=data.get('time', '?')
)
result_text = "✅ Запись успешно создана"
+7 -25
View File
@@ -1,28 +1,10 @@
from aiogram.types import InlineKeyboardMarkup
from aiogram.types import InlineKeyboardButton
from aiogram.types import InlineKeyboardMarkup, InlineKeyboardButton
from app.config import MASTERS
def get_masters_keyboard():
return InlineKeyboardMarkup(
inline_keyboard=[
[
InlineKeyboardButton(
text="👩 Анна",
callback_data="master_anna"
)
],
[
InlineKeyboardButton(
text="👩 Мария",
callback_data="master_maria"
)
],
[
InlineKeyboardButton(
text="👨 Алексей",
callback_data="master_alex"
)
]
]
)
buttons = [
[InlineKeyboardButton(text=name, callback_data=key)]
for key, name in MASTERS.items()
]
return InlineKeyboardMarkup(inline_keyboard=buttons)
+7 -25
View File
@@ -1,28 +1,10 @@
from aiogram.types import InlineKeyboardMarkup
from aiogram.types import InlineKeyboardButton
from aiogram.types import InlineKeyboardMarkup, InlineKeyboardButton
from app.config import SERVICES
def get_services_keyboard():
return InlineKeyboardMarkup(
inline_keyboard=[
[
InlineKeyboardButton(
text="💆 Массаж",
callback_data="service_massage"
)
],
[
InlineKeyboardButton(
text="🌿 SPA",
callback_data="service_spa"
)
],
[
InlineKeyboardButton(
text="✨ Косметология",
callback_data="service_cosmetology"
)
]
]
)
buttons = [
[InlineKeyboardButton(text=name, callback_data=key)]
for key, name in SERVICES.items()
]
return InlineKeyboardMarkup(inline_keyboard=buttons)
+16 -38
View File
@@ -1,41 +1,19 @@
from aiogram.types import InlineKeyboardMarkup
from aiogram.types import InlineKeyboardButton
from aiogram.types import InlineKeyboardMarkup, InlineKeyboardButton
from app.config import TIME_SLOTS
def get_time_keyboard(
busy_times=None
):
if busy_times is None:
busy_times = []
times = [
"10:00",
"11:00",
"12:00",
"13:00",
"14:00",
"15:00",
"16:00",
"17:00"
]
def get_time_keyboard(busy_times):
buttons = []
for time in times:
if time in busy_times:
continue
buttons.append(
[
InlineKeyboardButton(
text=time,
callback_data=f"time_{time}"
)
]
)
return InlineKeyboardMarkup(
inline_keyboard=buttons
)
row = []
for slot in TIME_SLOTS:
if slot in busy_times:
label = f {slot}
else:
label = f {slot}
row.append(InlineKeyboardButton(text=label, callback_data=ftime_{slot}))
if len(row) == 3:
buttons.append(row)
row = []
if row:
buttons.append(row)
return InlineKeyboardMarkup(inline_keyboard=buttons)