fix: emotes being cut off in replies

This commit is contained in:
Zoe Martin 2021-06-25 12:34:44 +02:00
parent 0dfea56d83
commit b156f6a9cb
No known key found for this signature in database
GPG Key ID: 65238C3E138FFBE9

View File

@ -177,6 +177,15 @@ namespace PluralKit.Bot
if (msg.Length > 100)
{
msg = repliedTo.Content.Substring(0, 100);
var openedEmotesInTruncatedString = Regex.Matches(msg, @"<a?:").Count;
var fullEmotesInTruncatedString = Regex.Matches(msg, @"<a?:\w+:\d+>").Count;
if (openedEmotesInTruncatedString != fullEmotesInTruncatedString)
{
var emoteTail = repliedTo.Content.Substring(100).Split(">")[0];
if (Regex.IsMatch(msg + emoteTail, @"<a?:\w+:\d+$"))
msg += emoteTail + ">";
}
var spoilersInOriginalString = Regex.Matches(repliedTo.Content, @"\|\|").Count;
var spoilersInTruncatedString = Regex.Matches(msg, @"\|\|").Count;
if (spoilersInTruncatedString % 2 == 1 && spoilersInOriginalString % 2 == 0)