From 633627c30a31600db9e82da4291689e27ee2fbad Mon Sep 17 00:00:00 2001 From: Ske Date: Thu, 26 Dec 2019 19:19:06 +0100 Subject: [PATCH] Fix image-only proxies where the tags have trailing/leading spaces --- PluralKit.Bot/Services/ProxyService.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/PluralKit.Bot/Services/ProxyService.cs b/PluralKit.Bot/Services/ProxyService.cs index 98e5baad..face01fd 100644 --- a/PluralKit.Bot/Services/ProxyService.cs +++ b/PluralKit.Bot/Services/ProxyService.cs @@ -62,7 +62,17 @@ namespace PluralKit.Bot var prefix = tag.Prefix ?? ""; var suffix = tag.Suffix ?? ""; - if (message.Length >= prefix.Length + suffix.Length && message.StartsWith(prefix) && message.EndsWith(suffix)) { + var isMatch = message.Length >= prefix.Length + suffix.Length + && message.StartsWith(prefix) && message.EndsWith(suffix); + + // Special case for image-only proxies and proxy tags with spaces + if (!isMatch && message.Trim() == prefix.TrimEnd() + suffix.TrimStart()) + { + isMatch = true; + message = prefix + suffix; // To get around substring errors + } + + if (isMatch) { var inner = message.Substring(prefix.Length, message.Length - prefix.Length - suffix.Length); if (leadingMention != null) inner = $"{leadingMention} {inner}"; return new ProxyMatch { Member = match.Member, System = match.System, InnerText = inner, ProxyTags = tag};