Class OutgoingMessageBuilder
Fluent builder for OutgoingMessage. Validation happens in Build().
public sealed class OutgoingMessageBuilder
- Inheritance
-
OutgoingMessageBuilder
- Inherited Members
Methods
AsViewOnce(bool)
Marks the message as view-once.
public OutgoingMessageBuilder AsViewOnce(bool viewOnce = true)
Parameters
viewOnceboolWhether the message is view-once.
Returns
- OutgoingMessageBuilder
This builder.
Build()
Validates the state and creates the immutable message.
public OutgoingMessage Build()
Returns
- OutgoingMessage
The message.
Exceptions
- SignalDomainException
There is no recipient; there is neither text, an attachment nor a sticker; a mention exceeds the text; a sticker is combined with attachments; or the link preview's URL is not in the text.
Editing(long)
Turns the send into an edit of a message sent earlier by the same account.
public OutgoingMessageBuilder Editing(long timestamp)
Parameters
timestamplongTimestamp of the message to edit.
Returns
- OutgoingMessageBuilder
This builder.
NotifySelf(bool)
Controls whether the sending account's other devices are notified.
public OutgoingMessageBuilder NotifySelf(bool notify = true)
Parameters
notifyboolWhether to notify the own devices.
Returns
- OutgoingMessageBuilder
This builder.
Quoting(long, string, string?)
Replies to (quotes) a message.
public OutgoingMessageBuilder Quoting(long timestamp, string author, string? text = null)
Parameters
timestamplongTimestamp of the quoted message.
authorstringPhone number or UUID of the quoted message's author.
textstringText of the quoted message, shown in the preview.
Returns
- OutgoingMessageBuilder
This builder.
To(params IEnumerable<Recipient>)
Adds recipients. Duplicates are ignored. Phone numbers, account ids, usernames and group ids convert implicitly.
public OutgoingMessageBuilder To(params IEnumerable<Recipient> recipients)
Parameters
recipientsIEnumerable<Recipient>The recipients to add.
Returns
- OutgoingMessageBuilder
This builder.
Exceptions
- ArgumentException
A recipient is default (holds no value).
WithAttachment(ReadOnlySpan<byte>, string, string?)
Adds an attachment, encoding it as a data URI.
public OutgoingMessageBuilder WithAttachment(ReadOnlySpan<byte> content, string contentType, string? fileName = null)
Parameters
contentReadOnlySpan<byte>The file content.
contentTypestringThe MIME type, e.g.
image/png.fileNamestringOptional file name shown to recipients.
Returns
- OutgoingMessageBuilder
This builder.
WithBase64Attachment(string)
Adds an attachment that is already base64 encoded (optionally as data URI).
public OutgoingMessageBuilder WithBase64Attachment(string base64OrDataUri)
Parameters
base64OrDataUristringPlain base64, or
data:<mime>;filename=<name>;base64,<data>.
Returns
- OutgoingMessageBuilder
This builder.
WithLinkPreview(LinkPreview)
Attaches a link preview card. The URL must also appear in the message text, because Signal clients ignore previews of links that aren't in the text.
public OutgoingMessageBuilder WithLinkPreview(LinkPreview preview)
Parameters
previewLinkPreviewThe preview.
Returns
- OutgoingMessageBuilder
This builder.
Exceptions
- SignalDomainException
The URL is not an absolute
httporhttpsURL.
WithLinkPreview(string, string?, string?, string?)
Attaches a link preview card for a URL contained in the message text.
public OutgoingMessageBuilder WithLinkPreview(string url, string? title = null, string? description = null, string? base64Thumbnail = null)
Parameters
urlstringThe previewed URL; must appear in the text.
titlestringThe card title.
descriptionstringThe card description.
base64ThumbnailstringThe thumbnail image as base64 or data URI.
Returns
- OutgoingMessageBuilder
This builder.
Exceptions
- SignalDomainException
urlis not an absolutehttporhttpsURL.
WithMention(string, int, int)
Mentions a user at a position in the text.
public OutgoingMessageBuilder WithMention(string author, int start, int length)
Parameters
authorstringPhone number or UUID of the mentioned user.
startintStart position in the text (UTF-16 code units).
lengthintLength of the mentioned span.
Returns
- OutgoingMessageBuilder
This builder.
Exceptions
- SignalDomainException
startis negative orlengthis not positive.
WithSticker(Sticker)
Sends a sticker from a sticker pack installed on the account (see IStickerService).
public OutgoingMessageBuilder WithSticker(Sticker sticker)
Parameters
stickerStickerThe sticker, e.g.
Sticker.Parse("f3a9…:4").
Returns
- OutgoingMessageBuilder
This builder.
WithSticker(string, int)
Sends a sticker from a sticker pack installed on the account.
public OutgoingMessageBuilder WithSticker(string packId, int stickerId)
Parameters
packIdstringThe hex id of the sticker pack.
stickerIdintThe index of the sticker within the pack.
Returns
- OutgoingMessageBuilder
This builder.
Exceptions
- SignalDomainException
packIdis not hex, orstickerIdis negative.
WithStyledText(string)
Sets a text using Signal's markdown-like styling (Styled).
public OutgoingMessageBuilder WithStyledText(string text)
Parameters
textstringThe styled text, e.g.
bold and italic.
Returns
- OutgoingMessageBuilder
This builder.
WithText(string?, TextMode)
Sets the message text.
public OutgoingMessageBuilder WithText(string? text, TextMode mode = TextMode.Normal)
Parameters
Returns
- OutgoingMessageBuilder
This builder.