From 505d5e30f5120e1b7006cbaaf52b6847819241ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9D=92=E6=A1=91?= Date: Fri, 9 Dec 2022 12:02:04 +0300 Subject: [PATCH] =?UTF-8?q?=E6=8D=95=E8=8E=B7OpenAI=E8=AE=A4=E8=AF=81?= =?UTF-8?q?=E9=98=B6=E6=AE=B5=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Token好像很容易过期,使用过程中突然不回复了,查日志发现Token过期了,但QQ没有提示。 --- index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index e8ec778..35c740c 100644 --- a/index.js +++ b/index.js @@ -117,7 +117,12 @@ export class chatgpt extends plugin { async chatgpt (e) { let question = _.trimStart(e.msg, '#chatgpt') question = question.trimStart() - await this.chatGPTApi.ensureAuth() + try { + await this.chatGPTApi.ensureAuth() + } catch (e) { + logger.error(e) + await this.reply(`OpenAI认证失败,请检查Token:${e}`, true) + } let c logger.info(`chatgpt question: ${question}`) let previousConversation = await redis.get(`CHATGPT:CONVERSATIONS:${e.sender.user_id}`)