diff --git a/apps/picSearch.js b/apps/picSearch.js index 8a57fb7..67e9027 100644 --- a/apps/picSearch.js +++ b/apps/picSearch.js @@ -57,10 +57,7 @@ export class NewPicSearch extends plugin { if (!await this.Authentication(e)) return if (!await this.handelImg(e, 'Ascii2D')) return await PicSearch.Ascii2D(e.img[0]) - .then(res => { - common.getRecallsendMsg(e, res.color, { isxmlMsg: false }) - common.getRecallsendMsg(e, res.bovw, { isxmlMsg: false }) - }) + .then(res => common.getRecallsendMsg(e, [...res.color, ...res.bovw], { isxmlMsg: false })) .catch(err => e.reply(err.message)) } diff --git a/config/default_config/picSearch.yaml b/config/default_config/picSearch.yaml index 7ab08e2..203ad83 100644 --- a/config/default_config/picSearch.yaml +++ b/config/default_config/picSearch.yaml @@ -16,7 +16,7 @@ cfTLSVersion: TLSv1.1 #是否使用 Puppeteer 请求 ascii2d 以绕过 cf js challenge ascii2dUsePuppeteer: false #ascii2d搜图返回结果的最大数量 -ascii2dResultMaxQuantity: 6 +ascii2dResultMaxQuantity: 3 #隐藏所有搜索结果的缩略图 hideImg: false #whatanime 得到 R18 结果时隐藏结果缩略图 diff --git a/lib/request/request.js b/lib/request/request.js index cf37bb0..7948311 100644 --- a/lib/request/request.js +++ b/lib/request/request.js @@ -50,7 +50,9 @@ export default new class { if (!options.agent) options.agent = await this.getAgent() try { let res = await fetch(url, options) - res = checkStatus(res) + if (!options.closeCheckStatus) { + res = checkStatus(res) + } if (options.statusCode) { return res[options.statusCode]() } @@ -90,7 +92,9 @@ export default new class { if (!options.agent) options.agent = await this.getAgent() try { let res = await fetch(url, options) - res = checkStatus(res) + if (!options.closeCheckStatus) { + res = checkStatus(res) + } if (options.statusCode) { return res[options.statusCode]() } diff --git a/model/PicSearch/ascii2d.js b/model/PicSearch/ascii2d.js index 0989a86..3f28b15 100644 --- a/model/PicSearch/ascii2d.js +++ b/model/PicSearch/ascii2d.js @@ -25,7 +25,7 @@ export default async function doSearch (url) { const $ = cheerio.load(ret.data, { decodeEntities: false }) logger.error('[error] ascii2d url:', colorURL) logger.debug(ret.data) - throw Error(`搜索失败,错误原因:${$('.container > .row > div:first-child > p').text().trim()}`) + throw Error(`Ascii2D搜索失败,错误原因:${$('.container > .row > div:first-child > p').text().trim()}`) } const bovwURL = colorURL.replace('/color/', '/bovw/') let bovwDetail = await (ascii2dUsePuppeteer ? getAscii2dWithPuppeteer(bovwURL) : request.cfGet(bovwURL)) diff --git a/model/PicSearch/saucenao.js b/model/PicSearch/saucenao.js index e852e29..0c1891b 100644 --- a/model/PicSearch/saucenao.js +++ b/model/PicSearch/saucenao.js @@ -42,7 +42,7 @@ export default async function doSearch (url) { async function getSearchResult (imgURL, db = 999) { logger.debug(`saucenao [${imgURL}]}`) let api_key = Config.picSearch.SauceNAOApiKey - if (!api_key) return { error: '未配置SauceNAOApiKey,无法使用SauceNAO搜图,请在 https://saucenao.com/user.php?page=search-api 进行获取,请用指令:#设置SauceNAOapiKey 进行添加' } + if (!api_key) throw Error('未配置SauceNAOApiKey,无法使用SauceNAO搜图,请在 https://saucenao.com/user.php?page=search-api 进行获取,请用指令:#设置SauceNAOapiKey 进行添加') return await request.get('https://saucenao.com/search.php', { params: { api_key, @@ -51,10 +51,11 @@ async function getSearchResult (imgURL, db = 999) { numres: 3, url: imgURL, hide: Config.picSearch.hideImgWhenSaucenaoNSFW - } + }, + closeCheckStatus: true }).then(res => { if (res.status === 429) { - return { error: 'SauceNAO搜图 搜索次数已达单位时间上限,请稍候再试' } + throw Error('SauceNAO搜图 搜索次数已达单位时间上限,请稍候再试') } else { return res.json() } diff --git a/model/Pixiv/api.js b/model/Pixiv/api.js index b4b071b..6fcea3d 100644 --- a/model/Pixiv/api.js +++ b/model/Pixiv/api.js @@ -22,7 +22,7 @@ export default class PixivApi { async login () { if (!this.refresh_token) { - throw Error('Pixiv 未配置refresh_token刷新令牌') + throw Error('[Yenai][Pixiv] 未配置refresh_token刷新令牌') } const data = { client_id: 'MOBrBDS8blbauoSck0ZfDbtuzpyT', @@ -34,15 +34,15 @@ export default class PixivApi { data, headers: this.headers }).then(res => res.json()) - if (error) throw Error(`Pixiv login Error Response: ${error}`) + if (error) throw Error(`[Yenai][Pixiv]login Error Response: ${error}`) this.access_token = response.access_token this.refresh_token = response.refresh_token this.auth = response if (this.access_token) { const { id, name, account } = this.auth.user - logger.info(`[Yenai] Pixiv login ${logger.yellow(`${name}(${id}) @${account}`)} ${logger.green('success')}`) + logger.info(`[Yenai][Pixiv]login ${logger.yellow(`${name}(${id}) @${account}`)} ${logger.green('success')}`) } else { - logger.error(`[Yenai] Pixiv login ${logger.red('fail')}`) + logger.error(`[Yenai][Pixiv]login ${logger.red('fail')}`) } }