From cd228128bacd710183e2322adba089d0f4c5b504 Mon Sep 17 00:00:00 2001 From: ikechan8370 Date: Thu, 20 Apr 2023 19:18:26 +0800 Subject: [PATCH] fix: unknown --- apps/chat.js | 4 ++-- utils/SydneyAIClient.js | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/chat.js b/apps/chat.js index dec7446..cb6b369 100644 --- a/apps/chat.js +++ b/apps/chat.js @@ -1316,7 +1316,7 @@ export class chatgpt extends plugin { } catch (error) { logger.error(error) const message = error?.message || error?.data?.message || error || '出错了' - if (message && message.indexOf('限流') > -1) { + if (message && typeof message === 'string' && message.indexOf('限流') > -1) { throttledTokens.push(bingToken) let bingTokens = JSON.parse(await redis.get('CHATGPT:BING_TOKENS')) const badBingToken = bingTokens.findIndex(element => element.Token === bingToken) @@ -1327,7 +1327,7 @@ export class chatgpt extends plugin { bingTokens[badBingToken].DisactivationTime = now await redis.set('CHATGPT:BING_TOKENS', JSON.stringify(bingTokens)) // 不减次数 - } else if (message && message.indexOf('UnauthorizedRequest') > -1) { + } else if (message && typeof message === 'string' && message.indexOf('UnauthorizedRequest') > -1) { // token过期了 let bingTokens = JSON.parse(await redis.get('CHATGPT:BING_TOKENS')) const badBingToken = bingTokens.findIndex(element => element.Token === bingToken) diff --git a/utils/SydneyAIClient.js b/utils/SydneyAIClient.js index 615c913..7032c16 100644 --- a/utils/SydneyAIClient.js +++ b/utils/SydneyAIClient.js @@ -98,7 +98,9 @@ export default class SydneyAIClient { 'x-ms-useragent': 'azsdk-js-api-client-factory/1.0.0-beta.1 core-rest-pipeline/1.10.0 OS/Win32', cookie: this.opts.cookies || `_U=${this.opts.userToken}`, Referer: 'https://www.bing.com/search?q=Bing+AI&showconv=1&FORM=hpcodx', - 'Referrer-Policy': 'origin-when-cross-origin' + 'Referrer-Policy': 'origin-when-cross-origin', + // Workaround for request being blocked due to geolocation + 'x-forwarded-for': '1.1.1.1' } } if (this.opts.proxy) {