捕获OpenAI认证阶段异常

Token好像很容易过期,使用过程中突然不回复了,查日志发现Token过期了,但QQ没有提示。
This commit is contained in:
青桑 2022-12-09 12:02:04 +03:00 committed by GitHub
parent 364fe9f578
commit 505d5e30f5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -117,7 +117,12 @@ export class chatgpt extends plugin {
async chatgpt (e) { async chatgpt (e) {
let question = _.trimStart(e.msg, '#chatgpt') let question = _.trimStart(e.msg, '#chatgpt')
question = question.trimStart() 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 let c
logger.info(`chatgpt question: ${question}`) logger.info(`chatgpt question: ${question}`)
let previousConversation = await redis.get(`CHATGPT:CONVERSATIONS:${e.sender.user_id}`) let previousConversation = await redis.get(`CHATGPT:CONVERSATIONS:${e.sender.user_id}`)