Skip to content
This repository has been archived by the owner on Apr 13, 2018. It is now read-only.

Commit

Permalink
调整邮箱的播报,带 [echo] 的将只阅读标题
Browse files Browse the repository at this point in the history
  • Loading branch information
wzpan committed May 25, 2017
1 parent c420e22 commit 4547116
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
7 changes: 5 additions & 2 deletions client/notifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,11 @@ def handleEmailNotifications(self, lastDate):
lastDate = Email.getMostRecentDate(emails)

def styleEmail(e):
return "您有来自 %s 的新邮件 %s" % (Email.getSender(e), Email.getSubject(e, self.profile))

subject = Email.getSubject(e, self.profile)
if '[echo]' in subject:
return subject.replace('[echo]', '')
sender = Email.getSender(e)
return "您有来自 %s 的新邮件 %s" % (sender, subject)
for e in emails:
self.q.put(styleEmail(e))

Expand Down
13 changes: 10 additions & 3 deletions client/plugins/Email.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ def getSender(msg):
if(len(ls) == 2):
fromname = email.Header.decode_header((ls[0]).strip('\"'))
sender = my_unicode(fromname[0][0], fromname[0][1])
elif(len(ls) > 2):
fromname = email.Header.decode_header((msg[:msg.find('<')]).strip('\"'))
sender = my_unicode(fromname[0][0], fromname[0][1])
else:
sender = msg['From']
return sender
Expand All @@ -44,12 +47,16 @@ def getSubject(msg, profile):
Title of the email.
"""
subject = email.Header.decode_header(msg['subject'])
sub = my_unicode(subject[0][0], subject[0][1]).replace('[read]', '')
sub = my_unicode(subject[0][0], subject[0][1])
to_read = False
if sub.strip() == '':
return ''
if 'read_email_title' in profile:
to_read = profile['read_email_title']
if '[read]' in subject or to_read:
return u',邮件标题为:' + sub
if '[echo]' in sub:
return sub
if to_read:
return '邮件标题为 %s' % sub
return ''


Expand Down

0 comments on commit 4547116

Please sign in to comment.