@bot.callback_query_handler(func=lambda call: True)
def handle_callback_query(call):
if call.data == 'learn_words':
markup = types.InlineKeyboardMarkup(row_width=2)
button1 = types.InlineKeyboardButton("Легкий уровень", callback_data='easy_level')
button2 = types.InlineKeyboardButton("Дом и быт", callback_data='home_and_life')
markup.add(button1, button2)
bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id,
text="Отлично! Выберите какие слова вы будете изучать", reply_markup=markup)
elif call.data == 'easy_level':
markup = types.InlineKeyboardMarkup(row_width=5)
row = []
for i in range(1, 26):
button = types.InlineKeyboardButton(str(i), callback_data=f'word_{i}')
row.append(button)
if len(row) == 5:
markup.row(*row)
row = []
bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id,
text="Выберите слово:", reply_markup=markup)
elif call.data.startswith('word_'):
selected_word = call.data.split('_')[1]
bot.send_message(call.message.chat.id, f"Вы выбрали слово {selected_word}")