diff options
author | TheArcaneBrony <myrainbowdash949@gmail.com> | 2023-10-06 18:29:15 +0200 |
---|---|---|
committer | TheArcaneBrony <myrainbowdash949@gmail.com> | 2023-10-06 18:29:15 +0200 |
commit | e5591eef3850a9796cc87386128651a828b70697 (patch) | |
tree | 7e501ec749229a3d96838265289266bb6f6ce208 /LibMatrix/Helpers/MessageFormatter.cs | |
parent | Unit tests, small refactors (diff) | |
download | LibMatrix-e5591eef3850a9796cc87386128651a828b70697.tar.xz |
Small refactors
Diffstat (limited to 'LibMatrix/Helpers/MessageFormatter.cs')
-rw-r--r-- | LibMatrix/Helpers/MessageFormatter.cs | 9 |
1 files changed, 7 insertions, 2 deletions
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 = $"<font color=\"#FF0000\">{error}: <pre>{e.Message}</pre>" + - $"</font>", + FormattedBody = $"<font color=\"#FF0000\">{error}: <pre>{e.Message}</pre></font>", Format = "org.matrix.custom.html" }; } @@ -36,4 +35,10 @@ public static class MessageFormatter { public static string HtmlFormatMention(string id, string? displayName = null) { return $"<a href=\"https://matrix.to/#/{id}\">{displayName ?? id}</a>"; } + +#region Extension functions + + public static RoomMessageEventContent ToMatrixMessage(this Exception e, string error) => FormatException(error, e); + +#endregion } |