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 {