Fix image-only proxies where the tags have trailing/leading spaces
This commit is contained in:
parent
67b5f7f7a6
commit
633627c30a
@ -62,7 +62,17 @@ namespace PluralKit.Bot
|
|||||||
var prefix = tag.Prefix ?? "";
|
var prefix = tag.Prefix ?? "";
|
||||||
var suffix = tag.Suffix ?? "";
|
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);
|
var inner = message.Substring(prefix.Length, message.Length - prefix.Length - suffix.Length);
|
||||||
if (leadingMention != null) inner = $"{leadingMention} {inner}";
|
if (leadingMention != null) inner = $"{leadingMention} {inner}";
|
||||||
return new ProxyMatch { Member = match.Member, System = match.System, InnerText = inner, ProxyTags = tag};
|
return new ProxyMatch { Member = match.Member, System = match.System, InnerText = inner, ProxyTags = tag};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user