Skip to content

bot mehmonhona #18

@doniyor112

Description

@doniyor112

import logging
from telegram import (
Update,
ReplyKeyboardMarkup,
KeyboardButton,
InlineKeyboardButton,
InlineKeyboardMarkup,
)
from telegram.ext import (
Application,
CommandHandler,
MessageHandler,
CallbackQueryHandler,
ContextTypes,
filters,
)

🔐 TOKEN (ENV ga qo‘y!)

TOKEN = "8753267268:AAG7BCk_gT0dxbn3vg15GH-TqtyYIzSmBXE"
ADMIN_ID = 123456789

logging.basicConfig(level=logging.INFO)

users = set()
bookings = []

🎨 MENYU

main_menu = ReplyKeyboardMarkup(
[
["🏨 Mehmonxona", "🛏 Xonalar"],
["💰 Narxlar", "🍽 Xizmatlar"],
["📸 Rasmlar", "📍 Manzil"],
["📞 Aloqa", "📅 Bron qilish"],
],
resize_keyboard=True,
)

back_btn = ReplyKeyboardMarkup([["🔙 Orqaga"]], resize_keyboard=True)

contact_btn = ReplyKeyboardMarkup(
[[KeyboardButton("📞 Raqam yuborish", request_contact=True)]],
resize_keyboard=True,
)

🚀 START

async def start(update: Update, context: ContextTypes.DEFAULT_TYPE):
users.add(update.effective_user.id)

await update.message.reply_text(
    "🔥 Premium mehmonxonaga xush kelibsiz!\n\n👇 Quyidagidan tanlang:",
    reply_markup=main_menu,
)

📱 MENU

async def menu(update: Update, context: ContextTypes.DEFAULT_TYPE):
text = update.message.text

if text == "🔙 Orqaga":
    context.user_data.clear()
    await update.message.reply_text("🏠 Menyu", reply_markup=main_menu)

elif text == "🏨 Mehmonxona":
    await update.message.reply_text("🌟 Premium mehmonxona\n🕐 24/7 xizmat\n⭐ 5 yulduz")

elif text == "🛏 Xonalar":
    keyboard = [
        [InlineKeyboardButton("🛏 Standart", callback_data="standard")],
        [InlineKeyboardButton("🌟 Komfort", callback_data="komfort")],
        [InlineKeyboardButton("🔥 VIP", callback_data="vip")],
    ]
    await update.message.reply_text(
        "👇 Xonani tanlang:",
        reply_markup=InlineKeyboardMarkup(keyboard),
    )

elif text == "💰 Narxlar":
    await update.message.reply_text(
        "💵 Standart: 100k\n🌟 Komfort: 150k\n🔥 VIP: 250k"
    )

elif text == "🍽 Xizmatlar":
    await update.message.reply_text(
        "🍽 Restoran\n🚗 Taxi\n📶 WiFi\n🛎 24/7 xizmat"
    )

elif text == "📸 Rasmlar":
    await update.message.reply_photo(
        photo="https://picsum.photos/600/400",
        caption="🏨 Premium mehmonxona",
    )

elif text == "📍 Manzil":
    await update.message.reply_location(41.3111, 69.2797)

elif text == "📞 Aloqa":
    await update.message.reply_text("📞 +998 90 123 45 67")

elif text == "📅 Bron qilish":
    context.user_data["step"] = "room"

    keyboard = [
        [InlineKeyboardButton("🛏 Standart", callback_data="bron_standard")],
        [InlineKeyboardButton("🌟 Komfort", callback_data="bron_komfort")],
        [InlineKeyboardButton("🔥 VIP", callback_data="bron_vip")],
    ]

    await update.message.reply_text(
        "👇 Xonani tanlang:",
        reply_markup=InlineKeyboardMarkup(keyboard),
    )

🎯 INLINE

async def inline(update: Update, context: ContextTypes.DEFAULT_TYPE):
query = update.callback_query
await query.answer()

if query.data in ["standard", "komfort", "vip"]:
    await query.message.reply_text(f"✅ Tanlandi: {query.data.upper()}")

elif query.data.startswith("bron_"):
    room = query.data.split("_")[1]
    context.user_data["room"] = room
    context.user_data["step"] = "name"

    await query.message.reply_text("👤 Ismingizni yozing:", reply_markup=back_btn)

📅 BRON

async def booking(update: Update, context: ContextTypes.DEFAULT_TYPE):
step = context.user_data.get("step")

if step == "name":
    context.user_data["name"] = update.message.text
    context.user_data["step"] = "phone"

    await update.message.reply_text(
        "📞 Telefon yuboring:",
        reply_markup=contact_btn,
    )

elif step == "phone":
    if update.message.contact:
        context.user_data["phone"] = update.message.contact.phone_number
    else:
        context.user_data["phone"] = update.message.text

    context.user_data["step"] = "date"
    await update.message.reply_text("📅 Sana yozing:")

elif step == "date":
    data = {
        "name": context.user_data["name"],
        "phone": context.user_data["phone"],
        "date": update.message.text,
        "room": context.user_data["room"],
    }

    bookings.append(data)

    await context.bot.send_message(
        chat_id=ADMIN_ID,
        text=f"🔥 Yangi bron!\n\n👤 {data['name']}\n📞 {data['phone']}\n📅 {data['date']}\n🏨 {data['room']}",
    )

    await update.message.reply_text(
        "✅ Bron olindi!",
        reply_markup=main_menu,
    )

    context.user_data.clear()

🧠 HANDLER

async def handle(update: Update, context: ContextTypes.DEFAULT_TYPE):
if "step" in context.user_data:
await booking(update, context)
else:
await menu(update, context)

👨‍💼 ADMIN PANEL

async def admin(update: Update, context: ContextTypes.DEFAULT_TYPE):
if update.effective_user.id != ADMIN_ID:
return

await update.message.reply_text(
    f"📊 Statistika\n\n👥 Users: {len(users)}\n📅 Bronlar: {len(bookings)}"
)

🚀 RUN

app = Application.builder().token(TOKEN).build()

app.add_handler(CommandHandler("start", start))
app.add_handler(CommandHandler("admin", admin))
app.add_handler(CallbackQueryHandler(inline))
app.add_handler(MessageHandler(filters.TEXT | filters.CONTACT, handle))

print("🔥 BOT ISHLADI")
app.run_polling()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions