using ArcaneLibs.Extensions; using LibMatrix.StateEventTypes.Spec; namespace LibMatrix.Helpers; public static class MessageFormatter { public static RoomMessageEventContent FormatError(string error) { return new RoomMessageEventContent(body: error, messageType: "m.text") { FormattedBody = $"{error}: {error}", Format = "org.matrix.custom.html" }; } public static RoomMessageEventContent FormatException(string error, Exception e) { return new RoomMessageEventContent(body: $"{error}: {e.Message}", messageType: "m.text") { FormattedBody = $"{error}:
{e.Message}
" + $"
", Format = "org.matrix.custom.html" }; } public static RoomMessageEventContent FormatSuccess(string text) { return new RoomMessageEventContent(body: text, messageType: "m.text") { FormattedBody = $"{text}", Format = "org.matrix.custom.html" }; } public static RoomMessageEventContent FormatSuccessJson(string text, object data) { return new RoomMessageEventContent(body: text, messageType: "m.text") { FormattedBody = $"{text}:
{data.ToJson(ignoreNull: true)}
", Format = "org.matrix.custom.html" }; } public static string HtmlFormatMention(string id, string? displayName = null) { return $"{displayName ?? id}"; } }