Fix: Escape Backticks (#192)

This commit is contained in:
BeeFox-sys
2020-07-05 20:55:21 +10:00
committed by GitHub
parent 0d2777c1d1
commit 55ea314b42
6 changed files with 17 additions and 10 deletions

View File

@@ -192,6 +192,13 @@ namespace PluralKit.Bot
else return input;
}
public static string EscapeBacktickPair(this string input){
Regex doubleBacktick = new Regex(@"``", RegexOptions.Multiline);
//Run twice to catch any pairs that are created from the first pass, pairs shouldn't be created in the second as they are created from odd numbers of backticks, even numbers are all caught on the first pass
if(input != null) return doubleBacktick.Replace(doubleBacktick.Replace(input, @"``"),@"``");
else return input;
}
public static Task<DiscordUser> GetUser(this DiscordRestClient client, ulong id) =>
WrapDiscordCall(client.GetUserAsync(id));

View File

@@ -14,7 +14,7 @@ using PluralKit.Core;
namespace PluralKit.Bot
{
public static class MiscUtils {
public static string ProxyTagsString(this PKMember member) => string.Join(", ", member.ProxyTags.Select(t => $"`{t.ProxyString.EscapeMarkdown()}`"));
public static string ProxyTagsString(this PKMember member) => string.Join(", ", member.ProxyTags.Select(t => $"``{t.ProxyString.EscapeBacktickPair()}``"));
public static bool IsOurProblem(this Exception e)
{