core: add oper MODULES command (702/703) listing loaded modules; module.list RPC already existed

This commit is contained in:
Jean Chevronnet 2026-08-22 17:36:46 +00:00
parent 4357a59c7a
commit 70a4ecb0a0
No known key found for this signature in database
GPG key ID: 439666D63A9477E4
2 changed files with 25 additions and 0 deletions

View file

@ -16,6 +16,7 @@ pub fn commands() -> Vec<Box<dyn Command>> {
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 {

View file

@ -101,6 +101,8 @@ pub const RPL_WHOISMODES: u16 = 379; // oper/self-only: "is using modes +<umodes
pub const RPL_SNOMASKIS: u16 = 8; // "+<mask> :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