feat: register Telegram command menu via SetMyCommands#668
feat: register Telegram command menu via SetMyCommands#668rfschubert wants to merge 5 commits intosipeed:mainfrom
Conversation
Call bot.SetMyCommands() on startup so that Telegram displays the command menu when users press "/" in chat. Registration failure is logged as a warning and does not block bot startup.
There was a problem hiding this comment.
Pull request overview
This PR adds Telegram command menu registration via SetMyCommands API so that users can see available commands when typing / in Telegram chat. The implementation registers the four existing command handlers (/start, /help, /show, /list) during bot startup, with registration failures logged as warnings to avoid blocking startup.
Changes:
- Added
registerCommands()method to register bot commands with Telegram API - Integrated command registration into
Start()method with non-blocking error handling - Mapped all four existing command handlers to their descriptions for the command menu
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Register command menu with Telegram | ||
| if err := c.registerCommands(ctx); err != nil { | ||
| logger.WarnCF("telegram", "Failed to register commands menu", map[string]any{ | ||
| "error": err.Error(), | ||
| }) | ||
| } |
There was a problem hiding this comment.
The command registration is happening after the bot is marked as running and after logging "Telegram bot connected". Consider moving this registration to occur before line 128 (before setRunning) and before the "connected" log message. This would ensure all initialization steps complete before the bot is considered operational and would make the "connected" log more accurate. Compare with the Discord channel implementation where bot info is fetched before opening the session.
|
Duplicate with #300 |
nikolasdehor
left a comment
There was a problem hiding this comment.
Clean implementation. Using SetMyCommands on startup is the standard Telegram bot pattern. Good choice to log a warning on failure rather than blocking startup.
Two minor suggestions (non-blocking):
- The command descriptions ("Show current configuration", "List available options") are generic. Consider aligning them with what the handlers actually do in the context of PicoClaw (e.g., "Show bot configuration and model info", "List installed skills").
- If commands are ever added or changed dynamically, consider calling
SetMyCommandsagain. But for static commands, startup registration is fine.
LGTM.
|
Closing this PR as the same was already done in #300 |
📝 Description
The Telegram bot does not call
SetMyCommands, so users don't see the command menu when pressing/in chat. This PR registers the existing handled commands (/start,/help,/show,/list) on startup so the menu is visible.🗣️ Type of Change
🤖 AI Code Generation
🔗 Related Issue
📚 Technical Context (Skip for Docs)
telego.BotCommandandtelego.SetMyCommandsParamsalready exist in telego v1.6.0 — no new dependencies needed. Only the 4 commands that have registered handlers are included. Registration failure logs a warning but does not block bot startup.🧪 Test Environment
📸 Evidence (Optional)
Click to view Logs/Screenshots
After deploying, pressing
/in the Telegram chat shows the command menu with all 4 registered commands.make buildandgo test ./pkg/channels/ -vpass with no errors or warnings.☑️ Checklist