fix: format IRC ACTION messages as * nick action * and strip CTCP delimiters

CTCP ACTION messages (/me) were relayed with raw \x01 bytes, rendering
as boxed-X characters in OwnCast. Detect the ACTION pattern, extract the
body, and format it like traditional IRC clients. Also strip \x01 in
irc_format as a safety net for other CTCP leakage.

Made-with: Cursor
This commit is contained in:
cottongin
2026-03-12 16:37:46 -04:00
parent b0236ee52b
commit e2fbd52009
7 changed files with 112 additions and 9 deletions

View File

@@ -0,0 +1,20 @@
# IRC ACTION Message Formatting Fix
## Task
Fix IRC CTCP ACTION messages (`/me` commands) displaying as `[IRC] <cottongin> ☒ACTION sniffs☒` in OwnCast. The `\x01` CTCP delimiters were rendering as boxed X characters, and the ACTION keyword was not being parsed.
## Changes Made
- **`src/events.rs`**: Added `is_action: bool` field to `BridgeEvent::ChatMessage` variant.
- **`src/irc_task.rs`**: Added `parse_ctcp_action()` function to detect `\x01ACTION ...\x01` pattern, extract the action body, and set `is_action: true`. Added 5 unit tests.
- **`src/router.rs`**: Updated formatting for both IRC-to-OwnCast and OwnCast-to-IRC directions to use `* username body *` format when `is_action` is true.
- **`src/irc_format.rs`**: Added `\x01` to the stripped control codes as a safety net for any non-ACTION CTCP leakage. Added 2 unit tests.
- **`src/webhook.rs`**: Added `is_action: false` to OwnCast-origin ChatMessage constructor; updated test destructure.
- **`src/websocket.rs`**: Added `is_action: false` to OwnCast-origin ChatMessage constructor.
## Result
- Before: `[IRC] <cottongin> ☒ACTION sniffs☒`
- After: `[IRC] * cottongin sniffs *`
## Follow-up
- None identified. All 55 tests pass.