Fix handling of ChannelForbidden in input peer, bump v1.10.3

This commit is contained in:
Lonami Exo 2019-09-12 22:30:47 +02:00
parent 9c06f29aaf
commit c1774276c2
2 changed files with 6 additions and 2 deletions

View File

@ -189,11 +189,15 @@ def get_input_peer(entity, allow_self=True, check_hash=True):
if isinstance(entity, (types.Chat, types.ChatEmpty, types.ChatForbidden)): if isinstance(entity, (types.Chat, types.ChatEmpty, types.ChatForbidden)):
return types.InputPeerChat(entity.id) return types.InputPeerChat(entity.id)
if isinstance(entity, (types.Channel, types.ChannelForbidden)): if isinstance(entity, types.Channel):
if (entity.access_hash is not None and not entity.min) or not check_hash: if (entity.access_hash is not None and not entity.min) or not check_hash:
return types.InputPeerChannel(entity.id, entity.access_hash) return types.InputPeerChannel(entity.id, entity.access_hash)
else: else:
raise TypeError('Channel without access_hash or min info cannot be input') raise TypeError('Channel without access_hash or min info cannot be input')
if isinstance(entity, types.ChannelForbidden):
# "channelForbidden are never min", and since their hash is
# also not optional, we assume that this truly is the case.
return types.InputPeerChannel(entity.id, entity.access_hash)
if isinstance(entity, types.InputUser): if isinstance(entity, types.InputUser):
return types.InputPeerUser(entity.user_id, entity.access_hash) return types.InputPeerUser(entity.user_id, entity.access_hash)

View File

@ -1,3 +1,3 @@
# Versions should comply with PEP440. # Versions should comply with PEP440.
# This line is parsed in setup.py: # This line is parsed in setup.py:
__version__ = '1.10.2' __version__ = '1.10.3'