| 15 | # Handler for /start command - Then the bot will send amount stars to purchase |
| 16 | @bot.message_handler(commands=['start']) |
| 17 | def send_welcome(message): |
| 18 | # Create a custom keyboard with 2 buttons per row |
| 19 | markup = types.ReplyKeyboardMarkup(row_width=2) |
| 20 | # Generate buttons for each product in our PRICES dictionary |
| 21 | buttons = [types.KeyboardButton(product) for product in PRICES.keys()] |
| 22 | # Add all buttons to the markup |
| 23 | markup.add(*buttons) |
| 24 | |
| 25 | # Send welcome message with the custom keyboard |
| 26 | bot.reply_to(message, |
| 27 | "Welcome to Stars Payment Bot!\nPlease select amount of stars to purchase:", |
| 28 | reply_markup=markup) |
| 29 | |
| 30 | # Handler for when user selects a product from the keyboard |
| 31 | @bot.message_handler(func=lambda message: message.text in PRICES.keys()) |