Skip to content

Ketab #70

Description

@seyedmohammadhsan2-gif

from telegram import Update, InlineKeyboardButton, InlineKeyboardMarkup
from telegram.ext import (
ApplicationBuilder,
CommandHandler,
CallbackQueryHandler,
ContextTypes
)

TOKEN = "8739806734:AAGhzCLG45DWV6jMHAkbN4Ku-jOVBM0vKHQ"

استارت

async def start(update: Update, context: ContextTypes.DEFAULT_TYPE):
keyboard = [
[InlineKeyboardButton("📚 خدمات کتاب", callback_data="books")]
]

await update.message.reply_text(
    "به فروشگاه کتاب خوش آمدید:",
    reply_markup=InlineKeyboardMarkup(keyboard)
)

دکمه‌ها

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

if query.data == "books":
    keyboard = [
        [InlineKeyboardButton("📘 کتاب روانشناسی", callback_data="book1")],
        [InlineKeyboardButton("📗 کتاب اطلس خدا", callback_data="book2")],
        [InlineKeyboardButton("📕 روانشناسی جلد ۳۱", callback_data="book3")]
    ]

    await query.edit_message_text(
        "کتاب مورد نظر را انتخاب کنید:",
        reply_markup=InlineKeyboardMarkup(keyboard)
    )

elif query.data == "book1":
    await query.edit_message_text(
        "📘 کتاب روانشناسی\n💰 قیمت: 800,000 تومان"
    )

elif query.data == "book2":
    await query.edit_message_text(
        "📗 کتاب از من خدا\n💰 قیمت: 900,000 تومان"
    )

elif query.data == "book3":
    await query.edit_message_text(
        "📕 کتاب روانشناسی جلد ۳۱\n💰 قیمت: 900,000 تومان"
    )

app = ApplicationBuilder().token(TOKEN).build()

app.add_handler(CommandHandler("start", start))
app.add_handler(CallbackQueryHandler(button))

app.run_polling()

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions