implement admin commands

This commit is contained in:
dusk 2025-10-04 01:57:48 +00:00
parent 5198f7d83b
commit a268f75d32
No known key found for this signature in database
15 changed files with 263 additions and 287 deletions

View file

@ -1 +1,64 @@
use super::*;
pub fn admin() -> &'static str {
"admin"
}
pub fn cmds() -> impl Iterator<Item = Command> {
let admin = admin();
let abuselog = tokens!(admin, ("abuselog", ["al"]));
let make_abuselog_cmds = |log_param: Parameter| {
[
command!(abuselog, ("show", ["s"]), log_param => format!("admin_abuselog_show_{}", log_param.name()))
.help("Shows an abuse log entry"),
command!(abuselog, ("flagdeny", ["fd"]), log_param, Optional(("value", Toggle)) => format!("admin_abuselog_flag_deny_{}", log_param.name()))
.help("Sets the deny flag on an abuse log entry"),
command!(abuselog, ("description", ["desc"]), log_param, Optional(("desc", OpaqueStringRemainder)) => format!("admin_abuselog_description_{}", log_param.name()))
.flag(("clear", ["c"]))
.help("Sets the description of an abuse log entry"),
command!(abuselog, ("adduser", ["au"]), log_param => format!("admin_abuselog_add_user_{}", log_param.name()))
.help("Adds a user to an abuse log entry"),
command!(abuselog, ("removeuser", ["ru"]), log_param => format!("admin_abuselog_remove_user_{}", log_param.name()))
.help("Removes a user from an abuse log entry"),
command!(abuselog, ("delete", ["d"]), log_param => format!("admin_abuselog_delete_{}", log_param.name()))
.help("Deletes an abuse log entry"),
].into_iter()
};
let abuselog_cmds = [
command!(abuselog, ("create", ["c", "new"]), ("account", UserRef), Optional(("description", OpaqueStringRemainder)) => "admin_abuselog_create")
.flag(("deny-boy-usage", ["deny"]))
.help("Creates an abuse log entry")
]
.into_iter()
.chain(make_abuselog_cmds(Skip(("account", UserRef)).into())) // falls through to log_id
.chain(make_abuselog_cmds(("log_id", OpaqueString).into()));
[
command!(admin, ("updatesystemid", ["usid"]), SystemRef, ("new_hid", OpaqueString) => "admin_update_system_id")
.help("Updates a system's ID"),
command!(admin, ("updatememberid", ["umid"]), MemberRef, ("new_hid", OpaqueString) => "admin_update_member_id")
.help("Updates a member's ID"),
command!(admin, ("updategroupid", ["ugid"]), GroupRef, ("new_hid", OpaqueString) => "admin_update_group_id")
.help("Updates a group's ID"),
command!(admin, ("rerollsystemid", ["rsid"]), SystemRef => "admin_reroll_system_id")
.help("Rerolls a system's ID"),
command!(admin, ("rerollmemberid", ["rmid"]), MemberRef => "admin_reroll_member_id")
.help("Rerolls a member's ID"),
command!(admin, ("rerollgroupid", ["rgid"]), GroupRef => "admin_reroll_group_id")
.help("Rerolls a group's ID"),
command!(admin, ("updatememberlimit", ["uml"]), SystemRef, Optional(("limit", OpaqueInt)) => "admin_system_member_limit")
.help("Updates a system's member limit"),
command!(admin, ("updategrouplimit", ["ugl"]), SystemRef, Optional(("limit", OpaqueInt)) => "admin_system_group_limit")
.help("Updates a system's group limit"),
command!(admin, ("systemrecover", ["sr"]), ("token", OpaqueString), ("account", UserRef) => "admin_system_recover")
.flag(("reroll-token", ["rt"]))
.help("Recovers a system"),
command!(admin, ("systemdelete", ["sd"]), SystemRef => "admin_system_delete")
.help("Deletes a system"),
command!(admin, ("sendmessage", ["sendmsg"]), ("account", UserRef), ("content", OpaqueStringRemainder) => "admin_send_message")
.help("Sends a message to a user"),
]
.into_iter()
.chain(abuselog_cmds)
}

View file

@ -5,9 +5,7 @@ pub fn cmds() -> impl Iterator<Item = Command> {
[
command!(("dashboard", ["dash"]) => "dashboard"),
command!("explain" => "explain"),
command!(help => "help")
.flag(("foo", OpaqueString)) // todo: just for testing
.help("Shows the help command"),
command!(help => "help").help("Shows the help command"),
command!(help, "commands" => "help_commands").help("help commands"),
command!(help, "proxy" => "help_proxy").help("help proxy"),
]

View file

@ -3,7 +3,6 @@ pub mod api;
pub mod autoproxy;
pub mod commands;
pub mod config;
pub mod dashboard;
pub mod debug;
pub mod fun;
pub mod group;
@ -40,10 +39,12 @@ pub fn all() -> impl Iterator<Item = Command> {
.chain(debug::cmds())
.chain(message::cmds())
.chain(import_export::cmds())
.chain(admin::cmds())
.map(|cmd| {
cmd.hidden_flag(("plaintext", ["pt"]))
.hidden_flag(("raw", ["r"]))
.hidden_flag(("show-embed", ["se"]))
.hidden_flag(("by-id", ["id"]))
})
}

View file

@ -25,7 +25,7 @@ pub fn cmds() -> impl Iterator<Item = Command> {
.help("Deletes a proxied message"),
apply_edit(command!(message, edit => "message_edit")),
apply_edit(command!(edit => "message_edit")),
command!(("reproxy", ["rp", "crimes", "crime"]), MessageRef => "message_reproxy")
command!(("reproxy", ["rp", "crimes", "crime"]), ("msg", MessageRef), ("member", MemberRef) => "message_reproxy")
.help("Reproxies a message with a different member"),
]
.into_iter()