From c1774276c2ae706593ab1965e07a154ea53aa3f1 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Thu, 12 Sep 2019 22:30:47 +0200 Subject: [PATCH] Fix handling of ChannelForbidden in input peer, bump v1.10.3 --- telethon/utils.py | 6 +++++- telethon/version.py | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/telethon/utils.py b/telethon/utils.py index 7654f7ab..05ab8ce7 100644 --- a/telethon/utils.py +++ b/telethon/utils.py @@ -189,11 +189,15 @@ def get_input_peer(entity, allow_self=True, check_hash=True): if isinstance(entity, (types.Chat, types.ChatEmpty, types.ChatForbidden)): 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: return types.InputPeerChannel(entity.id, entity.access_hash) else: 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): return types.InputPeerUser(entity.user_id, entity.access_hash) diff --git a/telethon/version.py b/telethon/version.py index 26d676d1..7d082dfc 100644 --- a/telethon/version.py +++ b/telethon/version.py @@ -1,3 +1,3 @@ # Versions should comply with PEP440. # This line is parsed in setup.py: -__version__ = '1.10.2' +__version__ = '1.10.3'