-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New accounts dont have phone numbers, _is_phone_number receives null and fails #48
Comments
This does happen when the user is added through the new "username" feature - ether manually or by QR code. have successfully tested this: diff --git a/signalbot/bot.py b/signalbot/bot.py
index e8c8013..5011119 100644
--- a/signalbot/bot.py
+++ b/signalbot/bot.py
@@ -7,6 +7,7 @@ import traceback
from typing import Optional, Union, List, Callable
import re
import phonenumbers
+import uuid
from .api import SignalAPI, ReceiveMessagesError
from .command import Command
@@ -238,6 +239,9 @@ class SignalBot:
logging.info(f"[Bot] {len(self.groups)} groups detected")
def _resolve_receiver(self, receiver: str) -> str:
+ if self._is_valid_uuid(receiver):
+ return receiver
+
if self._is_phone_number(receiver):
return receiver
@@ -251,6 +255,13 @@ class SignalBot:
except Exception:
raise SignalBotError(f"Cannot resolve receiver.")
+ def _is_valid_uuid(self, receiver_uuid: str):
+ try:
+ uuid.UUID(str(receiver_uuid))
+ return True
+ except ValueError:
+ return False
+
def _is_phone_number(self, phone_number: str) -> bool:
try:
parsed_number = phonenumbers.parse(phone_number, None)
when a message is received via number the UUID is not used. @filipre any chance to get this feature any time soon? <3 |
Hey! Thanks for looking into this. Do you want to open a PR? Then I can create a pre-release for you to test, too. |
I can create a PR. but i can create the PR anyway. maybe later this evening. |
After recent updates, account may not have phone number, sending message to it causes error " Error: Cannot resolve receiver."
Probable fix: adjust function
_resolve_receiver
with:But some other additional in changes
bot.py
might be neededThe text was updated successfully, but these errors were encountered: