chanlog: mirror the oper server-notice stream into a configured channel

This commit is contained in:
Jean Chevronnet 2026-08-09 23:19:29 +00:00
parent 1a53c5ae5a
commit 87e3d5436d
4 changed files with 28 additions and 0 deletions

View file

@ -117,6 +117,9 @@ amu_target = both
# hidewhois_hide_server = yes # hide 312 # hidewhois_hide_server = yes # hide 312
# hidewhois_hide_idle = yes # hide 317 # hidewhois_hide_idle = yes # hide 317
# hidewhois_hide_secure = yes # hide 671 # hidewhois_hide_secure = yes # hide 671
# --- chanlog (m_chanlog): mirror the oper server-notice stream into a channel so
# staff can watch it in a normal window. Set the channel (create/keep it opped):
# chanlog = #snotices
# --- banredirect (m_banredirect): no config needed — it extends ban syntax. A # --- banredirect (m_banredirect): no config needed — it extends ban syntax. A
# ban `+b <mask>$<#channel>` bounces a matching user into #channel instead of # ban `+b <mask>$<#channel>` bounces a matching user into #channel instead of
# refusing them, e.g. /MODE #main +b *!*@*.spammer.net$#quarantine # refusing them, e.g. /MODE #main +b *!*@*.spammer.net$#quarantine

23
src/modules/chanlog.rs Normal file
View file

@ -0,0 +1,23 @@
//! chanlog — mirror server notices (the `snotice` stream opers see with +s) into a
//! channel, so staff can watch the log in a normal channel window. Off unless
//! `chanlog = #channel` is configured. Reference: InspIRCd's `m_chanlog`.
//! Original native Rust.
use crate::server::Server;
use crate::Uid;
/// Tee `msg` to the configured chanlog channel (if set and it exists). Called at
/// the tail of `Server::snotice`. Read-only over server state, so it can't loop.
pub fn tee(s: &Server, msg: &str) {
let Some(chan) = s.conf("chanlog") else {
return;
};
let Some(ch) = s.channels.get(&chan.to_ascii_lowercase()) else {
return; // channel not created yet — nothing to log into
};
let line = format!(":{} NOTICE {chan} :{msg}", s.name);
let members: Vec<Uid> = ch.members.keys().copied().collect();
for u in members {
s.send(u, line.clone());
}
}

View file

@ -10,6 +10,7 @@ pub mod banredirect;
pub mod blockamsg; pub mod blockamsg;
pub mod channames; pub mod channames;
pub mod channelban; pub mod channelban;
pub mod chanlog;
pub mod chathistory; pub mod chathistory;
pub mod cloak; pub mod cloak;
pub mod cloudflare_challenge; pub mod cloudflare_challenge;

View file

@ -729,6 +729,7 @@ impl Server {
for o in opers { for o in opers {
self.deliver_server_notice(o, msg, &jval); self.deliver_server_notice(o, msg, &jval);
} }
crate::modules::chanlog::tee(self, msg);
} }
/// Broadcast a `*** msg` server NOTICE to *every* registered local user — for /// Broadcast a `*** msg` server NOTICE to *every* registered local user — for