From 096375344ef87fe53ca009b7a7eaa34c9c9f5407 Mon Sep 17 00:00:00 2001 From: Rory& Date: Fri, 15 Mar 2024 18:10:58 +0100 Subject: Bot changes, move named filters to subclass --- LibMatrix/Helpers/MessageBuilder.cs | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'LibMatrix/Helpers/MessageBuilder.cs') 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 += ""; return this; } + + public MessageBuilder WithCustomEmoji(string mxcUri, string name) { + Content.Body += $"{{{name}}}"; + Content.FormattedBody += $"\"{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 += $"{text[i]}"; // } - this; + return this; + } + + public MessageBuilder WithCodeBlock(string code, string language = "plaintext") { + Content.Body += code; + Content.FormattedBody += $"
{code}
"; + return this; + } } \ No newline at end of file -- cgit 1.4.1