Add /menu command to show main menu with buttons
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
parent
d7f071d4d2
commit
c2f62295b7
26
bot.py
26
bot.py
|
|
@ -288,6 +288,27 @@ async def start_command(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
|||
)
|
||||
|
||||
|
||||
async def menu_command(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
||||
"""Обработка команды /menu - показывает главное меню."""
|
||||
user = update.effective_user
|
||||
state = state_manager.get(user.id)
|
||||
|
||||
# Сброс состояния и возврат к главному меню
|
||||
state_manager.reset(user.id)
|
||||
state.current_menu = "main"
|
||||
|
||||
# Показать текущую директорию
|
||||
working_dir = state.working_directory or config.get("working_directory", str(Path.home()))
|
||||
|
||||
await update.message.reply_text(
|
||||
f"🏠 *Главное меню*\n\n"
|
||||
f"📁 Текущая директория: `{working_dir}`\n\n"
|
||||
f"Выберите действие:",
|
||||
parse_mode="Markdown",
|
||||
reply_markup=menu_builder.get_keyboard("main")
|
||||
)
|
||||
|
||||
|
||||
async def help_command(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
||||
"""Обработка команды /help."""
|
||||
help_text = f"""
|
||||
|
|
@ -314,7 +335,8 @@ async def help_command(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
|||
• ℹ️ О боте — информация
|
||||
|
||||
*Команды управления:*
|
||||
/start — Главное меню
|
||||
/start — Запустить бота, главное меню
|
||||
/menu — Показать главное меню с кнопками
|
||||
/help — Эта справка
|
||||
/settings — Настройки
|
||||
|
||||
|
|
@ -801,6 +823,7 @@ async def post_init(application: Application):
|
|||
# Установка команд бота
|
||||
commands = [
|
||||
BotCommand("start", "Запустить бота"),
|
||||
BotCommand("menu", "Главное меню с кнопками"),
|
||||
BotCommand("help", "Справка"),
|
||||
BotCommand("settings", "Настройки"),
|
||||
]
|
||||
|
|
@ -845,6 +868,7 @@ def main():
|
|||
application.add_handler(CommandHandler("start", start_command))
|
||||
application.add_handler(CommandHandler("help", help_command))
|
||||
application.add_handler(CommandHandler("settings", settings_command))
|
||||
application.add_handler(CommandHandler("menu", menu_command))
|
||||
application.add_handler(CallbackQueryHandler(menu_callback))
|
||||
application.add_handler(MessageHandler(filters.TEXT & ~filters.COMMAND, handle_text_message))
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue