feat: allow /start description and keep menu default
This commit is contained in:
+13
-5
@@ -3,7 +3,7 @@ import asyncio
|
||||
from typing import Callable, Dict, Any, Awaitable, Optional
|
||||
|
||||
from aiogram import Bot, Dispatcher, BaseMiddleware, Router, F
|
||||
from aiogram.types import Update, MenuButtonWebApp, WebAppInfo
|
||||
from aiogram.types import Update, MenuButtonDefault, BotCommand
|
||||
from aiogram.enums import ParseMode
|
||||
from aiogram.filters import CommandStart, Command
|
||||
from aiogram.client.default import DefaultBotProperties
|
||||
@@ -172,12 +172,20 @@ async def on_startup_configured(dispatcher: Dispatcher):
|
||||
await bot.delete_webhook(drop_pending_updates=True)
|
||||
|
||||
if settings.SUBSCRIPTION_MINI_APP_URL:
|
||||
menu_text = i18n_instance.gettext(settings.DEFAULT_LANGUAGE, "menu_my_subscription_inline")
|
||||
try:
|
||||
await bot.set_chat_menu_button(menu_button=MenuButtonWebApp(text=menu_text, web_app=WebAppInfo(url=settings.SUBSCRIPTION_MINI_APP_URL)))
|
||||
logging.info("STARTUP: Menu button for subscription mini app set via API.")
|
||||
await bot.set_chat_menu_button(MenuButtonDefault())
|
||||
logging.info("STARTUP: Mini app support enabled with default menu button.")
|
||||
except Exception as e:
|
||||
logging.error(f"STARTUP: Failed to set menu button web app: {e}", exc_info=True)
|
||||
logging.error(f"STARTUP: Failed to set default menu button: {e}", exc_info=True)
|
||||
|
||||
if settings.START_COMMAND_DESCRIPTION:
|
||||
try:
|
||||
await bot.set_my_commands([
|
||||
BotCommand(command="start", description=settings.START_COMMAND_DESCRIPTION)
|
||||
])
|
||||
logging.info("STARTUP: /start command description set.")
|
||||
except Exception as e:
|
||||
logging.error(f"STARTUP: Failed to set bot commands: {e}", exc_info=True)
|
||||
|
||||
logging.info("STARTUP: Bot on_startup_configured completed.")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user