Allow passing entities instead input_peers and more*

Some fixes to the interactive client (not handling
invalid options, errors when uploading files)
This commit is contained in:
Lonami Exo
2017-01-17 20:22:47 +01:00
parent 8e48455cdc
commit 9ca4471bcd
3 changed files with 36 additions and 32 deletions

View File

@@ -44,6 +44,11 @@ def get_extension(media):
def get_input_peer(entity):
"""Gets the input peer for the given "entity" (user, chat or channel).
Returns None if it was not found"""
if (isinstance(entity, InputPeerUser) or
isinstance(entity, InputPeerChat) or
isinstance(entity, InputPeerChannel)):
return entity
if isinstance(entity, User):
return InputPeerUser(entity.id, entity.access_hash)
if isinstance(entity, Chat):