Merge pull request #623 from nim-ka/main

Add shorthand 'pk;x' for 'pk;edit -regex'
This commit is contained in:
Astrid 2024-03-07 13:21:12 +01:00 committed by GitHub
commit 44bd0d6079
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 7 additions and 3 deletions

View file

@ -47,7 +47,9 @@ public partial class CommandTree
if (ctx.Match("message", "msg")) if (ctx.Match("message", "msg"))
return ctx.Execute<ProxiedMessage>(Message, m => m.GetMessage(ctx)); return ctx.Execute<ProxiedMessage>(Message, m => m.GetMessage(ctx));
if (ctx.Match("edit", "e")) if (ctx.Match("edit", "e"))
return ctx.Execute<ProxiedMessage>(MessageEdit, m => m.EditMessage(ctx)); return ctx.Execute<ProxiedMessage>(MessageEdit, m => m.EditMessage(ctx, false));
if (ctx.Match("x"))
return ctx.Execute<ProxiedMessage>(MessageEdit, m => m.EditMessage(ctx, true));
if (ctx.Match("reproxy", "rp", "crimes")) if (ctx.Match("reproxy", "rp", "crimes"))
return ctx.Execute<ProxiedMessage>(MessageReproxy, m => m.ReproxyMessage(ctx)); return ctx.Execute<ProxiedMessage>(MessageReproxy, m => m.ReproxyMessage(ctx));
if (ctx.Match("log")) if (ctx.Match("log"))

View file

@ -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); var (msg, systemId) = await GetMessageToEdit(ctx, EditTimeout, false);
@ -103,7 +103,7 @@ public class ProxiedMessage
throw new PKError("Could not edit message."); throw new PKError("Could not edit message.");
// Regex flag // Regex flag
var useRegex = ctx.MatchFlag("regex", "x"); useRegex = useRegex || ctx.MatchFlag("regex", "x");
// Check if we should append or prepend // Check if we should append or prepend
var mutateSpace = ctx.MatchFlag("nospace", "ns") ? "" : " "; var mutateSpace = ctx.MatchFlag("nospace", "ns") ? "" : " ";

View file

@ -27,6 +27,8 @@ PluralKit has a couple of useful command shorthands to reduce the typing:
|pk;switch|pk;sw| |pk;switch|pk;sw|
|pk;message|pk;msg| |pk;message|pk;msg|
|pk;autoproxy|pk;ap| |pk;autoproxy|pk;ap|
|pk;edit|pk;e|
|pk;edit -regex|pk;x|
## Member list flags ## Member list flags
There are a number of option flags that can be added to the `pk;system list` command. There are a number of option flags that can be added to the `pk;system list` command.