Message
Message
dataclass
¶
Message(
source: str,
source_number: str | None,
source_uuid: str,
timestamp: int,
type: MessageType,
text: str,
base64_attachments: list[str] = list(),
attachments_local_filenames: list[str] = list(),
view_once: bool = False,
link_previews: list[LinkPreview] = list(),
group: str | None = None,
reaction: str | None = None,
mentions: list[str] = list(),
quote: Quote | None = None,
read_messages: list[dict] | None = None,
target_sent_timestamp: int | None = None,
remote_delete_timestamp: int | None = None,
updated_group_id: str | None = None,
raw_message: str | None = None,
)
Class representing a Signal message.
Attributes:
| Name | Type | Description |
|---|---|---|
source |
str
|
The phone number or UUID of the sender of the message. |
source_number |
str | None
|
The phone number of the sender of the message.
This is |
source_uuid |
str
|
The UUID of the sender of the message. |
timestamp |
int
|
The timestamp of when the message was sent. |
type |
MessageType
|
The type of the message. |
text |
str
|
The text content of the message. |
base64_attachments |
list[str]
|
A list of attachments in the message, encoded as base64 strings. |
attachments_local_filenames |
list[str]
|
A list of local filenames for the attachments in the message. |
view_once |
bool
|
A boolean indicating whether the message is a view-once message. |
link_previews |
list[LinkPreview]
|
A list of |
group |
str | None
|
The UUID of the group chat the message was sent in, or |
reaction |
str | None
|
The reaction emoji if the message is a reaction. |
mentions |
list[str]
|
A list of UUIDs of users mentioned in the message. |
quote |
Quote | None
|
An object representing the quoted message if the message is a quote. |
read_messages |
list[dict] | None
|
A list of dictionaries representing the messages that have been
read if the message is a |
target_sent_timestamp |
int | None
|
The timestamp of the original message that was edited, if
the message is a |
remote_delete_timestamp |
int | None
|
The timestamp of the original message that was deleted,
the message is a |
updated_group_id |
str | None
|
The UUID of the group that was updated, if the message is a
|
raw_message |
str | None
|
The raw JSON string of the message as received from the Signal API. |
is_group ¶
is_group() -> bool
Check if the message is a group message.
Returns:
| Type | Description |
|---|---|
bool
|
True if the message is a group message, False otherwise. |
Source code in src/signalbot/message.py
116 117 118 119 120 121 122 | |
is_private ¶
is_private() -> bool
Check if the message is a private (one-on-one) message.
Returns:
| Type | Description |
|---|---|
bool
|
True if the message is a private (one-on-one) message, False otherwise. |
Source code in src/signalbot/message.py
107 108 109 110 111 112 113 114 | |
parse
async
classmethod
¶
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 |
|---|---|
Message
|
A |
Raises:
| Type | Description |
|---|---|
UnknownMessageFormatError
|
If the message format is unrecognized or if required fields are missing. |
Source code in src/signalbot/message.py
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 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 | |
recipient ¶
recipient() -> str
Get the recipient of the message, which is either the group ID for group chats or the source ID for user chats.
Returns:
| Type | Description |
|---|---|
str
|
The recipient ID of the message. |
Source code in src/signalbot/message.py
93 94 95 96 97 98 99 100 101 102 103 104 105 | |
MessageType ¶
Bases: Enum
Enum representing the type of a Signal message.
Attributes:
| Name | Type | Description |
|---|---|---|
SYNC_MESSAGE |
Message received in a linked device |
|
DATA_MESSAGE |
Message received in a primary device |
|
EDIT_MESSAGE |
Message received is an edit of a previous message |
|
DELETE_MESSAGE |
Message received is a remote delete of a previous message |
|
READ_MESSAGE |
User read some messages |
|
GROUP_UPDATE_MESSAGE |
An update has been made to a group |
|
CONTACT_SYNC_MESSAGE |
Message received is a contact sync |