fix: call set_my_commands in async context via setup_global_commands

This commit is contained in:
2026-06-17 11:53:06 +02:00
parent 4f7cb86c81
commit 709e0a65ed
2 changed files with 10 additions and 8 deletions
+8 -7
View File
@@ -222,14 +222,15 @@ async def _refresh_kw_card(bot, chat_id: int, message_id: int, kw_id_full: str):
# ── handler registration + global commands ────────────────────────────────
def register_handlers(app: Application) -> None:
async def _setup_commands(application: Application) -> None:
await application.bot.set_my_commands([
{"command": "start", "description": "Open main menu"},
{"command": "admin", "description": "Admin panel (admins only)"},
])
async def setup_global_commands(app: Application) -> None:
"""Call this from main() after building the app to register bot commands."""
await app.bot.set_my_commands([
{"command": "start", "description": "Open main menu"},
{"command": "admin", "description": "Admin panel (admins only)"},
])
app.post_init(_setup_commands)
def register_handlers(app: Application) -> None:
app.add_handler(CommandHandler("start", start_handler))
app.add_handler(CommandHandler("admin", admin_handler))
app.add_handler(CallbackQueryHandler(callback_router))