Rebrand the daemon and workspace: the binary is now `echo`, every crate is `echo-*` (`echo-api` and the module crates), Rust imports use `echo_*`, the gRPC proto is `proto/echo.proto` with package `echo.v1`, and the log filter, gossip peer-name default, and on-disk store default (`echo.db.jsonl`) follow. Docs updated throughout. No behaviour change; crate directories and the config schema are untouched.
21 lines
969 B
Rust
21 lines
969 B
Rust
use echo_api::{NetView, Priv, Sender, ServiceCtx};
|
|
|
|
// KILL <nick> [reason]: disconnect a user from the network. Admin-only.
|
|
pub fn handle(me: &str, from: &Sender, args: &[&str], ctx: &mut ServiceCtx, net: &dyn NetView) {
|
|
if !from.privs.has(Priv::Admin) {
|
|
ctx.notice(me, from.uid, "Access denied — KILL needs the \x02admin\x02 privilege.");
|
|
return;
|
|
}
|
|
let Some(&target) = args.get(1) else {
|
|
ctx.notice(me, from.uid, "Syntax: KILL <nick> [reason]");
|
|
return;
|
|
};
|
|
let Some(uid) = net.uid_by_nick(target).map(str::to_string) else {
|
|
ctx.notice(me, from.uid, format!("There's no \x02{target}\x02 online."));
|
|
return;
|
|
};
|
|
let by = from.account.unwrap_or(from.nick);
|
|
let reason = if args.len() > 2 { args[2..].join(" ") } else { "No reason given".to_string() };
|
|
ctx.kill(me, &uid, &format!("({by}) {reason}"));
|
|
ctx.notice(me, from.uid, format!("\x02{target}\x02 has been disconnected."));
|
|
}
|