From 17a2946311fcefa7c54362811c6f3d046a1b7d83 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Fri, 13 Apr 2018 13:08:29 +0200 Subject: [PATCH] Fix get_input_peer allow_self for custom.Dialog --- telethon/utils.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/telethon/utils.py b/telethon/utils.py index ef1e901d..ee489f90 100644 --- a/telethon/utils.py +++ b/telethon/utils.py @@ -91,9 +91,11 @@ def get_input_peer(entity, allow_self=True): if entity.SUBCLASS_OF_ID == 0xc91c90b6: # crc32(b'InputPeer') return entity except AttributeError: - if hasattr(entity, 'input_entity'): - # e.g. custom.Dialog (can't cyclic import) + # e.g. custom.Dialog (can't cyclic import). + if allow_self and hasattr(entity, 'input_entity'): return entity.input_entity + elif hasattr(entity, 'entity'): + return get_input_peer(entity.entity) else: _raise_cast_fail(entity, 'InputPeer')