Accept phone numbers with and without a leading "+"

This commit is contained in:
Dan 2018-02-20 15:48:10 +01:00
parent c5281eb963
commit 5a44b93574

View File

@ -800,19 +800,21 @@ class Client:
if peer_id in ("self", "me"):
return InputPeerSelf()
if peer_id.startswith("+"):
peer_id = peer_id.lower().strip("@+")
try:
int(peer_id)
except ValueError:
try:
return self.peers_by_username[peer_id]
except KeyError:
return self.resolve_username(peer_id)
else:
try:
return self.peers_by_phone[peer_id]
except KeyError:
raise PeerIdInvalid
peer_id = peer_id.lower().strip("@")
try:
return self.peers_by_username[peer_id]
except KeyError:
return self.resolve_username(peer_id)
if type(peer_id) is not int:
if isinstance(peer_id, types.PeerUser):
peer_id = peer_id.user_id