about summary refs log tree commit diff
path: root/LibMatrix/Helpers/MessageFormatter.cs
diff options
context:
space:
mode:
Diffstat (limited to 'LibMatrix/Helpers/MessageFormatter.cs')
-rw-r--r--LibMatrix/Helpers/MessageFormatter.cs24
1 files changed, 22 insertions, 2 deletions
diff --git a/LibMatrix/Helpers/MessageFormatter.cs b/LibMatrix/Helpers/MessageFormatter.cs
index b2dda61..b7c6975 100644
--- a/LibMatrix/Helpers/MessageFormatter.cs
+++ b/LibMatrix/Helpers/MessageFormatter.cs
@@ -13,7 +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=\"#EE4444\">{error}: <pre>{e.Message}</pre></font>",
+            FormattedBody = $"<font color=\"#EE4444\">{error}: <pre><code>{e.Message}</code></pre></font>",
             Format = "org.matrix.custom.html"
         };
     }
@@ -27,7 +27,7 @@ public static class MessageFormatter {
 
     public static RoomMessageEventContent FormatSuccessJson(string text, object data) {
         return new RoomMessageEventContent(body: text, messageType: "m.text") {
-            FormattedBody = $"<font color=\"#00FF00\">{text}: <pre>{data.ToJson(ignoreNull: true)}</pre></font>",
+            FormattedBody = $"<font color=\"#00FF00\">{text}: <pre><code>{data.ToJson(ignoreNull: true)}</code></pre></font>",
             Format = "org.matrix.custom.html"
         };
     }
@@ -53,4 +53,24 @@ public static class MessageFormatter {
             Format = "org.matrix.custom.html"
         };
     }
+    
+    public static RoomMessageEventContent FormatWarningJson(string warning, object data) {
+        return new RoomMessageEventContent(body: warning, messageType: "m.text") {
+            FormattedBody = $"<font color=\"#FFFF00\">{warning}: <pre><code>{data.ToJson(ignoreNull: true)}</code></pre></font>",
+            Format = "org.matrix.custom.html"
+        };
+    }
+    
+    public static RoomMessageEventContent Concat(this RoomMessageEventContent a, RoomMessageEventContent b) {
+        return new RoomMessageEventContent(body: $"{a.Body}{b.Body}", messageType: a.MessageType) {
+            FormattedBody = $"{a.FormattedBody}{b.FormattedBody}",
+            Format = a.Format
+        };
+    }
+    public static RoomMessageEventContent ConcatLine(this RoomMessageEventContent a, RoomMessageEventContent b) {
+        return new RoomMessageEventContent(body: $"{a.Body}\n{b.Body}", messageType: "m.text") {
+            FormattedBody = $"{a.FormattedBody}<br/>{b.FormattedBody}",
+            Format = "org.matrix.custom.html"
+        };
+    }
 }