aboutsummaryrefslogtreecommitdiffstats
path: root/signald/main.py
diff options
context:
space:
mode:
authorNiklas Halle <niklas@niklashalle.net>2020-09-18 17:19:12 +0200
committerNiklas Halle <niklas@niklashalle.net>2020-09-18 17:19:12 +0200
commit77363255ef2f69212c0aeb874d82cd15273ddcd4 (patch)
treeede24e71753c2b2e0b47cbd27824acc09fa9ffda /signald/main.py
parenta4c7361fdaa91c805081abfd7f593244fc008217 (diff)
downloadpysignald-77363255ef2f69212c0aeb874d82cd15273ddcd4.tar.gz
pysignald-77363255ef2f69212c0aeb874d82cd15273ddcd4.zip
implement (basic) attachment sending
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.