diff --git a/pyrogram/client/client.py b/pyrogram/client/client.py index 8f149c94..2548998c 100644 --- a/pyrogram/client/client.py +++ b/pyrogram/client/client.py @@ -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