using ArcaneLibs; using LibMatrix.EventTypes.Spec; namespace LibMatrix.Helpers; public class MessageBuilder(string msgType = "m.text", string format = "org.matrix.custom.html") { private RoomMessageEventContent Content { get; set; } = new() { MessageType = msgType, Format = format }; public RoomMessageEventContent Build() => Content; public MessageBuilder WithColoredBody(string color, string body) { Content.Body += body; Content.FormattedBody += $"{body}"; return this; } public MessageBuilder WithColoredBody(string color, Action bodyBuilder) { Content.FormattedBody += $""; bodyBuilder(this); Content.FormattedBody += ""; 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; } RainbowEnumerator enumerator = new(skip, offset, lengthFactor); for (int i = 0; i < text.Length; i++) { var (r, g, b) = enumerator.Next(); Content.FormattedBody += $"{text[i]}"; } return this; } }