about summary refs log tree commit diff
path: root/LibMatrix/Helpers
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2024-03-15 19:51:21 +0100
committerRory& <root@rory.gay>2024-03-15 19:51:21 +0100
commit89f61274be01320358fced2159acb4b8871d3680 (patch)
tree285ec36b520bdc4e1316a3d4fb266ee7363413a1 /LibMatrix/Helpers
parentBot changes, move named filters to subclass (diff)
downloadLibMatrix-89f61274be01320358fced2159acb4b8871d3680.tar.xz
Add AddCollapsiblePart to MessageBuilder
Diffstat (limited to '')
-rw-r--r--LibMatrix/Helpers/MessageBuilder.cs13
1 files changed, 13 insertions, 0 deletions
diff --git a/LibMatrix/Helpers/MessageBuilder.cs b/LibMatrix/Helpers/MessageBuilder.cs
index 07953e3..0753aca 100644
--- a/LibMatrix/Helpers/MessageBuilder.cs
+++ b/LibMatrix/Helpers/MessageBuilder.cs
@@ -78,4 +78,17 @@ public class MessageBuilder(string msgType = "m.text", string format = "org.matr
         Content.FormattedBody += $"<pre><code class=\"language-{language}\">{code}</code></pre>";
         return this;
     }
+    
+    public MessageBuilder WithCollapsibleSection(string title, string body) {
+        Content.Body += body;
+        Content.FormattedBody += $"<details><summary>{title}</summary>{body}</details>";
+        return this;
+    }
+    
+    public MessageBuilder WithCollapsibleSection(string title, Action<MessageBuilder> bodyBuilder) {
+        Content.FormattedBody += $"<details><summary>{title}</summary>";
+        bodyBuilder(this);
+        Content.FormattedBody += "</details>";
+        return this;
+    }
 }
\ No newline at end of file