A
A
AlexSeley2021-12-17 22:23:13
Python
AlexSeley, 2021-12-17 22:23:13

Telebot python why button click response not working?

After I click on the button (button1), nothing happens, although I indicated in the callback_inline function that after clicking the button, the bot sends the text "Nice!"

  1. telebot import types
  2. import telebot
  3. TOKEN="****"
  4. bot = telebot.TeleBot(TOKEN)
  5. def callback_inline(call):
  6. if call.message:
  7. if call.data == 'press':
  8. bot.send_message(call.message.chat.id, 'Nice!')
  9. print(first_name, call.message.chat.id, "command=press")
  10. @bot.message_handler(content_types=["text"])
  11. def button(message):
  12. button_1 = types.InlineKeyboardMarkup()
  13. button1 = types.InlineKeyboardButton("Button", callback_data='press')
  14. button_1.add(button1)
  15. bot.send_message(message.chat.id, text='Press:', reply_markup=button_1)
  16. bot.infinity_polling()

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question