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

Commit

Permalink
合并 dev 分支,邮件标题带有 [echo] 字样时直接阅读标题
Browse files Browse the repository at this point in the history
  • Loading branch information
wzpan committed May 25, 2017
2 parents 0881d03 + 56365fa commit c33cff8
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 7 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
2 changes: 1 addition & 1 deletion client/plugins/Camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ def handle(text, mic, profile, wxbot=None):
Arguments:
text -- user-input, typically transcribed speech
mic -- used to interact with the user (for both input and output)
wxBot -- wechat robot
profile -- contains information related to the user (e.g., phone
number)
wxbot -- wechat bot instance
"""
sys.path.append(mic.dingdangpath.LIB_PATH)
from app_utils import sendToUser
Expand Down
2 changes: 1 addition & 1 deletion client/plugins/Echo.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ def handle(text, mic, profile, wxbot=None):
Arguments:
text -- user-input, typically transcribed speech
mic -- used to interact with the user (for both input and output)
wxBot -- wechat robot
profile -- contains information related to the user (e.g., phone
number)
wxBot -- wechat robot
"""
text = text.lower().replace('echo', '').replace(u'传话', '')
mic.say(text)
Expand Down
14 changes: 11 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 Expand Up @@ -125,6 +132,7 @@ def handle(text, mic, profile, wxbot=None):
mic -- used to interact with the user (for both input and output)
profile -- contains information related to the user (e.g., email
address)
wxBot -- wechat robot
"""
try:
msgs = fetchUnreadEmails(profile, limit=5)
Expand Down
1 change: 1 addition & 0 deletions client/plugins/Time.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def handle(text, mic, profile, wxbot=None):
mic -- used to interact with the user (for both input and output)
profile -- contains information related to the user (e.g., phone
number)
wxBot -- wechat robot
"""

tz = getTimezone(profile)
Expand Down
1 change: 1 addition & 0 deletions client/plugins/Unclear.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def handle(text, mic, profile, wxbot=None):
mic -- used to interact with the user (for both input and output)
profile -- contains information related to the user (e.g., phone
number)
wxBot -- wechat robot
"""
if need_robot(profile):
robot = get_robot_by_slug("tuling")
Expand Down

0 comments on commit c33cff8

Please sign in to comment.