Бот не реагирует на Inline кнопки
При нажатии на кнопку бот не реагирует, что тут не так?
import telebot
from telebot import types
bot = telebot.TeleBot('my_token')
@bot.message_handler(commands=['start'])
def start(msg):
markup = types.InlineKeyboardMarkup()
markup.add(types.InlineKeyboardButton('1', callback_data='1'))
bot.send_message(msg.chat.id, 'Hey', reply_markup=markup)
@bot.callback_query_handler(func=lambda call: True)
def callback_handler(call):
bot.send_message(call.message.chat.id, text="Вы нажали кнопку ")
bot.polling(none_stop=True)
Ответы (1 шт):
Автор решения: Andrey comp
→ Ссылка
import telebot
from telebot import types
bot = telebot.TeleBot('токен')
@bot.message_handler(commands=['start'])
def start(msg):
markup = types.InlineKeyboardMarkup()
markup.add(types.InlineKeyboardButton('1', callback_data='1'))
bot.send_message(msg.chat.id, 'Hey', reply_markup=markup)
@bot.callback_query_handler(func=lambda call: True)
def callback_handler(call):
if call.data == '1':
bot.send_message(call.message.chat.id, text="Вы нажали кнопку 1")
bot.polling(none_stop=True)
