From 192eb3cf5767bdc81f0ac1cfa4e092da8dbe7d3b Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Mon, 17 Apr 2017 09:36:24 +0200 Subject: [PATCH] Fix crash when receiving MessageServices (closes #52) --- telethon/interactive_telegram_client.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/telethon/interactive_telegram_client.py b/telethon/interactive_telegram_client.py index 1cfb03b0..cce53001 100644 --- a/telethon/interactive_telegram_client.py +++ b/telethon/interactive_telegram_client.py @@ -149,13 +149,18 @@ class InteractiveTelegramClient(TelegramClient): name = sender.first_name if sender else '???' # Format the message content - if msg.media: + if getattr(msg, 'media', None): self.found_media.add(msg) content = '<{}> {}'.format( # The media may or may not have a caption msg.media.__class__.__name__, getattr(msg.media, 'caption', '')) - else: + elif hasattr(msg, 'message'): content = msg.message + elif hasattr(msg, 'action'): + content = str(msg.action) + else: + # Unknown message, simply print its class name + content = msg.__class__.__name__ # And print it to the user print('[{}:{}] (ID={}) {}: {}'.format(