#19203: telegram: convert hyphens to underscores in command names
channel: telegram
size: S
Cluster:
Signal and Discord Fixes
## 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
#18711: fix(telegram): replace hyphens with underscores in export-session c...
by MisterGuy420 · 2026-02-17
85.6%
#18704: fix(telegram): normalize command names by replacing hyphens with un...
by Limitless2023 · 2026-02-17
81.9%
#6457: fix(telegram): register commands for group scope + preserve topic t...
by dae-sun · 2026-02-01
75.0%
#22331: Fix Telegram reaction emoji normalization
by AIflow-Labs · 2026-02-21
72.5%
#11347: fix: scope Telegram update offset to bot token
by anooprdawar · 2026-02-07
72.4%
#14991: fix(telegram): deduplicate skill commands by skillName to prevent B...
by smartchainark · 2026-02-12
72.3%
#19213: Telegram: preserve DM topic thread in direct replies
by Kemalau · 2026-02-17
72.2%
#20170: fix(irc): add configurable commandPrefix to avoid IRC reserved / pr...
by yxshee · 2026-02-18
71.6%
#11340: Telegram: skip empty message text instead of throwing (#11238)
by lailoo · 2026-02-07
71.5%
#19375: telegram: align tool-error summaries
by NorthyIE · 2026-02-17
71.5%