X
X
xxxfdd2020-12-02 15:30:15
Python
xxxfdd, 2020-12-02 15:30:15

How to make words generally ignored in a purely clave bot?

How can I make the bot react only to the keyboard, as if, for example, the user is met with such a keyboard: Food, Toys, and the apple buttons are hidden behind the food, etc. and toys just slipped through

if message.text == 'Посмотреть товары!':
        user_mark_nal = telebot.types.ReplyKeyboardMarkup(True, True)



        user_mark_nal.row('Еда!')
        user_mark_nal.row('Игрушки!')
        user_mark_nal.row('Нашёл баг!')

        bot.send_message(message.from_user.id,
                         'Выберите категорию',
                         reply_markup=user_mark_nal)

    if message.text == 'Еда!':
        user_mark_nal = telebot.types.ReplyKeyboardMarkup(True, True)

        user_mark_nal.row('Яблоко')
        user_mark_nal.row('Апельсин')
        user_mark_nal.row('Банан')

        bot.send_message(message.from_user.id,
                         'Выберите категорию',
                         reply_markup=user_mark_nal)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
STARoD00M, 2020-12-02
@xxxfdd

Use InlineKeyboardMarkup.
You can attach callback_data to buttons, and catch bot.callback_query_handler.
More examples in Google
Plus there is such an implementation example, you can do it like https://github.com/starod00m/cooking_book

S
soremix, 2020-12-02
@SoreMix

No way.
ReplyKeyboardMarkups do not have any differences from text and are only shortcuts for the user so that they do not enter text by hand.
It is not clear how the keyboard can "slip", pressing the "Apple" button is 200% identical to sending "Apple" entered manually

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question