From cc9eaa55ec1090d49a3263ff86f8d4b5f233b038 Mon Sep 17 00:00:00 2001 From: Milin <417156994@qq.com> Date: Mon, 8 May 2023 15:15:07 +0800 Subject: [PATCH] fix: When the bot is abnormal, it returns a prompt message instead of an exception message. --- src/chatbot.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/chatbot.ts b/src/chatbot.ts index cae82e0..8674722 100644 --- a/src/chatbot.ts +++ b/src/chatbot.ts @@ -65,6 +65,8 @@ export class ChatBot { weChatBot: Wechaty; + errorResponse = "机器人异常,请稍后再试或联系管理员!"; + constructor(weChatBot: Wechaty) { this.weChatBot = weChatBot; } @@ -171,8 +173,8 @@ export class ChatBot { } replyCallback(responseData); }).catch((error) => { + replyCallback(this.constructResponseData(Constants.responseStatus.failed, this.errorResponse)); Logger.error(error); - replyCallback(this.constructResponseData(Constants.responseStatus.failed, error.message)); }); } @@ -194,7 +196,7 @@ export class ChatBot { await chatbot.askResponse(requestId, replyCallback, intervalId) }, 2000); }).catch((error) => { - replyCallback(this.constructResponseData(Constants.responseStatus.failed, error.message)); + replyCallback(this.constructResponseData(Constants.responseStatus.failed, this.errorResponse)); Logger.error(error); }); }