From 70a4ecb0a0aafac847c13bd4ae2c4121483c6048 Mon Sep 17 00:00:00 2001 From: reverse Date: Sat, 22 Aug 2026 17:36:46 +0000 Subject: [PATCH] core: add oper MODULES command (702/703) listing loaded modules; module.list RPC already existed --- src/coremods/core_extra.rs | 23 +++++++++++++++++++++++ src/numeric.rs | 2 ++ 2 files changed, 25 insertions(+) diff --git a/src/coremods/core_extra.rs b/src/coremods/core_extra.rs index d5f863e..43dae82 100644 --- a/src/coremods/core_extra.rs +++ b/src/coremods/core_extra.rs @@ -16,6 +16,7 @@ pub fn commands() -> Vec> { Box::new(Time), Box::new(Admin), Box::new(Info), + Box::new(Modules), Box::new(Stats), Box::new(Map), Box::new(Help), @@ -273,6 +274,28 @@ impl Command for Info { } } +struct Modules; +impl Command for Modules { + fn name(&self) -> &'static str { + "MODULES" + } + fn handle(&self, s: &mut Server, uid: Uid, _params: &[String]) -> CmdResult { + if !s.is_oper(uid) { + s.numeric( + uid, + ERR_NOPRIVILEGES, + ":Permission Denied- You're not an IRC operator", + ); + return CmdResult::Fail; + } + for name in crate::modules::module_names() { + s.numeric(uid, RPL_MODLIST, &format!("{name} :loaded")); + } + s.numeric(uid, RPL_ENDOFMODLIST, ":End of MODULES list"); + CmdResult::Ok + } +} + struct Stats; impl Command for Stats { fn name(&self) -> &'static str { diff --git a/src/numeric.rs b/src/numeric.rs index 0e52ca9..38eb2eb 100644 --- a/src/numeric.rs +++ b/src/numeric.rs @@ -101,6 +101,8 @@ pub const RPL_WHOISMODES: u16 = 379; // oper/self-only: "is using modes + :Server notice mask" after a +s change pub const ERR_NEEDREGGEDNICK: u16 = 477; // chan +R/+M — must be logged into an account pub const RPL_WHOISHOST: u16 = 378; // oper-only: real host/ip behind a cloak +pub const RPL_MODLIST: u16 = 702; // /MODULES entry +pub const RPL_ENDOFMODLIST: u16 = 703; // /MODULES terminator pub const RPL_HELPSTART: u16 = 704; // /HELP first line pub const RPL_HELPTXT: u16 = 705; // /HELP body line pub const RPL_ENDOFHELP: u16 = 706; // /HELP terminator