about summary refs log tree commit diff
path: root/LibMatrix/Helpers/MessageBuilder.cs
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2024-03-15 18:10:58 +0100
committerRory& <root@rory.gay>2024-03-15 18:11:18 +0100
commit096375344ef87fe53ca009b7a7eaa34c9c9f5407 (patch)
tree76d666cd6961ca04ae9e91e47c43d91eed27a87a /LibMatrix/Helpers/MessageBuilder.cs
parentFix README (diff)
downloadLibMatrix-096375344ef87fe53ca009b7a7eaa34c9c9f5407.tar.xz
Bot changes, move named filters to subclass
Diffstat (limited to '')
-rw-r--r--LibMatrix/Helpers/MessageBuilder.cs24
1 files changed, 19 insertions, 5 deletions
diff --git a/LibMatrix/Helpers/MessageBuilder.cs b/LibMatrix/Helpers/MessageBuilder.cs
index 68f6300..07953e3 100644
--- a/LibMatrix/Helpers/MessageBuilder.cs
+++ b/LibMatrix/Helpers/MessageBuilder.cs
@@ -50,11 +50,18 @@ public class MessageBuilder(string msgType = "m.text", string format = "org.matr
         Content.FormattedBody += "</font>";
         return this;
     }
+    
+    public MessageBuilder WithCustomEmoji(string mxcUri, string name) {
+        Content.Body += $"{{{name}}}";
+        Content.FormattedBody += $"<img data-mx-emoticon height=\"32\" src=\"{mxcUri}\" alt=\"{name}\" title=\"{name}\" />";
+        return this;
+    }
+
+    public MessageBuilder WithRainbowString(string text, byte skip = 1, int offset = 0, double lengthFactor = 255.0, bool useLength = true) {
+        if (useLength) {
+            lengthFactor = text.Length;
+        }
 
-    public MessageBuilder WithRainbowString(string text, byte skip = 1, int offset = 0, double lengthFactor = 255.0, bool useLength = true) =>
-        // if (useLength) {
-        //     lengthFactor = text.Length;
-        // }
         // HslaColorInterpolator interpolator = new((0, 255, 128, 255), (255, 255, 128, 255));
         // // RainbowEnumerator enumerator = new(skip, offset, lengthFactor);
         // for (int i = 0; i < text.Length; i++) {
@@ -63,5 +70,12 @@ public class MessageBuilder(string msgType = "m.text", string format = "org.matr
         //     // Console.WriteLine($"RBA: {r} {g} {b} {a}");
         //     // Content.FormattedBody += $"<font color=\"#{r:X2}{g:X2}{b:X2}\">{text[i]}</font>";
         // }
-        this;
+        return this;
+    }
+    
+    public MessageBuilder WithCodeBlock(string code, string language = "plaintext") {
+        Content.Body += code;
+        Content.FormattedBody += $"<pre><code class=\"language-{language}\">{code}</code></pre>";
+        return this;
+    }
 }
\ No newline at end of file