From e5591eef3850a9796cc87386128651a828b70697 Mon Sep 17 00:00:00 2001 From: TheArcaneBrony Date: Fri, 6 Oct 2023 18:29:15 +0200 Subject: Small refactors --- LibMatrix/Helpers/MessageFormatter.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'LibMatrix/Helpers/MessageFormatter.cs') diff --git a/LibMatrix/Helpers/MessageFormatter.cs b/LibMatrix/Helpers/MessageFormatter.cs index ae02afc..d252e85 100644 --- a/LibMatrix/Helpers/MessageFormatter.cs +++ b/LibMatrix/Helpers/MessageFormatter.cs @@ -13,8 +13,7 @@ public static class MessageFormatter { public static RoomMessageEventContent FormatException(string error, Exception e) { return new RoomMessageEventContent(body: $"{error}: {e.Message}", messageType: "m.text") { - FormattedBody = $"{error}:
{e.Message}
" + - $"
", + FormattedBody = $"{error}:
{e.Message}
", Format = "org.matrix.custom.html" }; } @@ -36,4 +35,10 @@ public static class MessageFormatter { public static string HtmlFormatMention(string id, string? displayName = null) { return $"{displayName ?? id}"; } + +#region Extension functions + + public static RoomMessageEventContent ToMatrixMessage(this Exception e, string error) => FormatException(error, e); + +#endregion } -- cgit 1.4.1