fix: issues with urls being cut in half at the end of replies and "…" unnecessarily being appended at the end
This commit is contained in:
parent
d1c6794330
commit
e9da1a80b7
@ -185,11 +185,20 @@ namespace PluralKit.Bot
|
|||||||
msg += mentionTail + ">";
|
msg += mentionTail + ">";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var endsWithUrl = Regex.IsMatch(msg,
|
||||||
|
@"(http|https)?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)$");
|
||||||
|
if (endsWithUrl)
|
||||||
|
{
|
||||||
|
var urlTail = repliedTo.Content.Substring(100).Split(" ")[0];
|
||||||
|
msg += urlTail + " ";
|
||||||
|
}
|
||||||
|
|
||||||
var spoilersInOriginalString = Regex.Matches(repliedTo.Content, @"\|\|").Count;
|
var spoilersInOriginalString = Regex.Matches(repliedTo.Content, @"\|\|").Count;
|
||||||
var spoilersInTruncatedString = Regex.Matches(msg, @"\|\|").Count;
|
var spoilersInTruncatedString = Regex.Matches(msg, @"\|\|").Count;
|
||||||
if (spoilersInTruncatedString % 2 == 1 && spoilersInOriginalString % 2 == 0)
|
if (spoilersInTruncatedString % 2 == 1 && spoilersInOriginalString % 2 == 0)
|
||||||
msg += "||";
|
msg += "||";
|
||||||
msg += "…";
|
if (msg != repliedTo.Content)
|
||||||
|
msg += "…";
|
||||||
}
|
}
|
||||||
|
|
||||||
content.Append($"**[Reply to:]({jumpLink})** ");
|
content.Append($"**[Reply to:]({jumpLink})** ");
|
||||||
|
Loading…
Reference in New Issue
Block a user