Fix crash when receiving MessageServices (closes #52)

This commit is contained in:
Lonami Exo 2017-04-17 09:36:24 +02:00
parent 4421c3ac7a
commit 192eb3cf57

View File

@ -149,13 +149,18 @@ class InteractiveTelegramClient(TelegramClient):
name = sender.first_name if sender else '???' name = sender.first_name if sender else '???'
# Format the message content # Format the message content
if msg.media: if getattr(msg, 'media', None):
self.found_media.add(msg) self.found_media.add(msg)
content = '<{}> {}'.format( # The media may or may not have a caption content = '<{}> {}'.format( # The media may or may not have a caption
msg.media.__class__.__name__, msg.media.__class__.__name__,
getattr(msg.media, 'caption', '')) getattr(msg.media, 'caption', ''))
else: elif hasattr(msg, 'message'):
content = 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 # And print it to the user
print('[{}:{}] (ID={}) {}: {}'.format( print('[{}:{}] (ID={}) {}: {}'.format(