Skip to content

feat: register Telegram command menu via SetMyCommands#668

Closed
rfschubert wants to merge 5 commits intosipeed:mainfrom
rfschubert:feat/telegram-setmycommands
Closed

feat: register Telegram command menu via SetMyCommands#668
rfschubert wants to merge 5 commits intosipeed:mainfrom
rfschubert:feat/telegram-setmycommands

Conversation

@rfschubert
Copy link

@rfschubert rfschubert commented Feb 23, 2026

📝 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

  • 🐞 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 📖 Documentation update
  • ⚡ Code refactoring (no functional changes, no api changes)

🤖 AI Code Generation

  • 🤖 Fully AI-generated (100% AI, 0% Human)
  • 🛠️ Mostly AI-generated (AI draft, Human verified/modified)
  • 👨‍💻 Mostly Human-written (Human lead, AI assisted or none)

🔗 Related Issue

📚 Technical Context (Skip for Docs)

  • Reference URL: https://core.telegram.org/bots/api#setmycommands
  • Reasoning: telego.BotCommand and telego.SetMyCommandsParams already 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

  • Hardware: PC (AMD64)
  • OS: Ubuntu 24.04 (Linux 6.8.0-87-generic)
  • Model/Provider: N/A (channel-level change, no LLM interaction)
  • Channels: Telegram

📸 Evidence (Optional)

Click to view Logs/Screenshots

After deploying, pressing / in the Telegram chat shows the command menu with all 4 registered commands. make build and go test ./pkg/channels/ -v pass with no errors or warnings.

☑️ Checklist

  • My code/docs follow the style of this project.
  • I have performed a self-review of my own changes.
  • I have updated the documentation accordingly.

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.
Copilot AI review requested due to automatic review settings February 23, 2026 02:57
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Copilot AI review requested due to automatic review settings February 23, 2026 03:02
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Copilot AI review requested due to automatic review settings February 23, 2026 03:05
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Copilot AI review requested due to automatic review settings February 23, 2026 03:08
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +133 to +138
// 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(),
})
}
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
@alexhoshina
Copy link
Collaborator

Duplicate with #300

@alexhoshina alexhoshina added this to the Refactor Channel milestone Feb 26, 2026
Copy link

@nikolasdehor nikolasdehor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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):

  1. 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").
  2. If commands are ever added or changed dynamically, consider calling SetMyCommands again. But for static commands, startup registration is fine.

LGTM.

@sipeed-bot sipeed-bot bot added type: enhancement New feature or request domain: channel labels Mar 3, 2026
@mymmrac
Copy link
Collaborator

mymmrac commented Mar 3, 2026

Closing this PR as the same was already done in #300

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants