From 2858c68a7d5a96c83f59347200871756e268ac79 Mon Sep 17 00:00:00 2001 From: spiral Date: Thu, 19 Nov 2020 17:10:59 -0500 Subject: [PATCH 1/4] Clean up member list commands and log commands, as well as related docs --- PluralKit.Bot/Commands/CommandTree.cs | 9 +++++---- docs/content/command-list.md | 1 + docs/content/staff/logging.md | 6 +++--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/PluralKit.Bot/Commands/CommandTree.cs b/PluralKit.Bot/Commands/CommandTree.cs index f0c825b9..ff220c56 100644 --- a/PluralKit.Bot/Commands/CommandTree.cs +++ b/PluralKit.Bot/Commands/CommandTree.cs @@ -71,6 +71,7 @@ namespace PluralKit.Bot public static Command Explain = new Command("explain", "explain", "Explains the basics of systems and proxying"); public static Command Message = new Command("message", "message ", "Looks up a proxied message"); public static Command LogChannel = new Command("log channel", "log channel ", "Designates a channel to post proxied messages to"); + public static Command LogChannelClear = new Command("log channel", "log channel -clear", "Clears the currently set log channel"); public static Command LogEnable = new Command("log enable", "log enable all| [channel 2] [channel 3...]", "Enables message logging in certain channels"); public static Command LogDisable = new Command("log disable", "log disable all| [channel 2] [channel 3...]", "Disables message logging in certain channels"); public static Command LogClean = new Command("logclean", "logclean [on|off]", "Toggles whether to clean up other bots' log channels"); @@ -105,7 +106,7 @@ namespace PluralKit.Bot public static Command[] SwitchCommands = {Switch, SwitchOut, SwitchMove, SwitchDelete}; - public static Command[] LogCommands = {LogChannel, LogEnable, LogDisable}; + public static Command[] LogCommands = {LogChannel, LogChannelClear, LogEnable, LogDisable}; private DiscordShardedClient _client; @@ -127,10 +128,8 @@ namespace PluralKit.Bot return HandleSwitchCommand(ctx); if (ctx.Match("ap", "autoproxy", "auto")) return ctx.Execute(Autoproxy, m => m.AutoproxyRoot(ctx)); - if (ctx.Match("list", "l", "members")) + if (ctx.Match("list", "find", "members", "search", "query", "l", "f", "fd")) return ctx.Execute(SystemList, m => m.MemberList(ctx, ctx.System)); - if (ctx.Match("f", "find", "search", "query", "fd")) - return ctx.Execute(SystemFind, m => m.MemberList(ctx, ctx.System)); if (ctx.Match("link")) return ctx.Execute(Link, m => m.LinkSystem(ctx)); if (ctx.Match("unlink")) @@ -163,6 +162,8 @@ namespace PluralKit.Bot return ctx.Execute(LogEnable, m => m.SetLogEnabled(ctx, true)); else if (ctx.Match("disable", "off")) return ctx.Execute(LogDisable, m => m.SetLogEnabled(ctx, false)); + else if (ctx.Match("commands")) + return PrintCommandList(ctx, "message logging", LogCommands); else return PrintCommandExpectedError(ctx, LogCommands); if (ctx.Match("logclean")) return ctx.Execute(LogClean, m => m.SetLogCleanup(ctx)); diff --git a/docs/content/command-list.md b/docs/content/command-list.md index 782af0dd..7cc6fc8c 100644 --- a/docs/content/command-list.md +++ b/docs/content/command-list.md @@ -81,6 +81,7 @@ Words in **\** or **[square brackets]** mean fill-in-the-blank. ## Server owner commands *(all commands here require Manage Server permission)* - `pk;log channel ` - Sets the given channel to log all proxied messages. +- `pk;log channel -clear` - Clears the currently set log channel. - `pk;log disable <#channel> [#channel...]` - Disables logging messages posted in the given channel(s) (useful for staff channels and such). - `pk;log enable <#channel> [#channel...]` - Re-enables logging messages posted in the given channel(s). - `pk;logclean ` - Enables or disables [log cleanup](./staff/compatibility.md#log-cleanup). diff --git a/docs/content/staff/logging.md b/docs/content/staff/logging.md index 673f5766..ea39c64a 100644 --- a/docs/content/staff/logging.md +++ b/docs/content/staff/logging.md @@ -1,9 +1,9 @@ # Proxy logging -If you want to log every proxied message to a separate channel for moderation purposes, you can use the `pk;log` command with the channel name.For example: +If you want to log every proxied message to a separate channel for moderation purposes, you can use the `pk;log channel` command with the channel name.For example: - pk;log #proxy-log + pk;log channel #proxy-log -This requires you to have the *Manage Server* permission on the server. To disable logging, use the `pk;log` command with no channel name. +This requires you to have the *Manage Server* permission on the server. To disable logging, use the `pk;log channel` command with the `-clear` flag as the channel name. Log messages have the following format: From 9babde3c82aa6a73040fb1dd90f745c70266e2c4 Mon Sep 17 00:00:00 2001 From: spiral Date: Thu, 19 Nov 2020 17:58:57 -0500 Subject: [PATCH 2/4] Add basic command help functionality to pk;commands --- PluralKit.Bot/Commands/CommandTree.cs | 55 +++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 3 deletions(-) diff --git a/PluralKit.Bot/Commands/CommandTree.cs b/PluralKit.Bot/Commands/CommandTree.cs index ff220c56..e6b79377 100644 --- a/PluralKit.Bot/Commands/CommandTree.cs +++ b/PluralKit.Bot/Commands/CommandTree.cs @@ -107,6 +107,8 @@ namespace PluralKit.Bot public static Command[] SwitchCommands = {Switch, SwitchOut, SwitchMove, SwitchDelete}; public static Command[] LogCommands = {LogChannel, LogChannelClear, LogEnable, LogDisable}; + + public static Command[] BlacklistCommands = {BlacklistAdd, BlacklistRemove, BlacklistShow}; private DiscordShardedClient _client; @@ -126,6 +128,8 @@ namespace PluralKit.Bot return HandleGroupCommand(ctx); if (ctx.Match("switch", "sw")) return HandleSwitchCommand(ctx); + if (ctx.Match("commands")) + return CommandHelpRoot(ctx); if (ctx.Match("ap", "autoproxy", "auto")) return ctx.Execute(Autoproxy, m => m.AutoproxyRoot(ctx)); if (ctx.Match("list", "find", "members", "search", "query", "l", "f", "fd")) @@ -151,8 +155,6 @@ namespace PluralKit.Bot else return ctx.Execute(Help, m => m.HelpRoot(ctx)); if (ctx.Match("explain")) return ctx.Execute(Explain, m => m.Explain(ctx)); - if (ctx.Match("commands")) - return ctx.Reply("For the list of commands, see the website: "); if (ctx.Match("message", "msg")) return ctx.Execute(Message, m => m.GetMessage(ctx)); if (ctx.Match("log")) @@ -174,7 +176,9 @@ namespace PluralKit.Bot return ctx.Execute(BlacklistRemove, m => m.SetBlacklisted(ctx, false)); else if (ctx.Match("list", "show")) return ctx.Execute(BlacklistShow, m => m.ShowBlacklisted(ctx)); - else return PrintCommandExpectedError(ctx, BlacklistAdd, BlacklistRemove, BlacklistShow); + else if (ctx.Match("commands")) + return PrintCommandList(ctx, "channel blacklisting", BlacklistCommands); + else return PrintCommandExpectedError(ctx, BlacklistCommands); if (ctx.Match("proxy", "enable", "disable")) return ctx.Execute(SystemProxy, m => m.SystemProxy(ctx)); if (ctx.Match("invite")) return ctx.Execute(Invite, m => m.Invite(ctx)); @@ -404,6 +408,51 @@ namespace PluralKit.Bot await PrintCommandNotFoundError(ctx, Switch, SwitchOut, SwitchMove, SwitchDelete, SystemFronter, SystemFrontHistory); } + private async Task CommandHelpRoot(Context ctx) + { + if (!ctx.HasNext()) + { + await ctx.Reply($"{Emojis.Error} You need to pass a target command.\nAvailable command help targets: `system`, `member`, `group`, `switch`, `log`, `blacklist`.\nFor the full list of commands, see the website: "); + return; + } + + switch (ctx.PeekArgument()) { + case "system": + case "systems": + case "s": + await PrintCommandList(ctx, "systems", SystemCommands); + break; + case "member": + case "members": + case "m": + await PrintCommandList(ctx, "members", MemberCommands); + break; + case "group": + case "groups": + case "g": + await PrintCommandList(ctx, "groups", GroupCommands); + break; + case "switch": + case "switches": + case "switching": + case "sw": + await PrintCommandList(ctx, "switching", SwitchCommands); + break; + case "log": + await PrintCommandList(ctx, "message logging", LogCommands); + break; + case "blacklist": + case "bl": + await PrintCommandList(ctx, "channel blacklisting", BlacklistCommands); + break; + // case "autoproxy": (add this when #232 is merged) + // todo: are there any commands that still need to be added? + default: + await ctx.Reply("For the full list of commands, see the website: "); + break; + } + } + private async Task PrintCommandNotFoundError(Context ctx, params Command[] potentialCommands) { var commandListStr = CreatePotentialCommandList(potentialCommands); From 01cedaab537d0af3ce03c3cded8f845d666ffbb1 Mon Sep 17 00:00:00 2001 From: spiral Date: Thu, 19 Nov 2020 18:05:53 -0500 Subject: [PATCH 3/4] Tweak description for `switch delete all` command --- PluralKit.Bot/Commands/CommandTree.cs | 5 +++-- docs/content/command-list.md | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/PluralKit.Bot/Commands/CommandTree.cs b/PluralKit.Bot/Commands/CommandTree.cs index e6b79377..211bf148 100644 --- a/PluralKit.Bot/Commands/CommandTree.cs +++ b/PluralKit.Bot/Commands/CommandTree.cs @@ -60,7 +60,8 @@ namespace PluralKit.Bot public static Command Switch = new Command("switch", "switch [member 2] [member 3...]", "Registers a switch"); public static Command SwitchOut = new Command("switch out", "switch out", "Registers a switch with no members"); public static Command SwitchMove = new Command("switch move", "switch move ", "Moves the latest switch in time"); - public static Command SwitchDelete = new Command("switch delete", "switch delete [all]", "Deletes the latest switch (or them all)"); + public static Command SwitchDelete = new Command("switch delete", "switch delete", "Deletes the latest switch"); + public static Command SwitchDeleteAll = new Command("switch delete", "switch delete all", "Deletes all logged switches"); public static Command Link = new Command("link", "link ", "Links your system to another account"); public static Command Unlink = new Command("unlink", "unlink [account]", "Unlinks your system from an account"); public static Command TokenGet = new Command("token", "token", "Gets your system's API token"); @@ -104,7 +105,7 @@ namespace PluralKit.Bot GroupDelete }; - public static Command[] SwitchCommands = {Switch, SwitchOut, SwitchMove, SwitchDelete}; + public static Command[] SwitchCommands = {Switch, SwitchOut, SwitchMove, SwitchDelete, SwitchDeleteAll}; public static Command[] LogCommands = {LogChannel, LogChannelClear, LogEnable, LogDisable}; diff --git a/docs/content/command-list.md b/docs/content/command-list.md index 7cc6fc8c..0eed6ac8 100644 --- a/docs/content/command-list.md +++ b/docs/content/command-list.md @@ -75,7 +75,7 @@ Words in **\** or **[square brackets]** mean fill-in-the-blank. - `pk;switch [member...]` - Registers a switch with the given members. - `pk;switch move