aboutsummaryrefslogtreecommitdiffstats
path: root/signald/main.py
diff options
context:
space:
mode:
Diffstat (limited to 'signald/main.py')
-rw-r--r--signald/main.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/signald/main.py b/signald/main.py
index 7373b65..414d82b 100644
--- a/signald/main.py
+++ b/signald/main.py
@@ -145,6 +145,27 @@ class Signal:
payload = {"type": "send", "username": self.username, "recipientAddress": recipient, "messageBody": text}
self._send_command(payload, block)
+ def send_attachment(self, recipient: str, filename: str, block: bool = True) -> None:
+ """
+ Send an attachment.
+
+ recipient: The recipient's phone number, in E.123 format.
+ filename: The filename of the attachment to send.
+ block: Whether to block while sending. If you choose not to block, you won't get an exception if there
+ are any errors.
+ """
+ payload = {
+ "type": "send",
+ "username": self.username,
+ "recipientAddress": recipient,
+ "attachments": [
+ {
+ "filename": filename
+ }
+ ]
+ }
+ self._send_command(payload, block)
+
def send_group_message(self, recipient_group_id: str, text: str, block: bool = False) -> None:
"""
Send a group message.
@@ -162,6 +183,27 @@ class Signal:
}
self._send_command(payload, block)
+ def send_group_attachment(self, recipient_group_id: str, filename: str, block: bool = False) -> None:
+ """
+ Send an attachment to a group.
+
+ recipient: The recipient's phone number, in E.123 format.
+ filename: The filename of the attachment to send.
+ block: Whether to block while sending. If you choose not to block, you won't get an exception if there
+ are any errors.
+ """
+ payload = {
+ "type": "send",
+ "username": self.username,
+ "recipientGroupId": recipient_group_id,
+ "attachments": [
+ {
+ "filename": filename
+ }
+ ]
+ }
+ self._send_command(payload, block)
+
def chat_handler(self, regex, order=100):
"""
A decorator that registers a chat handler function with a regex.