Merge branch 'master' into docs
This commit is contained in:
commit
faec832f2b
@ -524,6 +524,7 @@ class Client:
|
|||||||
peer_id,
|
peer_id,
|
||||||
peer_access_hash
|
peer_access_hash
|
||||||
)
|
)
|
||||||
|
peer_id = int("-100" + str(peer_id))
|
||||||
else:
|
else:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@ -547,35 +548,38 @@ class Client:
|
|||||||
user_id=resolved_peer.users[0].id,
|
user_id=resolved_peer.users[0].id,
|
||||||
access_hash=resolved_peer.users[0].access_hash
|
access_hash=resolved_peer.users[0].access_hash
|
||||||
)
|
)
|
||||||
chat_id = input_peer.user_id
|
peer_id = input_peer.user_id
|
||||||
elif type(resolved_peer.peer) is PeerChannel:
|
elif type(resolved_peer.peer) is PeerChannel:
|
||||||
input_peer = InputPeerChannel(
|
input_peer = InputPeerChannel(
|
||||||
channel_id=resolved_peer.chats[0].id,
|
channel_id=resolved_peer.chats[0].id,
|
||||||
access_hash=resolved_peer.chats[0].access_hash
|
access_hash=resolved_peer.chats[0].access_hash
|
||||||
)
|
)
|
||||||
chat_id = input_peer.channel_id
|
peer_id = int("-100" + str(input_peer.channel_id))
|
||||||
else:
|
else:
|
||||||
raise PeerIdInvalid
|
raise PeerIdInvalid
|
||||||
|
|
||||||
self.peers_by_username[username] = input_peer
|
self.peers_by_username[username] = input_peer
|
||||||
self.peers_by_id[chat_id] = input_peer
|
self.peers_by_id[peer_id] = input_peer
|
||||||
|
|
||||||
return input_peer
|
return input_peer
|
||||||
|
|
||||||
def resolve_peer(self, chat_id: int or str):
|
def resolve_peer(self, peer_id: int or str):
|
||||||
if chat_id in ("self", "me"):
|
if peer_id in ("self", "me"):
|
||||||
return InputPeerSelf()
|
return InputPeerSelf()
|
||||||
else:
|
else:
|
||||||
if type(chat_id) is str:
|
if type(peer_id) is str:
|
||||||
chat_id = chat_id.lower().strip("@")
|
peer_id = peer_id.lower().strip("@")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return self.peers_by_username[chat_id]
|
return self.peers_by_username[peer_id]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return self.resolve_username(chat_id)
|
return self.resolve_username(peer_id)
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
return self.peers_by_id[chat_id]
|
return self.peers_by_id[peer_id]
|
||||||
|
except KeyError:
|
||||||
|
try:
|
||||||
|
return self.peers_by_id[int("-100" + str(peer_id))]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
raise PeerIdInvalid
|
raise PeerIdInvalid
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user