about summary refs log tree commit diff
path: root/LibMatrix/Helpers/MessageBuilder.cs
diff options
context:
space:
mode:
Diffstat (limited to 'LibMatrix/Helpers/MessageBuilder.cs')
-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