Skip to content

Commit

Permalink
add '_is_valid_uuid()' to '_resolve_receiver()' for users without number
Browse files Browse the repository at this point in the history
  • Loading branch information
Kariton committed Jun 2, 2024
1 parent 9ab791e commit cfe7b56
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions signalbot/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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.
Expand Down

0 comments on commit cfe7b56

Please sign in to comment.