Fix get_input_peer allow_self for custom.Dialog

This commit is contained in:
Lonami Exo 2018-04-13 13:08:29 +02:00
parent 3bf259d6b3
commit 17a2946311

View File

@ -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')