feat: strip IRC formatting codes from messages sent to Owncast

Add irc_format module that removes mIRC control codes (bold, color,
italic, underline, reverse, strikethrough, monospace, reset) before
forwarding to Owncast. Color codes with fg/bg digit params are
consumed correctly. Multi-byte UTF-8 (emoji, accented chars, CJK)
is preserved.

Made-with: Cursor
This commit is contained in:
cottongin
2026-03-12 14:07:01 -04:00
parent 196997f728
commit 65471fb9fc
4 changed files with 184 additions and 3 deletions

View File

@@ -3,6 +3,7 @@ mod control;
mod events;
mod health;
mod html;
mod irc_format;
mod irc_task;
mod owncast_api;
mod router;
@@ -69,11 +70,15 @@ async fn main() -> anyhow::Result<()> {
});
let _ws_handle = if config.owncast.websocket_enabled {
let ws_url = config.owncast.url.clone();
let ws_api = owncast_api::OwncastApiClient::new(
config.owncast.url.clone(),
String::new(),
);
let ws_display_name = config.owncast.ws_display_name.clone();
let ws_event_tx = event_tx.clone();
let ws_shutdown = shutdown_rx.clone();
Some(tokio::spawn(async move {
websocket::run_websocket_task(ws_url, ws_event_tx, ws_shutdown).await;
websocket::run_websocket_task(ws_api, ws_display_name, ws_event_tx, ws_shutdown).await;
}))
} else {
None