← Back to PRs

#19203: telegram: convert hyphens to underscores in command names

by janckerchen open 2026-02-17 14:30 View on GitHub →
channel: telegram size: S
## Summary - Telegram Bot API requires command names to use underscores, not hyphens - Convert hyphenated command names to underscores before registering with Telegram - Fixes command matching for bots with hyphenated command names (e.g., `!show-context` becomes `/show_context`) ## Test plan - [ ] Test with a bot that has hyphenated commands (e.g., `!show-context`) - [ ] Verify command is registered as `/show_context` on Telegram - [ ] Verify `!show-context` still triggers the command in messages <!-- greptile_comment --> <h3>Greptile Summary</h3> Converts hyphens to underscores in Telegram command names during normalization, since the Telegram Bot API only allows `a-z`, `0-9`, and underscores in command names. The change is minimal and well-targeted: a single `.replace(/-/g, "_")` added to `normalizeTelegramCommandName` in `telegram-custom-commands.ts`, with the test updated to verify the new behavior instead of rejecting hyphenated names. - `normalizeTelegramCommandName` now converts hyphens to underscores (e.g., `show-context` → `show_context`) - The existing test that expected hyphenated names to be rejected is updated to verify successful normalization - The change propagates correctly to all three call sites: Zod schema transform, `resolveTelegramCustomCommands`, and `buildPluginTelegramMenuCommands` - No issues found with existing test coverage — the `bot-native-command-menu.test.ts` test case `bad-name!` still fails correctly (due to `!`, not the hyphen) <h3>Confidence Score: 5/5</h3> - This PR is safe to merge — minimal, well-tested change with no risk of regression. - The change is a single-line addition to an existing normalization function, with the test correctly updated to verify the new behavior. All three call sites of `normalizeTelegramCommandName` benefit from the fix consistently. Existing tests in `bot-native-command-menu.test.ts` remain unaffected because their test cases use characters beyond just hyphens (e.g., `!`) that still fail validation. No logic, security, or behavioral concerns. - No files require special attention. <sub>Last reviewed commit: b66ddc7</sub> <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs