← Back to PRs

#20170: fix(irc): add configurable commandPrefix to avoid IRC reserved / prefix (#20127)

by yxshee open 2026-02-18 16:16 View on GitHub →
channel: irc size: S
## Problem IRC servers reserve the `/` prefix for native commands (e.g. `/join`, `/nick`). OpenClaw's command parser hardcoded `/` as the only valid prefix, so commands like `/status` were intercepted by the IRC client and never reached the bot. Fixes #20127 ## Solution Added a configurable `commandPrefix` option to the IRC extension, defaulting to `!` (the standard IRC bot convention). Messages starting with the configured prefix are normalized to canonical `/` form before entering the existing command pipeline — no changes to command definitions needed. ## Changes - **`extensions/irc/src/config-schema.ts`** — Add `commandPrefix` field (1–3 chars, optional) to Zod schema - **`extensions/irc/src/types.ts`** — Add `commandPrefix` to `IrcAccountConfig` type - **`src/auto-reply/commands-registry.types.ts`** — Add `commandPrefix` to `CommandNormalizeOptions` - **`src/auto-reply/commands-registry.ts`** — `normalizeCommandBody()` normalizes custom prefix → `/` before further processing - **`extensions/irc/src/inbound.ts`** — Read `commandPrefix` from account config (default `!`), pass to `hasControlCommand()` and pre-normalize `CommandBody` for the reply pipeline - **`src/config/schema.irc.ts`** — Add field label and help text for `commandPrefix` ## Configuration ```yaml channels: irc: commandPrefix: "!" # default; configurable 1-3 chars (e.g. "!", "~", ">>") ``` ## Tests - 9 new tests in `commands-registry.test.ts` for prefix-aware `normalizeCommandBody()` - 1 new test in `command-control.test.ts` for `hasControlCommand()` with `commandPrefix` - All 47 tests pass ✅ ## Notes Model persistence across transports (the second part of #20127) is deferred — it requires a separate design discussion around session identity management. <!-- greptile_comment --> <h3>Greptile Summary</h3> Adds a configurable `commandPrefix` option to the IRC extension so bot commands can use `!` (or any 1–3 character prefix) instead of `/`, which is reserved by IRC clients for native commands. The implementation normalizes custom-prefixed messages to canonical `/` form early in the inbound pipeline, allowing the entire downstream command processing (detection, resolution, abort handling) to work unchanged. - `normalizeCommandBody()` in `commands-registry.ts` gains `commandPrefix` support, converting transport-specific prefixes to `/` before existing alias/colon/mention normalization - IRC `inbound.ts` reads `commandPrefix` from account config (default `!`), passes it to `hasControlCommand()`, and pre-normalizes `CommandBody` for the reply pipeline - Zod schema, TypeScript type, and config UI labels/help text updated for the new field - 10 new tests covering prefix-aware normalization and command detection with custom prefixes <h3>Confidence Score: 4/5</h3> - This PR is safe to merge with minimal risk — changes are well-scoped and backward compatible. - The implementation is clean and follows existing patterns (similar to Telegram's botUsername normalization). The prefix normalization is applied early in the pipeline, the downstream command processing works unchanged, and there are comprehensive tests. The Zod schema properly validates the input. No breaking changes to existing behavior (default prefix for IRC changes from `/` to `!`, but this is the fix — `/` was broken on IRC). - No files require special attention. `extensions/irc/src/inbound.ts` has a minor style concern with duplicated normalization logic, but it's intentional and correct. <sub>Last reviewed commit: 15640a3</sub> <!-- greptile_other_comments_section --> <sub>(4/5) You can add custom instructions or style guidelines for the agent [here](https://app.greptile.com/review/github)!</sub> <!-- /greptile_comment -->

Most Similar PRs