Messages
ReceivedMessage
module-attribute
¶
ReceivedMessage: TypeAlias = (
"DataMessage | GroupUpdate | RemoteDelete | TypingMessage | EditMessage | Reaction"
)
Union of all message types parse can return.
BaseSendMessage
pydantic-model
¶
Bases: BaseModel
Fields shared by every outgoing message, regardless of recipient shape.
Fields:
-
base64_attachments(list[str] | None) -
attachments(list[PydanticPath] | None) -
edit_timestamp(int | None) -
link_preview(LinkPreview | None) -
mentions(list[MessageMention] | None) -
text(str | None) -
notify_self(bool | None) -
quote_author(str | None) -
quote_mentions(list[MessageMention] | None) -
quote_text(str | None) -
quote_timestamp(int | None) -
sticker(str | None) -
text_mode(TextMode | None) -
view_once(bool | None)
Validators:
-
check_link_preview_url_in_text
Source code in src/signalbot/messages/send_message.py
DataMessage
pydantic-model
¶
Bases: BaseMessageWithGroup
Fields:
-
server_delivered_timestamp(int) -
server_received_timestamp(int) -
source(str | None) -
source_device(int | None) -
source_name(str | None) -
source_number(str | None) -
source_uuid(str | None) -
group_info(GroupInfo | None) -
attachments(list[Attachment] | None) -
expires_in_seconds(int | None) -
mentions(list[Mention] | None) -
text(str | None) -
previews(list[Preview] | None) -
base64_previews(list[str] | None) -
quote(Quote | None) -
sticker(Sticker | None) -
text_styles(list[TextStyle] | None) -
timestamp(int) -
view_once(bool | None)
Source code in src/signalbot/messages/data_message.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 | |
to_send_message ¶
to_send_message() -> SendMessage
Convert the received message to a SendMessage that can be sent using the API.
Returns:
| Type | Description |
|---|---|
SendMessage
|
A SendMessage object that can be sent using the API. |
Source code in src/signalbot/messages/data_message.py
EditMessage
pydantic-model
¶
Bases: DataMessage
A DataMessage that replaces an earlier message the sender previously sent.
Fields:
-
server_delivered_timestamp(int) -
server_received_timestamp(int) -
source(str | None) -
source_device(int | None) -
source_name(str | None) -
source_number(str | None) -
source_uuid(str | None) -
timestamp(int) -
group_info(GroupInfo | None) -
attachments(list[Attachment] | None) -
expires_in_seconds(int | None) -
mentions(list[Mention] | None) -
text(str | None) -
previews(list[Preview] | None) -
base64_previews(list[str] | None) -
quote(Quote | None) -
sticker(Sticker | None) -
text_styles(list[TextStyle] | None) -
view_once(bool | None) -
target_sent_timestamp(int)
Source code in src/signalbot/messages/edit_message.py
LinkPreview
pydantic-model
¶
Bases: BaseModel
A link preview to attach to an outgoing message.
Fields:
-
description(str) -
title(str) -
url(str) -
thumbnail(PydanticPath | str)
Source code in src/signalbot/messages/link_preview.py
thumbnail
pydantic-field
¶
thumbnail: PydanticPath | str
The thumbnail of the link preview. This can be a Path or a base64 encoded string of the image content.
Mention
pydantic-model
¶
MessageMention
pydantic-model
¶
Bases: MessageMention
A mention to attach to an outgoing message, via SendMessage.mentions/
quote_mentions.
Fields:
Source code in src/signalbot/messages/message_mention.py
Preview
pydantic-model
¶
Bases: Preview
The preview metadata Signal already generated for a link in a received message.
Fields:
-
description(str | None) -
title(str | None) -
url(str | None) -
base64_thumbnail(str | None) -
image(Attachment | None)
Source code in src/signalbot/messages/link_preview.py
Quote
pydantic-model
¶
Bases: Quote
The quoted message a received message replies to.
Fields:
-
author(str | None) -
author_number(str | None) -
author_uuid(str | None) -
id(int) -
text(str | None) -
attachments(list[QuotedAttachment] | None) -
mentions(list[Mention] | None) -
text_styles(list[TextStyle] | None)
Source code in src/signalbot/messages/data_message_content.py
QuotedAttachment
pydantic-model
¶
Bases: QuotedAttachment
An attachment on the message a received message quotes.
Fields:
-
content_type(str | None) -
filename(str | None) -
thumbnail(Attachment | None)
Source code in src/signalbot/messages/data_message_content.py
ReceiveError ¶
Bases: SignalAPIError
Raised when the receive websocket connection fails or is interrupted.
Source code in src/signalbot/_client/messages.py
RemoteDelete
pydantic-model
¶
Bases: BaseMessageWithGroup
Notification that a previously sent message was deleted by its sender.
Fields:
-
server_delivered_timestamp(int) -
server_received_timestamp(int) -
source(str | None) -
source_device(int | None) -
source_name(str | None) -
source_number(str | None) -
source_uuid(str | None) -
timestamp(int) -
group_info(GroupInfo | None)
Source code in src/signalbot/messages/remote_delete.py
RemoteDeleteError ¶
Bases: SignalAPIError
Raised when the API rejects a remote-delete request.
Source code in src/signalbot/_client/messages.py
SendError ¶
Bases: SignalAPIError
Raised when the API rejects a message send request.
Source code in src/signalbot/_client/messages.py
SendMessage
pydantic-model
¶
Bases: BaseSendMessage
A message to send to one or more recipients (contacts or groups).
Fields:
-
base64_attachments(list[str] | None) -
attachments(list[PydanticPath] | None) -
edit_timestamp(int | None) -
link_preview(LinkPreview | None) -
mentions(list[MessageMention] | None) -
text(str | None) -
notify_self(bool | None) -
quote_author(str | None) -
quote_mentions(list[MessageMention] | None) -
quote_text(str | None) -
quote_timestamp(int | None) -
sticker(str | None) -
text_mode(TextMode | None) -
view_once(bool | None)
Validators:
-
check_link_preview_url_in_text
Source code in src/signalbot/messages/send_message.py
SentMessage
pydantic-model
¶
Bases: BaseSendMessage
A record of a message after it was successfully sent to one recipient.
Fields:
-
base64_attachments(list[str] | None) -
attachments(list[PydanticPath] | None) -
edit_timestamp(int | None) -
link_preview(LinkPreview | None) -
mentions(list[MessageMention] | None) -
text(str | None) -
notify_self(bool | None) -
quote_author(str | None) -
quote_mentions(list[MessageMention] | None) -
quote_text(str | None) -
quote_timestamp(int | None) -
sticker(str | None) -
text_mode(TextMode | None) -
view_once(bool | None) -
recipient(str) -
timestamp(int)
Validators:
-
check_link_preview_url_in_text
Source code in src/signalbot/messages/send_message.py
StartTypingError ¶
Bases: TypingError
Raised when the API rejects a request to start a typing indicator.
Source code in src/signalbot/_client/messages.py
Sticker
pydantic-model
¶
StopTypingError ¶
Bases: TypingError
Raised when the API rejects a request to stop a typing indicator.
Source code in src/signalbot/_client/messages.py
TextStyle
pydantic-model
¶
TypingAction ¶
TypingError ¶
Bases: SignalAPIError
Base class for errors updating a typing indicator.
Source code in src/signalbot/_client/messages.py
TypingMessage
pydantic-model
¶
Bases: BaseMessage
A typing indicator received from a contact or group.
Fields:
-
server_delivered_timestamp(int) -
server_received_timestamp(int) -
source(str | None) -
source_device(int | None) -
source_name(str | None) -
source_number(str | None) -
source_uuid(str | None) -
action(TypingAction) -
group_id(str | None) -
timestamp(int)
Source code in src/signalbot/messages/typing_message.py
UnknownMessageFormatError ¶
Bases: SignalAPIError
Exception raised when a message with an unknown format is encountered.
Source code in src/signalbot/messages/parser.py
parse
async
¶
parse(
signal: SignalAPI, raw_message_str: str
) -> ReceivedMessage
Parse a raw JSON message string from the Signal API into a Message object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
signal
|
SignalAPI
|
An instance of the |
required |
raw_message_str
|
str
|
The raw JSON string of the message as received from the Signal API. |
required |
Returns:
| Type | Description |
|---|---|
ReceivedMessage
|
A |
Raises:
| Type | Description |
|---|---|
UnknownMessageFormatError
|
If the message format is unrecognized or if required fields are missing. |