From 9dd3fba7e64d4b4078eb667ddb5bc622d0df7cf6 Mon Sep 17 00:00:00 2001 From: spiral Date: Mon, 13 Jun 2022 14:52:07 -0400 Subject: [PATCH] fix: show correct error in 'pk;debug proxy' when autoproxy is disabled for discord account --- PluralKit.Bot/Commands/Checks.cs | 3 +-- PluralKit.Bot/Handlers/MessageCreated.cs | 3 +-- PluralKit.Bot/Proxy/ProxyMatcher.cs | 4 ++++ 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/PluralKit.Bot/Commands/Checks.cs b/PluralKit.Bot/Commands/Checks.cs index 05623a4d..0c6836a4 100644 --- a/PluralKit.Bot/Commands/Checks.cs +++ b/PluralKit.Bot/Commands/Checks.cs @@ -268,8 +268,7 @@ public class Checks try { _proxy.ShouldProxy(channel, msg, context); - _matcher.TryMatch(context, autoproxySettings, members, out var match, msg.Content, msg.Attachments.Length > 0, - context.AllowAutoproxy); + _matcher.TryMatch(context, autoproxySettings, members, out var match, msg.Content, msg.Attachments.Length > 0, true); await ctx.Reply("I'm not sure why this message was not proxied, sorry."); } diff --git a/PluralKit.Bot/Handlers/MessageCreated.cs b/PluralKit.Bot/Handlers/MessageCreated.cs index 09a1a8c5..7f6cd1c0 100644 --- a/PluralKit.Bot/Handlers/MessageCreated.cs +++ b/PluralKit.Bot/Handlers/MessageCreated.cs @@ -178,8 +178,7 @@ public class MessageCreated: IEventHandler try { - return await _proxy.HandleIncomingMessage(evt, ctx, guild, channel, ctx.AllowAutoproxy, - botPermissions); + return await _proxy.HandleIncomingMessage(evt, ctx, guild, channel, true, botPermissions); } // Catch any failed proxy checks so they get ignored in the global error handler diff --git a/PluralKit.Bot/Proxy/ProxyMatcher.cs b/PluralKit.Bot/Proxy/ProxyMatcher.cs index 9c4a5b68..87cbf329 100644 --- a/PluralKit.Bot/Proxy/ProxyMatcher.cs +++ b/PluralKit.Bot/Proxy/ProxyMatcher.cs @@ -43,6 +43,10 @@ public class ProxyMatcher { match = default; + if (!ctx.AllowAutoproxy) + throw new ProxyService.ProxyChecksFailedException( + "Autoproxy is disabled for your account. Type `pk;cfg autoproxy account enable` to re-enable it."); + // Skip autoproxy match if we hit the escape character if (messageContent.StartsWith(AutoproxyEscapeCharacter)) throw new ProxyService.ProxyChecksFailedException(