fix: bing绘图重复发送的问题

This commit is contained in:
ikechan8370 2023-04-01 22:42:11 +08:00
parent d6267e3f98
commit 14b4d3cdf4
2 changed files with 83 additions and 18 deletions

View file

@ -66,7 +66,11 @@ export default class BingDrawClient {
logger.info({ pollingUrl })
logger.info('waiting for bing draw results...')
let timeoutTimes = 50
let found = false
let timer = setInterval(async () => {
if (found) {
return
}
let r = await fetch(pollingUrl, {
headers: {
accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
@ -83,6 +87,7 @@ export default class BingDrawClient {
if (rText) {
// logger.info(rText)
logger.info('got bing draw results!')
found = true
let regex = /src="([^"]+)"/g
let imageLinks = rText.match(regex)
if (!imageLinks || imageLinks.length === 0) {