From 1f84a21048aa22c452cfeecb7f23cb7f196918f5 Mon Sep 17 00:00:00 2001 From: Joseph Pan Date: Sun, 24 Dec 2017 18:21:27 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86=E5=A4=A7=E9=83=A8=E5=88=86=E5=AE=98?= =?UTF-8?q?=E6=96=B9=E6=8F=92=E4=BB=B6=E5=8A=A0=E5=85=A5=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/plugins/Camera.py | 14 +++++++------- client/plugins/Chatting.py | 4 ++-- client/plugins/Email.py | 6 +++--- client/plugins/SendQR.py | 12 ++++++------ client/plugins/Unclear.py | 2 +- client/robot.py | 20 ++++++++++---------- 6 files changed, 29 insertions(+), 29 deletions(-) diff --git a/client/plugins/Camera.py b/client/plugins/Camera.py index 61c8535..fa9d203 100755 --- a/client/plugins/Camera.py +++ b/client/plugins/Camera.py @@ -64,7 +64,7 @@ def handle(text, mic, profile, wxbot=None): if not os.path.exists(dest_path): os.makedirs(dest_path) except Exception: - mic.say(u"抱歉,照片目录创建失败") + mic.say(u"抱歉,照片目录创建失败", cache=True) return dest_file = os.path.join(dest_path, "%s.jpg" % time.time()) if usb_camera: @@ -83,7 +83,7 @@ def handle(text, mic, profile, wxbot=None): if horizontal_flip: command.append('-hf') if sound and count_down > 0: - mic.say(u"收到,%d秒后启动拍照" % (count_down)) + mic.say(u"收到,%d秒后启动拍照" % (count_down), cache=True) if usb_camera: time.sleep(count_down) @@ -91,7 +91,7 @@ def handle(text, mic, profile, wxbot=None): res = process.wait() if res != 0: if sound: - mic.say(u"拍照失败,请检查相机是否连接正确") + mic.say(u"拍照失败,请检查相机是否连接正确", cache=True) return if sound: mic.play(mic.dingdangpath.data('audio', 'camera.wav')) @@ -103,15 +103,15 @@ def handle(text, mic, profile, wxbot=None): not profile['prefers_email']): target = '微信' if sound: - mic.say(u'拍照成功!正在发送照片到您的%s' % target) + mic.say(u'拍照成功!正在发送照片到您的%s' % target, cache=True) if sendToUser(profile, wxbot, u"这是刚刚为您拍摄的照片", "", [], [dest_file]): if sound: - mic.say(u'发送成功') + mic.say(u'发送成功', cache=True) else: if sound: - mic.say(u'发送失败了') + mic.say(u'发送失败了', cache=True) else: - mic.say(u"请先在配置文件中开启相机拍照功能") + mic.say(u"请先在配置文件中开启相机拍照功能", cache=True) def isValid(text): diff --git a/client/plugins/Chatting.py b/client/plugins/Chatting.py index f381fd7..0a0b40a 100644 --- a/client/plugins/Chatting.py +++ b/client/plugins/Chatting.py @@ -21,11 +21,11 @@ def handle(text, mic, profile, wxbot=None): wxbot -- wechat bot instance """ if not any(word in text for word in [u"结束", u"停止", u"退出", u"不聊了"]): - mic.say(u"进入闲聊模式,现在跟我说说话吧") + mic.say(u"进入闲聊模式,现在跟我说说话吧", cache=True) mic.chatting_mode = True mic.skip_passive = True else: - mic.say(u"退出闲聊模式") + mic.say(u"退出闲聊模式", cache=True) mic.skip_passive = False mic.chatting_mode = False diff --git a/client/plugins/Email.py b/client/plugins/Email.py index b3c31cc..9534319 100644 --- a/client/plugins/Email.py +++ b/client/plugins/Email.py @@ -190,18 +190,18 @@ def handle(text, mic, profile, wxbot=None): if msgs is None: mic.say( - u"抱歉,您的邮箱账户验证失败了") + u"抱歉,您的邮箱账户验证失败了", cache=True) return if isinstance(msgs, int): response = "您有 %d 封未读邮件" % msgs - mic.say(response) + mic.say(response, cache=True) return senders = [getSender(e) for e in msgs] if not senders: - mic.say(u"您没有未读邮件,真棒!") + mic.say(u"您没有未读邮件,真棒!", cache=True) elif len(senders) == 1: mic.say(u"您有来自 " + senders[0] + " 的未读邮件") else: diff --git a/client/plugins/SendQR.py b/client/plugins/SendQR.py index e929905..b2c85bd 100644 --- a/client/plugins/SendQR.py +++ b/client/plugins/SendQR.py @@ -19,11 +19,11 @@ def handle(text, mic, profile, wxbot=None): wxbot -- wechat bot instance """ if 'wechat' not in profile or not profile['wechat'] or wxbot is None: - mic.say(u'请先在配置文件中开启微信接入功能') + mic.say(u'请先在配置文件中开启微信接入功能', cache=True) return if 'email' not in profile or ('enable' in profile['email'] and not profile['email']): - mic.say(u'请先配置好邮箱功能') + mic.say(u'请先配置好邮箱功能', cache=True) return sys.path.append(mic.dingdangpath.LIB_PATH) from app_utils import emailUser @@ -31,13 +31,13 @@ def handle(text, mic, profile, wxbot=None): wxbot.get_uuid() wxbot.gen_qr_code(dest_file) if os.path.exists(dest_file): - mic.say(u'正在发送微信登录二维码到您的邮箱') + mic.say(u'正在发送微信登录二维码到您的邮箱', cache=True) if emailUser(profile, u"这是您的微信登录二维码", "", [dest_file]): - mic.say(u'发送成功') + mic.say(u'发送成功', cache=True) else: - mic.say(u'发送失败') + mic.say(u'发送失败', cache=True) else: - mic.say(u"微信接入失败") + mic.say(u"微信接入失败", cache=True) def isValid(text): diff --git a/client/plugins/Unclear.py b/client/plugins/Unclear.py index 6db9b44..9bca733 100644 --- a/client/plugins/Unclear.py +++ b/client/plugins/Unclear.py @@ -33,7 +33,7 @@ def handle(text, mic, profile, wxbot=None): u"听不清楚呢,可以再为我说一次吗?", u"再说一遍好吗?"] message = random.choice(messages) - mic.say(message) + mic.say(message, cache=True) def isValid(text): diff --git a/client/robot.py b/client/robot.py index a8fb082..9ab4a7e 100644 --- a/client/robot.py +++ b/client/robot.py @@ -90,13 +90,13 @@ def chat(self, texts): if self.wxbot is not None and self.wxbot.my_account != {} \ and not self.profile['prefers_email']: target = '微信' - self.mic.say(u'一言难尽啊,我给您发%s吧' % target) + self.mic.say(u'一言难尽啊,我给您发%s吧' % target, cache=True) if sendToUser(self.profile, self.wxbot, u'回答%s' % msg, result): - self.mic.say(u'%s发送成功!' % target) + self.mic.say(u'%s发送成功!' % target, cache=True) else: - self.mic.say(u'抱歉,%s发送失败了!' % target) + self.mic.say(u'抱歉,%s发送失败了!' % target, cache=True) else: - self.mic.say(result) + self.mic.say(result, cache=True) if result.endswith('?') or result.endswith(u'?') or \ u'告诉我' in result or u'请回答' in result: self.mic.skip_passive = True @@ -104,7 +104,7 @@ def chat(self, texts): self._logger.critical("Tuling robot failed to responsed for %r", msg, exc_info=True) self.mic.say("抱歉, 我的大脑短路了 " + - "请稍后再试试.") + "请稍后再试试.", cache=True) class Emotibot(AbstractRobot): @@ -189,13 +189,13 @@ def chat(self, texts): if self.wxbot is not None and self.wxbot.my_account != {} \ and not self.profile['prefers_email']: target = '微信' - self.mic.say(u'一言难尽啊,我给您发%s吧' % target) + self.mic.say(u'一言难尽啊,我给您发%s吧' % target, cache=True) if sendToUser(self.profile, self.wxbot, u'回答%s' % msg, result): - self.mic.say(u'%s发送成功!' % target) + self.mic.say(u'%s发送成功!' % target, cache=True) else: - self.mic.say(u'抱歉,%s发送失败了!' % target) + self.mic.say(u'抱歉,%s发送失败了!' % target, cache=True) else: - self.mic.say(result) + self.mic.say(result, cache=True) if result.endswith('?') or result.endswith(u'?') or \ u'告诉我' in result or u'请回答' in result: self.mic.skip_passive = True @@ -204,7 +204,7 @@ def chat(self, texts): self._logger.critical("Emotibot failed to responsed for %r", msg, exc_info=True) self.mic.say("抱歉, 我的大脑短路了 " + - "请稍后再试试.") + "请稍后再试试.", cache=True) def get_robot_by_slug(slug):