← Back to PRs

#18704: fix(telegram): normalize command names by replacing hyphens with underscores

by Limitless2023 open 2026-02-17 00:18 View on GitHub →
channel: telegram stale size: XS
## Summary Telegram bot command names must match `/^[a-z0-9_]{1,32}$/` (only lowercase letters, numbers, and underscores). The `export-session` native command (introduced in add3afb7) contains a hyphen, causing `setMyCommands` to fail with `400 Bad Request: BOT_COMMAND_INVALID`. This PR normalizes all native command names by replacing hyphens with underscores before registering them with Telegram's Bot API, making `export-session` accessible as `/export_session`. ## Context **This is a regression fix introduced in commit add3afb7 (2026-02-17).** - **Affected**: Users running from `main` branch (developers using `pnpm dev`) - **Not affected**: Stable release users (v2026.2.15 and earlier) - **Impact**: Command registration fails completely, preventing all Telegram commands from appearing in the bot menu Without this fix, the next stable release would ship with broken Telegram command registration. ## Changes - **Menu registration**: Convert hyphens to underscores when building `allCommandsFull` for Telegram command menu - **Handler registration**: Use normalized command name when registering bot command handlers - **Prompt building**: Use normalized command name in generated prompts for consistency ## Why normalize at registration time? Instead of renaming `export-session` to `export_session` in the command registry, normalization at registration: - ✅ Prevents future issues if other hyphenated commands are added - ✅ Keeps command IDs consistent across providers (other channels may allow hyphens) - ✅ Maintains backward compatibility with existing command definitions - ✅ Localizes the fix to Telegram-specific code ## Testing - [x] Code builds without errors - [x] All 457 Telegram tests pass - [ ] Manual test: verify `/export_session` command registers and works in Telegram ## Fixes Closes #18683 ## AI-assisted Yes - AI-assisted with human review

Most Similar PRs