diff --git a/client/notifier.py b/client/notifier.py index b93cfd7..f970a5b 100644 --- a/client/notifier.py +++ b/client/notifier.py @@ -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)) diff --git a/client/plugins/Camera.py b/client/plugins/Camera.py index 1cf0ec5..01ac821 100644 --- a/client/plugins/Camera.py +++ b/client/plugins/Camera.py @@ -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 diff --git a/client/plugins/Echo.py b/client/plugins/Echo.py index 57be22d..2b3159a 100644 --- a/client/plugins/Echo.py +++ b/client/plugins/Echo.py @@ -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) diff --git a/client/plugins/Email.py b/client/plugins/Email.py index 7b234a0..79338f2 100644 --- a/client/plugins/Email.py +++ b/client/plugins/Email.py @@ -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 @@ -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 '' @@ -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) diff --git a/client/plugins/Time.py b/client/plugins/Time.py index 4f02350..58758c7 100644 --- a/client/plugins/Time.py +++ b/client/plugins/Time.py @@ -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) diff --git a/client/plugins/Unclear.py b/client/plugins/Unclear.py index b66d90d..b7a7ff0 100644 --- a/client/plugins/Unclear.py +++ b/client/plugins/Unclear.py @@ -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")