""" بات رزرو آرایشگاه — نسخه رایگان Salon Booking Bot (Bale) بات‌بان | hi@botban.ir """ import os, time, sqlite3, logging from datetime import date from typing import Any import requests from dotenv import load_dotenv load_dotenv() log = logging.getLogger(__name__) TOKEN: str = os.getenv("BALE_BOT_TOKEN", "") BASE_URL: str = f"https://tapi.bale.ai/bot{TOKEN}" DB_PATH: str = os.path.join(os.path.dirname(__file__), "salon.db") ADMIN_ID: int = int(os.getenv("ADMIN_USER_ID", "0")) # محدودیت نسخه رایگان: ۳ سرویس، ۲ استایلیست SERVICES: dict[str, dict] = { "haircut": {"name": "✂️ کوتاهی مو", "duration": 45, "price": 120_000}, "color": {"name": "🎨 رنگ مو", "duration": 90, "price": 350_000}, "eyebrow": {"name": "👁️ اصلاح ابرو","duration": 20, "price": 80_000}, } STAFF: dict[str, dict] = { "mahdavi": {"name": "خانم مهدوی ⭐ ۴.۹", "slots": ["۱۵:۰۰","۱۶:۰۰","۱۷:۳۰","۱۸:۳۰"]}, "ranjbar": {"name": "خانم رنجبر ⭐ ۴.۸", "slots": ["۱۰:۳۰","۱۱:۳۰","۱۴:۰۰","۱۶:۳۰"]}, } sessions: dict[int, dict] = {} def format_price(p: int) -> str: return f"{p:,} تومان" def services_keyboard() -> dict: return {"inline_keyboard": [ [{"text": f"{s['name']} — {format_price(s['price'])}", "callback_data": f"svc:{key}"}] for key, s in SERVICES.items() ]} def staff_keyboard(service_key: str) -> dict: buttons = [ [{"text": st['name'], "callback_data": f"stf:{service_key}:{key}"}] for key, st in STAFF.items() ] buttons.append([{"text": "🔙 بازگشت", "callback_data": "back_services"}]) return {"inline_keyboard": buttons} def save_booking(user_id: int, user_name: str, service_key: str, staff_key: str, booking_date: str, slot: str) -> int: return db_run( "INSERT INTO bookings (user_id,user_name,service_key,staff_key,booking_date,slot) VALUES (?,?,?,?,?,?)", (user_id, user_name, service_key, staff_key, booking_date, slot) ) def get_booked_slots(staff_key: str, booking_date: str) -> list[str]: return [r[0] for r in db_query( "SELECT slot FROM bookings WHERE staff_key=? AND booking_date=? AND cancelled=0", (staff_key, booking_date) )] # ... ادامه کد (تا ۱۳۵ خط دیگر) # نسخه کامل + مستندات + دیتابیس → hi@botban.ir