From 8f7f4ab6f4fda52e2231fe56e8d9030d7dfd1068 Mon Sep 17 00:00:00 2001 From: nim-ka Date: Thu, 7 Mar 2024 03:25:17 -0800 Subject: [PATCH 1/2] Add shorthand 'pk;x' for 'pk;edit -regex' --- PluralKit.Bot/CommandMeta/CommandTree.cs | 6 ++++-- PluralKit.Bot/Commands/Message.cs | 6 +++--- docs/content/tips-and-tricks.md | 2 ++ 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/PluralKit.Bot/CommandMeta/CommandTree.cs b/PluralKit.Bot/CommandMeta/CommandTree.cs index 07d183bf..8e31a0b3 100644 --- a/PluralKit.Bot/CommandMeta/CommandTree.cs +++ b/PluralKit.Bot/CommandMeta/CommandTree.cs @@ -47,7 +47,9 @@ public partial class CommandTree if (ctx.Match("message", "msg")) return ctx.Execute(Message, m => m.GetMessage(ctx)); if (ctx.Match("edit", "e")) - return ctx.Execute(MessageEdit, m => m.EditMessage(ctx)); + return ctx.Execute(MessageEdit, m => m.EditMessage(ctx, false)); + if (ctx.Match("x")) + return ctx.Execute(MessageEdit, m => m.EditMessage(ctx, true)); if (ctx.Match("reproxy", "rp", "crimes")) return ctx.Execute(MessageReproxy, m => m.ReproxyMessage(ctx)); if (ctx.Match("log")) @@ -540,4 +542,4 @@ public partial class CommandTree // todo: maybe add the list of configuration keys here? return ctx.Reply($"{Emojis.Error} Could not find a setting with that name. Please see `pk;commands config` for the list of possible config settings."); } -} \ No newline at end of file +} diff --git a/PluralKit.Bot/Commands/Message.cs b/PluralKit.Bot/Commands/Message.cs index 6aac61eb..5d933cec 100644 --- a/PluralKit.Bot/Commands/Message.cs +++ b/PluralKit.Bot/Commands/Message.cs @@ -91,7 +91,7 @@ public class ProxiedMessage } } - public async Task EditMessage(Context ctx) + public async Task EditMessage(Context ctx, bool useRegex) { var (msg, systemId) = await GetMessageToEdit(ctx, EditTimeout, false); @@ -103,7 +103,7 @@ public class ProxiedMessage throw new PKError("Could not edit message."); // Regex flag - var useRegex = ctx.MatchFlag("regex", "x"); + useRegex = useRegex || ctx.MatchFlag("regex", "x"); // Check if we should append or prepend var mutateSpace = ctx.MatchFlag("nospace", "ns") ? "" : " "; @@ -433,4 +433,4 @@ public class ProxiedMessage else await ctx.Rest.CreateReaction(ctx.Message.ChannelId, ctx.Message.Id, new Emoji { Name = Emojis.Success }); } -} \ No newline at end of file +} diff --git a/docs/content/tips-and-tricks.md b/docs/content/tips-and-tricks.md index 66e676a7..d7f14faf 100644 --- a/docs/content/tips-and-tricks.md +++ b/docs/content/tips-and-tricks.md @@ -27,6 +27,8 @@ PluralKit has a couple of useful command shorthands to reduce the typing: |pk;switch|pk;sw| |pk;message|pk;msg| |pk;autoproxy|pk;ap| +|pk;edit|pk;e| +|pk;edit -regex|pk;x| ## Member list flags There are a number of option flags that can be added to the `pk;system list` command. From 1493e8d83dcf9dbe8dad11e743fa884fa78c2c50 Mon Sep 17 00:00:00 2001 From: nim-ka Date: Thu, 7 Mar 2024 03:31:01 -0800 Subject: [PATCH 2/2] Remove trailing newlines --- PluralKit.Bot/CommandMeta/CommandTree.cs | 2 +- PluralKit.Bot/Commands/Message.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/PluralKit.Bot/CommandMeta/CommandTree.cs b/PluralKit.Bot/CommandMeta/CommandTree.cs index 8e31a0b3..627b1bdc 100644 --- a/PluralKit.Bot/CommandMeta/CommandTree.cs +++ b/PluralKit.Bot/CommandMeta/CommandTree.cs @@ -542,4 +542,4 @@ public partial class CommandTree // todo: maybe add the list of configuration keys here? return ctx.Reply($"{Emojis.Error} Could not find a setting with that name. Please see `pk;commands config` for the list of possible config settings."); } -} +} \ No newline at end of file diff --git a/PluralKit.Bot/Commands/Message.cs b/PluralKit.Bot/Commands/Message.cs index 5d933cec..37b5a4e0 100644 --- a/PluralKit.Bot/Commands/Message.cs +++ b/PluralKit.Bot/Commands/Message.cs @@ -433,4 +433,4 @@ public class ProxiedMessage else await ctx.Rest.CreateReaction(ctx.Message.ChannelId, ctx.Message.Id, new Emoji { Name = Emojis.Success }); } -} +} \ No newline at end of file