Добавлена ветка prod_prep
This commit is contained in:
+29
-11
@@ -1,23 +1,41 @@
|
||||
"""Services handler - show rich service cards with images."""
|
||||
from aiogram import Router, F
|
||||
from aiogram.types import Message
|
||||
from aiogram.types import Message, FSInputFile, InlineKeyboardMarkup, InlineKeyboardButton, CallbackQuery
|
||||
from aiogram.fsm.context import FSMContext
|
||||
from aiogram import Bot
|
||||
|
||||
from app.keyboards.menu import menu
|
||||
from app.keyboards.services import get_services_keyboard
|
||||
from app.config import SERVICES, BOT_TOKEN
|
||||
from app.logger import logger
|
||||
|
||||
router = Router()
|
||||
|
||||
_bot = None
|
||||
|
||||
|
||||
def bot():
|
||||
global _bot
|
||||
if _bot is None:
|
||||
_bot = Bot(token=BOT_TOKEN)
|
||||
return _bot
|
||||
|
||||
|
||||
@router.message(F.text == "\U0001f4cb \u0423\u0441\u043b\u0443\u0433\u0438")
|
||||
async def show_services(message: Message, state: FSMContext):
|
||||
await state.clear()
|
||||
logger.info("User {uid} requested services list", uid=message.from_user.id)
|
||||
await message.answer(
|
||||
"\U0001f4cb \u041d\u0430\u0448\u0438 \u0443\u0441\u043b\u0443\u0433\u0438:\n\n"
|
||||
"\U0001f4aa \u041c\u0430\u0441\u0441\u0430\u0436 - \u0440\u0430\u0441\u0441\u043b\u0430\u0431\u043b\u044f\u044e\u0449\u0438\u0439 \u0438 \u043b\u0435\u0447\u0435\u0431\u043d\u044b\u0439\n"
|
||||
"\U0001f388 SPA - \u043a\u043e\u043c\u043f\u043b\u0435\u043a\u0441\u043d\u044b\u0435 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u044b\n"
|
||||
"\U0001f484 \u041a\u043e\u0441\u043c\u0435\u0442\u043e\u043b\u043e\u0433\u0438\u044f - \u0443\u0445\u043e\u0434 \u0437\u0430 \u043b\u0438\u0446\u043e\u043c\n\n"
|
||||
"\u0427\u0442\u043e\u0431\u044b \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c\u0441\u044f, \u043d\u0430\u0436\u043c\u0438\u0442\u0435 \u00ab\u0417\u0430\u043f\u0438\u0441\u0430\u0442\u044c\u0441\u044f\u00bb",
|
||||
reply_markup=get_services_keyboard()
|
||||
)
|
||||
|
||||
for key, svc in SERVICES.items():
|
||||
try:
|
||||
card = (
|
||||
svc["emoji"] + " " + svc["name"] + "\n\n"
|
||||
+ svc["desc"] + "\n\n"
|
||||
+ "\u23f1 \u0414\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c: " + str(svc["duration"]) + " \u043c\u0438\u043d\n"
|
||||
+ "\U0001f4b0 \u0426\u0435\u043d\u0430: " + str(svc["price"]) + "\u20bd"
|
||||
)
|
||||
book_btn = InlineKeyboardMarkup(inline_keyboard=[[
|
||||
InlineKeyboardButton(text="\U0001f4c5 \u0417\u0430\u043f\u0438\u0441\u0430\u0442\u044c\u0441\u044f", callback_data=key)
|
||||
]])
|
||||
img = FSInputFile(svc["image"])
|
||||
await bot().send_photo(message.chat.id, photo=img, caption=card, reply_markup=book_btn)
|
||||
except Exception as e:
|
||||
logger.warning("Error sending service card for {key}: {err}", key=key, err=e)
|
||||
|
||||
Reference in New Issue
Block a user