{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}";
}
public static string HtmlFormatMessageLink(string roomId, string eventId, string[]? servers = null, string? displayName = null) {
if (servers is not { Length: > 0 }) servers = new[] { roomId.Split(':', 2)[1] };
return $"{displayName ?? eventId}";
}
#region Extension functions
public static RoomMessageEventContent ToMatrixMessage(this Exception e, string error) => FormatException(error, e);
#endregion
public static RoomMessageEventContent FormatWarning(string warning) {
return new RoomMessageEventContent(body: warning, messageType: "m.text") {
FormattedBody = $"{warning}",
Format = "org.matrix.custom.html"
};
}
public static RoomMessageEventContent FormatWarningJson(string warning, object data) {
return new RoomMessageEventContent(body: warning, messageType: "m.text") {
FormattedBody = $"{warning}: {data.ToJson(ignoreNull: true)}
",
Format = "org.matrix.custom.html"
};
}
public static RoomMessageEventContent Concat(this RoomMessageEventContent a, RoomMessageEventContent b) {
return new RoomMessageEventContent(body: $"{a.Body}{b.Body}", messageType: a.MessageType) {
FormattedBody = $"{a.FormattedBody}{b.FormattedBody}",
Format = a.Format
};
}
public static RoomMessageEventContent ConcatLine(this RoomMessageEventContent a, RoomMessageEventContent b) {
return new RoomMessageEventContent(body: $"{a.Body}\n{b.Body}", messageType: "m.text") {
FormattedBody = $"{a.FormattedBody}