From aee04eefe887ad69609a7fe5ed341c43882faa2d Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Fri, 23 Feb 2018 21:32:38 +0100 Subject: [PATCH] Remove hacky print --- .../interactive_telegram_client.py | 20 ++++--------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/telethon_examples/interactive_telegram_client.py b/telethon_examples/interactive_telegram_client.py index ae868837..9baed634 100644 --- a/telethon_examples/interactive_telegram_client.py +++ b/telethon_examples/interactive_telegram_client.py @@ -273,22 +273,10 @@ class InteractiveTelegramClient(TelegramClient): print('No profile picture found for this user!') elif msg == '!i': - blacklist_attrs = ['from_reader', 'on_response', 'pretty_format', 'resolve', 'rpc_error', - 'serialize_bytes', 'serialize_datetime', 'stringify', 'to_dict', - 'constructor_id', 'subclass_of_id', 'confirm_received', 'result'] - interesting_attributes = [ - x for x in dir(entity) - if x.lower() not in blacklist_attrs and not (x.startswith('_') or x.startswith('__')) - ] - - longest_attr = max(len(x) for x in interesting_attributes) - - for attr in interesting_attributes: - print("{:<{width}} : {}".format( - attr, - getattr(entity, attr, ''), - width=longest_attr) - ) + attributes = list(entity.to_dict().items()) + pad = max(len(x) for x, _ in attributes) + for name, val in attributes: + print("{:<{width}} : {}".format(name, val, width=pad)) # Send chat message (if any) elif msg: