Elif state == "choosing_topic": subject = user_states[chat_id]["subject"] section = user_states[chat_id]["section"] if text in materials[subject][section] or text == "Назад": if text == "Назад": show_sections(chat_id, subject) else: send_material(chat_id, subject, section, text) elif text == "FAQ": show_faq(chat_id) else: bot.send_message(chat_id, add_emoji("Неверная тема. Пожалуйста, выберите из списка.")) elif state == "faq": send_faq_answer(chat_id, text) # Отправляем ответ на вопрос elif state == "choosing_test_subject": if text in test_data or text == "Назад" or text == "FAQ": if text == "Назад": show_main_menu(chat_id) elif text == "FAQ": show_faq(chat_id) else: show_test_topics(chat_id, text) else: bot.send_message(chat_id, add_emoji("Неверный предмет. Пожалуйста, выберите из списка.")) elif state == "choosing_test_topic": subject = user_states[chat_id]["subject"] if text in test_data[subject] or text == "Назад" or text == "FAQ": if text == "Назад": show_test_menu(chat_id) elif text == "FAQ": show_faq(chat_id) else: start_test(chat_id, subject, text) # Начинаем тест else: bot.send_message(chat_id, add_emoji("Неверный вариант. Пожалуйста, выберите из списка.")) else: bot.send_message(chat_id, add_emoji("Я не понимаю эту команду. Начните с главного меню.")) def handle_back_button(chat_id): """Обрабатывает нажатие кнопки "Назад".""" state = user_states.get(chat_id, {}).get("state") if state == "choosing_section": show_subjects(chat_id) elif state == "choosing_topic": subject = user_states[chat_id]["subject"] show_sections(chat_id, subject) elif state == "choosing_subject": show_main_menu(chat_id) elif state == "advice" or state == "faq" or state == "testing": show_main_menu(chat_id) elif state == "choosing_test_subject": show_main_menu(chat_id) # Возврат из выбора предмета для теста elif state == "choosing_test_topic": show_test_menu(chat_id) # Возврат из выбора темы для теста else: show_main_menu(chat_id) # --- Запуск бота --- if __name__ == '__main__': bot.infinity_polling()
Ответ нейросети
09 марта 2025 17:29
Понравился ответ?
Задай свой вопрос
Напиши любую задачу или вопрос, а нейросеть её решит



