about summary refs log tree commit diff
path: root/LibMatrix/Helpers/MessageBuilder.cs
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2025-08-06 03:12:29 +0200
committerRory& <root@rory.gay>2025-08-06 03:12:29 +0200
commitfcad35734ffe635a85e27349ff09bc035f268062 (patch)
tree0245003d1245ab459de075b742fec1448bf85ee3 /LibMatrix/Helpers/MessageBuilder.cs
parentDont set own powerlevel on room creation (diff)
downloadLibMatrix-fcad35734ffe635a85e27349ff09bc035f268062.tar.xz
Handle room upgrades
Diffstat (limited to 'LibMatrix/Helpers/MessageBuilder.cs')
-rw-r--r--LibMatrix/Helpers/MessageBuilder.cs18
1 files changed, 16 insertions, 2 deletions
diff --git a/LibMatrix/Helpers/MessageBuilder.cs b/LibMatrix/Helpers/MessageBuilder.cs

index 6f55739..f753bf7 100644 --- a/LibMatrix/Helpers/MessageBuilder.cs +++ b/LibMatrix/Helpers/MessageBuilder.cs
@@ -95,8 +95,13 @@ public class MessageBuilder(string msgType = "m.text", string format = "org.matr return this; } - public MessageBuilder WithMention(string id, string? displayName = null) { - Content.Body += $"@{displayName ?? id}"; + public MessageBuilder WithMention(string id, string? displayName = null, string[]? vias = null, bool useIdInPlainText = false, bool useLinkInPlainText = false) { + if (!useLinkInPlainText) Content.Body += $"@{(useIdInPlainText ? id : displayName ?? id)}"; + else { + Content.Body += $"https://matrix.to/#/{id}"; + if (vias is { Length: > 0 }) Content.Body += $"?via={string.Join("&via=", vias)}"; + } + Content.FormattedBody += $"<a href=\"https://matrix.to/#/{id}\">{displayName ?? id}</a>"; if (id == "@room") { Content.Mentions ??= new(); @@ -111,6 +116,15 @@ public class MessageBuilder(string msgType = "m.text", string format = "org.matr return this; } + public MessageBuilder WithRoomMention() { + // Legacy push rules support + Content.Body += "@room"; + Content.FormattedBody += "@room"; + Content.Mentions ??= new(); + Content.Mentions.Room = true; + return this; + } + public MessageBuilder WithNewline() { Content.Body += "\n"; Content.FormattedBody += "<br>";