diff options
author | niklas <niklas@niklashalle.net> | 2020-08-24 14:21:07 +0200 |
---|---|---|
committer | niklas <niklas@niklashalle.net> | 2020-08-24 14:21:07 +0200 |
commit | f2eb87da9f3b3a26f893809c9b517490e4c99b67 (patch) | |
tree | 8ae7788136b5ff34ef6dc90aebb441f8249d1dc8 | |
parent | e87b2ece9255205bee339287bac6c13996ed32a4 (diff) | |
download | pysignald-f2eb87da9f3b3a26f893809c9b517490e4c99b67.tar.gz pysignald-f2eb87da9f3b3a26f893809c9b517490e4c99b67.zip |
rudimentary fixes
-rw-r--r-- | signald/main.py | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/signald/main.py b/signald/main.py index 222c89f..cfaa79c 100644 --- a/signald/main.py +++ b/signald/main.py @@ -67,7 +67,7 @@ class Signal: continue if data["type"] == "unexpected_error": - raise ValueError("unexpected error occurred") + raise ValueError("unexpected error occurred: " + str(line)) def register(self, voice=False): """ @@ -98,9 +98,10 @@ class Signal: except json.JSONDecodeError: print("Invalid JSON") - if message.get("type") != "message" or ( - not message["data"]["isReceipt"] and message["data"].get("dataMessage") is None - ): + #print("type: " + message.get("type")) + if message.get("type") != "message": #or ( + #not message["data"]["isReceipt"] and message["data"].get("dataMessage") is None + #): # If the message type isn't "message", or if it's a weird message whose # purpose I don't know, return. I think the weird message is a typing # notification. @@ -112,13 +113,13 @@ class Signal: yield Message( username=message["username"], source=message["source"], - text=data_message.get("message"), + text=data_message.get("body"), source_device=message["sourceDevice"], timestamp=data_message.get("timestamp"), timestamp_iso=message["timestampISO"], expiration_secs=data_message.get("expiresInSeconds"), - is_receipt=message["isReceipt"], - group_info=data_message.get("groupInfo", {}), +# is_receipt=message["isReceipt"], + group_info=data_message.get("group", {}), attachments=[ Attachment( content_type=attachment["contentType"], @@ -140,6 +141,7 @@ class Signal: are any errors. """ payload = {"type": "send", "username": self.username, "recipientAddress": recipient, "messageBody": text} +# print(f"payload: {payload}") self._send_command(payload, block) def send_group_message(self, recipient_group_id: str, text: str, block: bool = False) -> None: @@ -181,7 +183,7 @@ class Signal: for message in self.receive_messages(): if not message.text: continue - + #print("text: " + message.text) for _, regex, func in self._chat_handlers: match = re.search(regex, message.text) if not match: |