From ddbf0e869181d1e8e03711d683e35bf5439ffc8d Mon Sep 17 00:00:00 2001 From: spiral Date: Fri, 21 Jan 2022 18:23:58 -0500 Subject: [PATCH] Revert "feat: remove 2000-character limit for proxied messages" This reverts commit 7cc2aab1f05fd6f508eec1c752d30d40a57ac9ed. --- PluralKit.Bot/Commands/Message.cs | 3 +++ PluralKit.Bot/Proxy/ProxyService.cs | 4 ++++ PluralKit.Bot/Services/WebhookExecutorService.cs | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/PluralKit.Bot/Commands/Message.cs b/PluralKit.Bot/Commands/Message.cs index 596a5b0d..8b91b3f9 100644 --- a/PluralKit.Bot/Commands/Message.cs +++ b/PluralKit.Bot/Commands/Message.cs @@ -56,6 +56,9 @@ public class ProxiedMessage var newContent = ctx.RemainderOrNull().NormalizeLineEndSpacing(); + if (newContent.Length > 2000) + throw new PKError("PluralKit cannot proxy messages over 2000 characters in length."); + var originalMsg = await _rest.GetMessageOrNull(msg.Message.Channel, msg.Message.Mid); if (originalMsg == null) throw new PKError("Could not edit message."); diff --git a/PluralKit.Bot/Proxy/ProxyService.cs b/PluralKit.Bot/Proxy/ProxyService.cs index 69aa6932..60384b36 100644 --- a/PluralKit.Bot/Proxy/ProxyService.cs +++ b/PluralKit.Bot/Proxy/ProxyService.cs @@ -66,6 +66,10 @@ public class ProxyService if (!_matcher.TryMatch(ctx, members, out var match, message.Content, message.Attachments.Length > 0, allowAutoproxy)) return false; + // this is hopefully temporary, so not putting it into a separate method + if (message.Content != null && message.Content.Length > 2000) + throw new PKError("PluralKit cannot proxy messages over 2000 characters in length."); + // Permission check after proxy match so we don't get spammed when not actually proxying if (!CheckBotPermissionsOrError(botPermissions, rootChannel.Id)) return false; diff --git a/PluralKit.Bot/Services/WebhookExecutorService.cs b/PluralKit.Bot/Services/WebhookExecutorService.cs index db1b4539..b816d6f9 100644 --- a/PluralKit.Bot/Services/WebhookExecutorService.cs +++ b/PluralKit.Bot/Services/WebhookExecutorService.cs @@ -100,7 +100,7 @@ public class WebhookExecutorService private async Task ExecuteWebhookInner(Webhook webhook, ProxyRequest req, bool hasRetried = false) { var guild = await _cache.GetGuild(req.GuildId); - var content = req.Content.Truncate(4000); + var content = req.Content.Truncate(2000); var allowedMentions = content.ParseMentions(); if (!req.AllowEveryone)