diff --git a/echoircd.conf.example b/echoircd.conf.example index 4741162..eefaa9f 100644 --- a/echoircd.conf.example +++ b/echoircd.conf.example @@ -117,6 +117,9 @@ amu_target = both # hidewhois_hide_server = yes # hide 312 # hidewhois_hide_idle = yes # hide 317 # 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 # ban `+b $<#channel>` bounces a matching user into #channel instead of # refusing them, e.g. /MODE #main +b *!*@*.spammer.net$#quarantine diff --git a/src/modules/chanlog.rs b/src/modules/chanlog.rs new file mode 100644 index 0000000..3ea7de7 --- /dev/null +++ b/src/modules/chanlog.rs @@ -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 = ch.members.keys().copied().collect(); + for u in members { + s.send(u, line.clone()); + } +} diff --git a/src/modules/mod.rs b/src/modules/mod.rs index adee0cb..cb82e91 100644 --- a/src/modules/mod.rs +++ b/src/modules/mod.rs @@ -10,6 +10,7 @@ pub mod banredirect; pub mod blockamsg; pub mod channames; pub mod channelban; +pub mod chanlog; pub mod chathistory; pub mod cloak; pub mod cloudflare_challenge; diff --git a/src/server.rs b/src/server.rs index a8d4e68..00f220f 100644 --- a/src/server.rs +++ b/src/server.rs @@ -729,6 +729,7 @@ impl Server { for o in opers { self.deliver_server_notice(o, msg, &jval); } + crate::modules::chanlog::tee(self, msg); } /// Broadcast a `*** msg` server NOTICE to *every* registered local user — for