From cfe7b56176272d97dc67b23e1639ee2a40f7cbb3 Mon Sep 17 00:00:00 2001 From: Kariton <67470612+Kariton@users.noreply.github.com> Date: Sun, 2 Jun 2024 21:51:41 +0200 Subject: [PATCH 1/4] add '_is_valid_uuid()' to '_resolve_receiver()' for users without number --- signalbot/bot.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/signalbot/bot.py b/signalbot/bot.py index ab806fd..8e69191 100644 --- a/signalbot/bot.py +++ b/signalbot/bot.py @@ -6,6 +6,7 @@ import traceback from typing import Optional, Union, List, Callable import re +import uuid from .api import SignalAPI, ReceiveMessagesError from .command import Command @@ -240,6 +241,9 @@ def _resolve_receiver(self, receiver: str) -> str: if self._is_phone_number(receiver): return receiver + if self._is_valid_uuid(receiver): + return receiver + if self._is_group_id(receiver): return receiver @@ -259,6 +263,13 @@ def _is_phone_number(self, phone_number: str) -> bool: return False return True + def _is_valid_uuid(self, receiver_uuid: str): + try: + uuid.UUID(str(receiver_uuid)) + return True + except ValueError: + return False + def _is_group_id(self, group_id: str) -> bool: """Check if group_id has the right format, e.g. From 9a56d3c39e48e4e229686bd279849ad4e2eed018 Mon Sep 17 00:00:00 2001 From: Era Dorta <era.dorta@proton.me> Date: Tue, 18 Jun 2024 23:01:21 +0200 Subject: [PATCH 2/4] Add source number and uuid to the message attributes --- signalbot/message.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/signalbot/message.py b/signalbot/message.py index 3aa7b36..28e2f52 100644 --- a/signalbot/message.py +++ b/signalbot/message.py @@ -1,6 +1,6 @@ import json from enum import Enum - +from typing import Optional class MessageType(Enum): SYNC_MESSAGE = 1 @@ -11,6 +11,8 @@ class Message: def __init__( self, source: str, + source_number: Optional[str], + source_uuid: str, timestamp: int, type: MessageType, text: str, @@ -22,6 +24,8 @@ def __init__( ): # required self.source = source + self.source_number = source_number + self.source_uuid = source_uuid self.timestamp = timestamp self.type = type self.text = text @@ -65,10 +69,13 @@ def parse(cls, raw_message: str): # General attributes try: source = raw_message["envelope"]["source"] + source_uuid = raw_message["envelope"]["sourceUuid"] timestamp = raw_message["envelope"]["timestamp"] except Exception: raise UnknownMessageFormatError + source_number = raw_message["envelope"].get("sourceNumber") + # Option 1: syncMessage if "syncMessage" in raw_message["envelope"]: type = MessageType.SYNC_MESSAGE @@ -99,6 +106,8 @@ def parse(cls, raw_message: str): return cls( source, + source_number, + source_uuid, timestamp, type, text, From bc6c863444e886da97bbe6ebba874cd16a133291 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Filip?= <renefilip@mail.com> Date: Wed, 17 Jul 2024 23:31:31 +0200 Subject: [PATCH 3/4] Fix formatting issues --- signalbot/message.py | 1 + 1 file changed, 1 insertion(+) diff --git a/signalbot/message.py b/signalbot/message.py index 28e2f52..9f0c4d4 100644 --- a/signalbot/message.py +++ b/signalbot/message.py @@ -2,6 +2,7 @@ from enum import Enum from typing import Optional + class MessageType(Enum): SYNC_MESSAGE = 1 DATA_MESSAGE = 2 From 628ea8059dda0ca668ec2b0af60770e160ae6713 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Filip?= <rene.filip@sizekick.io> Date: Tue, 6 Aug 2024 22:19:53 +0200 Subject: [PATCH 4/4] Bump version to 0.10.1 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 5505d27..1616ab4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,7 +18,7 @@ maintainers = ["René Filip"] name = "signalbot" readme = "README.md" repository = "https://github.com/filipre/signalbot" -version = "0.9.2" +version = "0.10.1" [tool.poetry.dependencies] APScheduler = "^3.9.1"