diff --git a/EduAutomation/Application/Helpers/MarkdownHelpers.cs b/EduAutomation/Application/Helpers/MarkdownHelpers.cs new file mode 100644 index 0000000..dcea52d --- /dev/null +++ b/EduAutomation/Application/Helpers/MarkdownHelpers.cs @@ -0,0 +1,12 @@ +using System.Text.RegularExpressions; + +namespace EduAutomation.Application.Helpers; + +public static partial class MarkdownHelpers +{ + public static string NormalizeLinkText(this string text) + => BracketsRegex().Replace(text, ""); + + [GeneratedRegex(@"\[(.*?)\]")] + private static partial Regex BracketsRegex(); +} diff --git a/EduAutomation/Application/Telegram/Formatters/MarkdownMessageFormatter.cs b/EduAutomation/Application/Telegram/Formatters/MarkdownMessageFormatter.cs index f9a206c..e27a416 100644 --- a/EduAutomation/Application/Telegram/Formatters/MarkdownMessageFormatter.cs +++ b/EduAutomation/Application/Telegram/Formatters/MarkdownMessageFormatter.cs @@ -1,4 +1,5 @@ using System.Text; +using EduAutomation.Application.Helpers; using EduAutomation.Domain.GitHub.Events; namespace EduAutomation.Application.Telegram.Formatters; @@ -28,10 +29,10 @@ private string GetRepoCreatedCard(RepoCreated? repoCreated, Dictionary // Organization and Creator builder.AppendLine("**Organization and Creator**"); builder.AppendLine($"- **Organization:** [{e.Org.Name}](https://github.com/{e.Org.Name})"); - builder.AppendLine($"- **Creator:** [{NormalizedSenderLogin(e)}]({e.Sender.Url})"); + builder.AppendLine($"- **Creator:** [{e.Sender.Login.NormalizeLinkText()}]({e.Sender.Url})"); builder.AppendLine(); // Assignment @@ -84,9 +85,4 @@ private static void TryAddMentor(StringBuilder builder, Dictionary