@VoNpEr132

Почему не меняются кнопки в боте?

Здравствуйте! У меня не переключаются кнопки в боте. Вот код:

import telebot
from telebot import types

bot = telebot.TeleBot('TOKEN')

@bot.message_handler(commands=['start'])
def start(message):
    bot.send_message(message.chat.id, 'Привет!✋\nМы продаём голду, аккаунты и промокоды по самым сладким ценам!\nВсегда мечтал стать крутым в стандоффе? Тогда тебе к нам!')
    markup = types.ReplyKeyboardMarkup(resize_keyboard=True, row_width=2)
    accounts = types.KeyboardButton('КУПИТЬ АККАУНТ')
    promo = types.KeyboardButton('КУПИТЬ ПРОМОКОД')
    gold = types.KeyboardButton('КУПИТЬ ГОЛДУ')
    markup.add(accounts, promo, gold)
    bot.send_message(message.chat.id, 'Выберите, что хотите купить', reply_markup=markup)

@bot.message_handler()
def get_user_text(message):
    if message.text == 'КУПИТЬ АККАУНТ':
        bot.send_message(message.chat.id, 'Выберите, какой аккаунт хотите купить')
        markup = types.ReplyKeyboardMarkup(resize_keyboard=True, row_width=1)
        buy_account = types.KeyboardButton('АККАУНТ С НОЖОМ И ПЕРЧАТКАМИ - 230₽')
        buy_account_1 = types.KeyboardButton('АККАУНТ С ТЫЧКАМИ - 175₽')
        back_to_menu = types.KeyboardButton('НАЗАД В МЕНЮ')
    markup.add(buy_account, buy_account_1, back_to_menu)

bot.polling(none_stop=True)
  • Вопрос задан
  • 258 просмотров
Решения вопроса 1
@HXNDY
import telebot
from telebot import types

bot = telebot.TeleBot('TOKEN')

@bot.message_handler(commands=['start'])
def start(message):
    bot.send_message(message.chat.id, 'Привет!✋\nМы продаём голду, аккаунты и промокоды по самым сладким ценам!\nВсегда мечтал стать крутым в стандоффе? Тогда тебе к нам!')
    markup = types.ReplyKeyboardMarkup(resize_keyboard=True, row_width=2)
    accounts = types.KeyboardButton('КУПИТЬ АККАУНТ')
    promo = types.KeyboardButton('КУПИТЬ ПРОМОКОД')
    gold = types.KeyboardButton('КУПИТЬ ГОЛДУ')
    markup.add(accounts, promo, gold)
    bot.send_message(message.chat.id, 'Выберите, что хотите купить', reply_markup=markup)

@bot.message_handler()
def get_user_text(message):
    if message.text == 'КУПИТЬ АККАУНТ':
        markup = types.ReplyKeyboardMarkup(resize_keyboard=True, row_width=1)
        buy_account = types.KeyboardButton('АККАУНТ С НОЖОМ И ПЕРЧАТКАМИ - 230₽')
        buy_account_1 = types.KeyboardButton('АККАУНТ С ТЫЧКАМИ - 175₽')
        back_to_menu = types.KeyboardButton('НАЗАД В МЕНЮ')
        markup.add(buy_account, buy_account_1, back_to_menu)
        bot.send_message(message.chat.id, 'Выберите, какой аккаунт хотите купить', reply_markup=markup)

bot.polling(none_stop=True)
Ответ написан
Комментировать
Пригласить эксперта
Ответы на вопрос 1
Vindicar
@Vindicar
RTFM!
Кнопки привязаны к сообщению. Чтобы отправить новые кнопки, нужно послать новое сообщение. Ты этого не делаешь.
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы