From 375fad8a20ee9f1f38ebb9ebacbb28c87e7928f1 Mon Sep 17 00:00:00 2001 From: ikechan8370 Date: Thu, 25 May 2023 18:54:55 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=BF=85=E5=BA=94=E6=97=A0=E9=9C=80tok?= =?UTF-8?q?en=E5=8D=B3=E5=8F=AF=E8=BF=9B=E8=A1=8C=E5=AF=B9=E8=AF=9D?= =?UTF-8?q?=EF=BC=88max20->5=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/chat.js | 8 ++++++-- apps/draw.js | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/apps/chat.js b/apps/chat.js index c57065b..f4c54f5 100644 --- a/apps/chat.js +++ b/apps/chat.js @@ -1661,7 +1661,7 @@ export class chatgpt extends plugin { // 如果token曾经有异常,则清除异常 let Tokens = JSON.parse(await redis.get('CHATGPT:BING_TOKENS')) const TokenIndex = Tokens.findIndex(element => element.Token === abtrs.bingToken) - if (Tokens[TokenIndex].exception) { + if (TokenIndex > 0 && Tokens[TokenIndex].exception) { delete Tokens[TokenIndex].exception await redis.set('CHATGPT:BING_TOKENS', JSON.stringify(Tokens)) } @@ -2140,7 +2140,11 @@ async function getAvailableBingToken (conversation, throttled = []) { }) bingToken = minElement.Token } else { - throw new Error('全部Token均已失效,暂时无法使用') + // throw new Error('全部Token均已失效,暂时无法使用') + return { + bingToken: null, + allThrottled + } } if (Config.toneStyle != 'Sydney' && Config.toneStyle != 'Custom') { // bing 下,需要保证同一对话使用同一账号的token diff --git a/apps/draw.js b/apps/draw.js index c4e00f6..10eed61 100644 --- a/apps/draw.js +++ b/apps/draw.js @@ -239,7 +239,7 @@ export class dalle extends plugin { this.reply('请提供绘图prompt') return false } - + this.reply('在画了,请稍等……') let bingToken = '' if (await redis.exists('CHATGPT:BING_TOKENS') != 0) { let bingTokens = JSON.parse(await redis.get('CHATGPT:BING_TOKENS'))