Skip to content
Browse files

Updated message printing

The plain and html properties use get() to make sure they don't just up
and crash if the variant does not exist.  Also updated the printing
mechanism that will prefer plain and fallback to html, or print a 'no
message' message.
  • Loading branch information...
1 parent 62a2669 commit 225d63f48e6808edcaa42d486e6d350a3e141750 @rca committed
Showing with 3 additions and 3 deletions.
  1. +1 −1 imapbot/bot.py
  2. +2 −2 imapbot/message.py
View
2 imapbot/bot.py
@@ -65,7 +65,7 @@ def handle_message(self, message):
with open('message.txt', 'ab') as fh:
fh.write('{}\n\n'.format(message.text))
- print message.plain
+ print message.plain or message.html or 'no message'
def idle(self):
if self._is_idle:
View
4 imapbot/message.py
@@ -55,8 +55,8 @@ def parsed(self):
@property
def html(self):
- return self.parsed['text/html']
+ return self.parsed.get('text/html')
@property
def plain(self):
- return self.parsed['text/plain']
+ return self.parsed.get('text/plain')

0 comments on commit 225d63f

Please sign in to comment.
Something went wrong with that request. Please try again.