From 242c7c7e1eabd2f74886ce2248580b6348500355 Mon Sep 17 00:00:00 2001 From: Masterjun3 Date: Fri, 26 Jan 2024 12:59:09 +0100 Subject: [PATCH] Revert "escape formatting symbols for discord publisher (#1749)" This reverts commit df97a929affe1527755f95a1be73da9a8f7a87c3. --- .../Distributors/DiscordDistributor.cs | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/TASVideos.Core/Services/ExternalMediaPublisher/Distributors/DiscordDistributor.cs b/TASVideos.Core/Services/ExternalMediaPublisher/Distributors/DiscordDistributor.cs index 9c9143c40..fd933fe52 100644 --- a/TASVideos.Core/Services/ExternalMediaPublisher/Distributors/DiscordDistributor.cs +++ b/TASVideos.Core/Services/ExternalMediaPublisher/Distributors/DiscordDistributor.cs @@ -2,7 +2,6 @@ using Microsoft.Extensions.Logging; using TASVideos.Core.Settings; using TASVideos.Core.HttpClientExtensions; -using System.Text.RegularExpressions; namespace TASVideos.Core.Services.ExternalMediaPublisher.Distributors; @@ -73,26 +72,20 @@ or PostGroups.Submission private class DiscordMessage { - private readonly Regex CharacterToBeEscaped = new Regex(@"([\\_*~#\-`<>|])"); - private const string EscapeRule = @"\$1"; - // Generate the Discord message letting Discord take care of the Embed from Open Graph Metadata public DiscordMessage(IPostable post) { - var body = CharacterToBeEscaped.Replace(post.Body, EscapeRule); - var title = CharacterToBeEscaped.Replace(post.Title, EscapeRule); - var formattedTitle = CharacterToBeEscaped.Replace(post.FormattedTitle, EscapeRule); - body = string.IsNullOrWhiteSpace(body) ? "" : $" ({body})"; + var body = string.IsNullOrWhiteSpace(post.Body) ? "" : $" ({post.Body})"; if (string.IsNullOrWhiteSpace(post.Link)) { - Content = $"{title}{body}"; + Content = $"{post.Title}{body}"; } else { var link = post.Type == PostType.Announcement ? post.Link : $"<{post.Link}>"; - Content = string.IsNullOrWhiteSpace(formattedTitle) - ? $"{title}{body} {link}" - : $"{string.Format(formattedTitle, link)}{body}"; + Content = string.IsNullOrWhiteSpace(post.FormattedTitle) + ? $"{post.Title}{body} {link}" + : $"{string.Format(post.FormattedTitle, link)}{body}"; } }