mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-17 13:57:10 +00:00
fix: 微软能不能少报一些错啊
This commit is contained in:
parent
9a8db9577a
commit
0efc67f522
1 changed files with 5 additions and 5 deletions
|
|
@ -93,7 +93,7 @@ export default class BingDrawClient {
|
||||||
let pollingUrl = `${this.opts.baseUrl}/images/create/async/results/${requestId}?q=${urlEncodedPrompt}`
|
let pollingUrl = `${this.opts.baseUrl}/images/create/async/results/${requestId}?q=${urlEncodedPrompt}`
|
||||||
logger.info({ pollingUrl })
|
logger.info({ pollingUrl })
|
||||||
logger.info('waiting for bing draw results...')
|
logger.info('waiting for bing draw results...')
|
||||||
let timeoutTimes = 50
|
let timeoutTimes = 30
|
||||||
let found = false
|
let found = false
|
||||||
let timer = setInterval(async () => {
|
let timer = setInterval(async () => {
|
||||||
if (found) {
|
if (found) {
|
||||||
|
|
@ -108,9 +108,8 @@ export default class BingDrawClient {
|
||||||
let regex = /src="([^"]+)"/g
|
let regex = /src="([^"]+)"/g
|
||||||
let imageLinks = rText.match(regex)
|
let imageLinks = rText.match(regex)
|
||||||
if (!imageLinks || imageLinks.length === 0) {
|
if (!imageLinks || imageLinks.length === 0) {
|
||||||
await e.reply('绘图失败:no images', true)
|
// 很可能是微软内部error,重试即可
|
||||||
logger.error(rText)
|
return
|
||||||
throw new Error('no images')
|
|
||||||
}
|
}
|
||||||
imageLinks = imageLinks.map(link => link.split('?w=')[0]).map(link => link.replace('src="', ''))
|
imageLinks = imageLinks.map(link => link.split('?w=')[0]).map(link => link.replace('src="', ''))
|
||||||
imageLinks = [...new Set(imageLinks)]
|
imageLinks = [...new Set(imageLinks)]
|
||||||
|
|
@ -133,11 +132,12 @@ export default class BingDrawClient {
|
||||||
if (timeoutTimes === 0) {
|
if (timeoutTimes === 0) {
|
||||||
await e.reply('绘图超时', true)
|
await e.reply('绘图超时', true)
|
||||||
clearInterval(timer)
|
clearInterval(timer)
|
||||||
|
timer = null
|
||||||
} else {
|
} else {
|
||||||
logger.info('still waiting for bing draw results... times left: ' + timeoutTimes)
|
logger.info('still waiting for bing draw results... times left: ' + timeoutTimes)
|
||||||
timeoutTimes--
|
timeoutTimes--
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 1500)
|
}, 2000)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue