mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-06-18 02:56:39 +00:00
Expect UserEmpty on get_input_entity
This commit is contained in:
parent
d892a537a7
commit
ca2c8687c8
@ -322,7 +322,14 @@ class UserMethods(TelegramBaseClient):
|
|||||||
if isinstance(peer, types.PeerUser):
|
if isinstance(peer, types.PeerUser):
|
||||||
users = await self(functions.users.GetUsersRequest([
|
users = await self(functions.users.GetUsersRequest([
|
||||||
types.InputUser(peer.user_id, access_hash=0)]))
|
types.InputUser(peer.user_id, access_hash=0)]))
|
||||||
if users:
|
if users and not isinstance(users[0], types.UserEmpty):
|
||||||
|
# If the user passed a valid ID they expect to work for
|
||||||
|
# channels but would be valid for users, we get UserEmpty.
|
||||||
|
# Avoid returning the invalid empty input peer for that.
|
||||||
|
#
|
||||||
|
# We *could* try to guess if it's a channel first, and if
|
||||||
|
# it's not, work as a chat and try to validate it through
|
||||||
|
# another request, but that becomes too much work.
|
||||||
return utils.get_input_peer(users[0])
|
return utils.get_input_peer(users[0])
|
||||||
elif isinstance(peer, types.PeerChat):
|
elif isinstance(peer, types.PeerChat):
|
||||||
return types.InputPeerChat(peer.chat_id)
|
return types.InputPeerChat(peer.chat_id)
|
||||||
|
Loading…
Reference in New Issue
Block a user