fix: enforce Telegram 100-command limit with warning (#5787)#15844
fix: enforce Telegram 100-command limit with warning (#5787)#15844steipete merged 2 commits intoopenclaw:mainfrom
Conversation
src/telegram/bot-native-commands.ts
Outdated
| const commandsToRegister = allCommands.slice(0, TELEGRAM_MAX_COMMANDS); | ||
|
|
||
| if (commandsToRegister.length > 0) { | ||
| withTelegramApiErrorLogging({ | ||
| operation: "setMyCommands", | ||
| runtime, | ||
| fn: () => bot.api.setMyCommands(allCommands), | ||
| fn: () => bot.api.setMyCommands(commandsToRegister), | ||
| }).catch(() => {}); |
There was a problem hiding this comment.
Command list/handler mismatch
setMyCommands is truncated to commandsToRegister, but the subsequent bot.command(...) registrations still iterate over all nativeCommands and pluginCommands. This creates a definite divergence where commands beyond the first 100 remain callable (handlers exist) but won’t show in Telegram’s command UI, which is confusing and makes the warning actionable but behavior inconsistent. Consider limiting handler registration to the same truncated set (or explicitly choosing an ordering/selection for which handlers should remain enabled when over the limit).
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/telegram/bot-native-commands.ts
Line: 342:349
Comment:
**Command list/handler mismatch**
`setMyCommands` is truncated to `commandsToRegister`, but the subsequent `bot.command(...)` registrations still iterate over *all* `nativeCommands` and `pluginCommands`. This creates a definite divergence where commands beyond the first 100 remain callable (handlers exist) but won’t show in Telegram’s command UI, which is confusing and makes the warning actionable but behavior inconsistent. Consider limiting handler registration to the same truncated set (or explicitly choosing an ordering/selection for which handlers should remain enabled when over the limit).
How can I resolve this? If you propose a fix, please make it concise.|
Addressed in 546de98 — added a comment clarifying the intentional behavior: the command menu is truncated to 100 (Telegram API limit), but handlers remain registered for all commands so they still work when typed manually. This is the correct behavior since the agent handles commands via natural language regardless of the menu. |
Telegram's setMyCommands API rejects requests with more than 100 commands. When skills + custom + plugin commands exceed the limit, truncate to 100 and warn the user instead of silently failing on every startup.
546de98 to
682765e
Compare
|
Landed via temp rebase onto main. Thanks @battman21! |
…penclaw#15844) * fix: enforce Telegram 100-command limit with warning (openclaw#5787) Telegram's setMyCommands API rejects requests with more than 100 commands. When skills + custom + plugin commands exceed the limit, truncate to 100 and warn the user instead of silently failing on every startup. * fix: enforce Telegram menu cap + keep hidden commands callable (openclaw#15844) (thanks @battman21) --------- Co-authored-by: Peter Steinberger <[email protected]>
…penclaw#15844) * fix: enforce Telegram 100-command limit with warning (openclaw#5787) Telegram's setMyCommands API rejects requests with more than 100 commands. When skills + custom + plugin commands exceed the limit, truncate to 100 and warn the user instead of silently failing on every startup. * fix: enforce Telegram menu cap + keep hidden commands callable (openclaw#15844) (thanks @battman21) --------- Co-authored-by: Peter Steinberger <[email protected]>
…penclaw#15844) * fix: enforce Telegram 100-command limit with warning (openclaw#5787) Telegram's setMyCommands API rejects requests with more than 100 commands. When skills + custom + plugin commands exceed the limit, truncate to 100 and warn the user instead of silently failing on every startup. * fix: enforce Telegram menu cap + keep hidden commands callable (openclaw#15844) (thanks @battman21) --------- Co-authored-by: Peter Steinberger <[email protected]>
…penclaw#15844) * fix: enforce Telegram 100-command limit with warning (openclaw#5787) Telegram's setMyCommands API rejects requests with more than 100 commands. When skills + custom + plugin commands exceed the limit, truncate to 100 and warn the user instead of silently failing on every startup. * fix: enforce Telegram menu cap + keep hidden commands callable (openclaw#15844) (thanks @battman21) --------- Co-authored-by: Peter Steinberger <[email protected]>
Summary
setMyCommandsAPIFixes #5787
Test plan
BOT_COMMANDS_TOO_MUCHerror when >100 commands🤖 Generated with Claude Code
Greptile Overview
Greptile Summary
This change introduces a hard cap of 100 commands when registering Telegram bot commands via
setMyCommands, and logs a warning when configuration exceeds Telegram’s limit. The command list is built with the intended priority order (native → plugin → custom), then truncated before calling the Telegram API to avoidBOT_COMMANDS_TOO_MUCH.Within the Telegram channel integration,
registerTelegramNativeCommandsis the central place where both the advertised command menu (setMyCommands) and the runtime command handlers (bot.command) are set up.Confidence Score: 4/5
setMyCommandspayload and warning. However, it leaves command handlers registered for commands that are no longer advertised, which will produce confusing UX and potentially unexpected exposure of commands beyond the first 100.Last reviewed commit: 151796f