From f2eb87da9f3b3a26f893809c9b517490e4c99b67 Mon Sep 17 00:00:00 2001 From: niklas Date: Mon, 24 Aug 2020 14:21:07 +0200 Subject: rudimentary fixes --- signald/main.py | 18 ++++++++++-------- 1 file 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: -- cgit v1.2.3-54-g00ecf