OperServ: MODE override and KICK
Two channel operator tools: - MODE <#chan> <modes> [params] forces a channel mode change (TS 1, so it applies regardless of the current TS). A status-mode target may be given as a nick — it's resolved to the uid the ircd's FMODE expects. - KICK <#chan> <nick> [reason] removes a user, sourced from OperServ and attributed to the operator. Both admin-gated. To resolve status-mode params, channel-mode parameter arity became one shared helper (chanmode_takes_param + STATUS_MODES in the api): the ircd module now delegates to it instead of keeping its own copy, so burst-parsing and MODE-building can never drift.
This commit is contained in:
parent
930198b826
commit
c5d93f29c1
6 changed files with 147 additions and 11 deletions
26
operserv/src/kick.rs
Normal file
26
operserv/src/kick.rs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
use fedserv_api::{NetView, Priv, Sender, ServiceCtx};
|
||||
|
||||
// KICK <#channel> <nick> [reason]: remove a user from a channel, sourced from
|
||||
// OperServ so it's clearly a staff action. 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 — KICK needs the \x02admin\x02 privilege.");
|
||||
return;
|
||||
}
|
||||
let Some(&chan) = args.get(1).filter(|c| c.starts_with('#') || c.starts_with('&')) else {
|
||||
ctx.notice(me, from.uid, "Syntax: KICK <#channel> <nick> [reason]");
|
||||
return;
|
||||
};
|
||||
let Some(&target) = args.get(2) else {
|
||||
ctx.notice(me, from.uid, "Syntax: KICK <#channel> <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() > 3 { args[3..].join(" ") } else { "Removed by services".to_string() };
|
||||
ctx.kick(me, chan, &uid, &format!("({by}) {reason}"));
|
||||
ctx.notice(me, from.uid, format!("\x02{target}\x02 kicked from \x02{chan}\x02."));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue