UP re-applies the op/voice status your channel access entitles you to; DOWN removes your status. Mirrors the OP/VOICE command's access check and mode emission, and requires you to actually be in the channel.
This commit is contained in:
parent
98ecbca414
commit
959d085e7a
3 changed files with 71 additions and 0 deletions
|
|
@ -9,6 +9,8 @@ mod access;
|
|||
mod flags;
|
||||
#[path = "op.rs"]
|
||||
mod op;
|
||||
#[path = "updown.rs"]
|
||||
mod updown;
|
||||
#[path = "kick.rs"]
|
||||
mod kick;
|
||||
#[path = "ban.rs"]
|
||||
|
|
@ -55,6 +57,7 @@ const TOPICS: &[HelpEntry] = &[
|
|||
HelpEntry { cmd: "AOP/SOP/VOP", summary: "tiered access shortcuts", detail: "Syntax: \x02AOP|SOP|VOP <#channel> ADD <account> | DEL <account> | LIST\x02\nTiered shortcuts over ACCESS: AOP and SOP grant op, VOP grants voice." },
|
||||
HelpEntry { cmd: "STATUS", summary: "show a user's access", detail: "Syntax: \x02STATUS <#channel> [nick]\x02\nShows a user's access level on a channel." },
|
||||
HelpEntry { cmd: "OP/DEOP/VOICE/DEVOICE", summary: "give or take op/voice", detail: "Syntax: \x02OP|DEOP|VOICE|DEVOICE <#channel> [nick]\x02\nGives or takes channel op or voice." },
|
||||
HelpEntry { cmd: "UP/DOWN", summary: "apply or drop your status", detail: "Syntax: \x02UP|DOWN <#channel>\x02\nUP re-applies the op/voice your access entitles you to; DOWN removes your status." },
|
||||
HelpEntry { cmd: "KICK", summary: "kick from the channel", detail: "Syntax: \x02KICK <#channel> <nick> [reason]\x02\nKicks a user from the channel." },
|
||||
HelpEntry { cmd: "BAN/UNBAN", summary: "ban or unban a user", detail: "Syntax: \x02BAN <#channel> <nick> [reason]\x02, \x02UNBAN <#channel> [nick]\x02\nBans or unbans a user by host." },
|
||||
HelpEntry { cmd: "AKICK", summary: "manage the auto-kick list", detail: "Syntax: \x02AKICK <#channel> ADD <mask> [reason] | DEL <mask> | LIST\x02\nManages the auto-kick list; matches are banned and kicked on join." },
|
||||
|
|
@ -250,6 +253,8 @@ impl Service for ChanServ {
|
|||
Some("DEOP") => op::handle(me, from, "-o", args, ctx, net, db),
|
||||
Some("VOICE") => op::handle(me, from, "+v", args, ctx, net, db),
|
||||
Some("DEVOICE") => op::handle(me, from, "-v", args, ctx, net, db),
|
||||
Some("UP") => updown::handle(me, from, true, args, ctx, net, db),
|
||||
Some("DOWN") => updown::handle(me, from, false, args, ctx, net, db),
|
||||
Some("KICK") => kick::handle(me, from, args, ctx, net, db),
|
||||
Some("BAN") => ban::handle(me, from, args, ctx, net, db),
|
||||
Some("UNBAN") => unban::handle(me, from, args, ctx, net, db),
|
||||
|
|
|
|||
35
modules/chanserv/src/updown.rs
Normal file
35
modules/chanserv/src/updown.rs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
use echo_api::{NetView, Sender, ServiceCtx, Store};
|
||||
|
||||
// UP <#channel>: (re)apply the status mode your access entitles you to.
|
||||
// DOWN <#channel>: drop your channel status modes. `up` selects which.
|
||||
pub fn handle(me: &str, from: &Sender, up: bool, args: &[&str], ctx: &mut ServiceCtx, net: &dyn NetView, db: &dyn Store) {
|
||||
let Some(&chan) = args.get(1) else {
|
||||
ctx.notice(me, from.uid, if up { "Syntax: UP <#channel>" } else { "Syntax: DOWN <#channel>" });
|
||||
return;
|
||||
};
|
||||
let Some(account) = from.account else {
|
||||
ctx.notice(me, from.uid, "You need to be logged in. Identify to NickServ first.");
|
||||
return;
|
||||
};
|
||||
let Some(info) = db.channel(chan) else {
|
||||
ctx.notice(me, from.uid, format!("\x02{chan}\x02 isn't registered."));
|
||||
return;
|
||||
};
|
||||
if !net.channel_members(chan).iter().any(|u| u.as_str() == from.uid) {
|
||||
ctx.notice(me, from.uid, format!("You're not in \x02{chan}\x02."));
|
||||
return;
|
||||
}
|
||||
if up {
|
||||
match info.join_mode(account) {
|
||||
Some(mode) => {
|
||||
ctx.channel_mode(me, chan, &format!("{mode} {}", from.uid));
|
||||
ctx.notice(me, from.uid, format!("Your status in \x02{chan}\x02 has been applied."));
|
||||
}
|
||||
None => ctx.notice(me, from.uid, format!("You have no status access in \x02{chan}\x02.")),
|
||||
}
|
||||
} else {
|
||||
// Strip op and voice; the ircd ignores any mode you don't currently hold.
|
||||
ctx.channel_mode(me, chan, &format!("-ov {} {}", from.uid, from.uid));
|
||||
ctx.notice(me, from.uid, format!("Your status in \x02{chan}\x02 has been removed."));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue