N
N
Nika9802022-02-19 14:12:15
Python
Nika980, 2022-02-19 14:12:15

How to make the Reply button respond?

Here is an example of a piece of code with a button, how to proceed further so that by clicking on the "Poke" button, the user receives the message "Thank you for poke", for example?

answer = ''
    if call.data == '1':
        markup = types.ReplyKeyboardMarkup()
        button2 = types.KeyboardButton(text='Тык')
        markup.row(button2)
        bot.send_message(call.message.chat.id, f"Тыкни на кнопку", reply_markup=markup)
        bot.answer_callback_query(callback_query_id=call.id)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2022-02-19
@SoreMix

ReplyKeyboardMarkupis just a keyboard that sends the prepared text in the same way as the user would send it manually. So the usual handler

@bot.message_handler(func=lambda message: message.text == 'Тык')
def test(message):
    bot.reply_to(message, message.text)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question