core: add oper MODULES command (702/703) listing loaded modules; module.list RPC already existed
This commit is contained in:
parent
4357a59c7a
commit
70a4ecb0a0
2 changed files with 25 additions and 0 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue