Answer the question
In order to leave comments, you need to log in
Why does the multi-stage menu in the telegram bot not work?
There is such a code. It does not work, or rather, the menu does not appear either with the category of goods, or with the manufacturers of goods and TD. Please help solve the problem, the order is waiting. There is no desire to use other libraries, I hope only for telebot.
import telebot
import config
bot = telebot.TeleBot(config.token)
@bot.message_handler(content_types=['text', 'document'])
def kt(message):
key = types.ReplyKeyboardMarkup(resize_keyboard=True)
key.row(types.KeyboardButton('Магнитолы'))
key.row(types.KeyboardButton('Усилители'))
key.row(types.KeyboardButton('Акустика'))
key.row(types.KeyboardButton('Эстрадная акустика'))
key.row(types.KeyboardButton('Сабвуферы'))
key.row(types.KeyboardButton('Назад'))
bot.send_message(message.chat.id, 'Выберите категорию товара')
@bot.message_handler(commands=['katalog']
def katalog(message):
if message.text == 'Магнитолы':
key = types.ReplyKeyboardMarkup(resize_keyboard=True)
key.row(types.KeyboardButton('ACES'))
key.row(types.KeyboardButton('ACV'))
key.row(types.KeyboardButton('ALPINE'))
key.row(types.KeyboardButton('AURA'))
key.row(types.KeyboardButton('AVATAR'))
key.row(types.KeyboardButton('CLARION'))
key.row(types.KeyboardButton('Назад'))
bot.send_message(message.chat.id, 'Выберите производителя')
elif message.text == 'Акустика':
key = types.ReplyKeyboardMarkup(resize_keyboard=True)
key.row(types.KeyboardButton('ACV'))
key.row(types.KeyboardButton('AIRTONE'))
key.row(types.KeyboardButton('ALPHARD'))
key.row(types.KeyboardButton('ALPINE'))
key.row(types.KeyboardButton('ARIA'))
key.row(types.KeyboardButton('AUDIO SYSTEM'))
key.row(types.KeyboardButton('Назад'))
bot.send_message(message.chat.id, 'Выберите производителя')
Answer the question
In order to leave comments, you need to log in
The answer is simple:
In the send_message methods, you need to add the reply_markup=key
argument
without this, the keyboard object will not be sent along with the message
and also
key.row('Radios')
key.row('ALPINE')
so it's easier
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question