fix: unknown

This commit is contained in:
ikechan8370 2023-04-20 19:18:26 +08:00
parent 5ded004538
commit cd228128ba
2 changed files with 5 additions and 3 deletions

View file

@ -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)

View file

@ -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) {