From b26ca69071c89a6a554499a074b2c96a8826989a Mon Sep 17 00:00:00 2001 From: Iris System Date: Tue, 12 Nov 2024 21:20:36 +1300 Subject: [PATCH] fix(bot): make tag enforcement check name formatting --- PluralKit.Bot/Proxy/ProxyService.cs | 14 ++++++++++---- .../Database/Functions/MessageContextExt.cs | 18 ++++++++++++++++++ 2 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 PluralKit.Core/Database/Functions/MessageContextExt.cs diff --git a/PluralKit.Bot/Proxy/ProxyService.cs b/PluralKit.Bot/Proxy/ProxyService.cs index f3635d5b..85b7dd7d 100644 --- a/PluralKit.Bot/Proxy/ProxyService.cs +++ b/PluralKit.Bot/Proxy/ProxyService.cs @@ -125,11 +125,17 @@ public class ProxyService if (ctx.RequireSystemTag) { - var tag = ctx.SystemGuildTag ?? ctx.SystemTag; - if (tag == null) - return "This server requires PluralKit users to have a system tag, but you do not have one set."; if (!ctx.TagEnabled) - return "This server requires PluralKit users to have a system tag, but your system tag is disabled in this server."; + { + return "This server requires PluralKit users to have a system tag, but your system tag is disabled in this server. " + + "Use `pk;s servertag -enable` to enable it for this server."; + } + + if (!ctx.HasProxyableTag()) + { + return "This server requires PluralKit users to have a system tag, but you do not have one set. " + + "A system tag can be set for all servers with `pk;s tag`, or for just this server with `pk;s servertag`."; + } } var guild = await _cache.GetGuild(channel.GuildId.Value); diff --git a/PluralKit.Core/Database/Functions/MessageContextExt.cs b/PluralKit.Core/Database/Functions/MessageContextExt.cs new file mode 100644 index 00000000..bca26b2d --- /dev/null +++ b/PluralKit.Core/Database/Functions/MessageContextExt.cs @@ -0,0 +1,18 @@ +#nullable enable + +namespace PluralKit.Core; +public static class MessageContextExt +{ + public static bool HasProxyableTag(this MessageContext ctx) + { + var tag = ctx.SystemGuildTag ?? ctx.SystemTag; + if (!ctx.TagEnabled || tag == null) + return false; + + var format = ctx.NameFormat ?? ProxyMember.DefaultFormat; + if (!format.Contains("{tag}")) + return false; + + return true; + } +} \ No newline at end of file