Пишу ТГ- бота на Pytelegrambotapi, не могу найти решение - как обработать inline кнопки btn1, btn2, btn3?
@bot.message_handler(commands=['start'])
def start(message):
markup = types.InlineKeyboardMarkup()
butt1 = types.InlineKeyboardButton(lang[0], callback_data=lang[0])
butt2 = types.InlineKeyboardButton(lang[1], callback_data=lang[1])
butt3 = types.InlineKeyboardButton(lang[2], callback_data=lang[2])
markup.add(butt1,butt2,butt3)
bot.send_message(message.chat.id, f'Greetings, {message.from_user.first_name}, please, choose your language', reply_markup=markup)
@bot.callback_query_handler(func=lambda callback: callback.data)
def callback_message(callback):
if callback.data == lang[0]:
markup = types.InlineKeyboardMarkup(row_width= 1)
butt1 = types.InlineKeyboardButton(random.choice(question), callback_data='btn1')
butt2 = types.InlineKeyboardButton(random.choice(question), callback_data='btn2')
butt3 = types.InlineKeyboardButton(random.choice(question), callback_data='btn3')
markup.add(butt1, butt2, butt3)
bot.send_message(callback.message.chat.id, mess, parse_mode='html', reply_markup=markup)
#Тут нужен обработчик кнопок btn1, btn2, btn3
if call.data == 'btn1' or 'btn2' or 'btn3':
conn = sqlite3.connect('book.db')
cur = conn.cursor()
cur.execute("select * from book order by RANDOM() LIMIT 1")
answer = cur.fetchall()
bot.send_message(call.message.chat.id, answer[0][1], parse_mode='html')