From 950c3e18b859aaccdbf01f275e81e586fe0e545c Mon Sep 17 00:00:00 2001 From: yeyang <746659424@qq.com> Date: Thu, 16 Feb 2023 00:18:58 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20=E4=BC=98=E5=8C=96SauceNAO?= =?UTF-8?q?=E6=90=9C=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 6 ++++++ apps/picSearch.js | 11 +++-------- model/PicSearch/saucenao.js | 19 ++++++++++++++----- 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 4944c0b..2252d87 100644 --- a/README.md +++ b/README.md @@ -202,6 +202,7 @@ Tip:具体可使用 **#椰奶群管帮助** 查看 状态 +
常见问题请移步[wiki](https://github.com/yeyang52/yenai-plugin/wiki) @@ -244,6 +245,11 @@ Tip:具体可使用 **#椰奶群管帮助** 查看 本段遵循 [all-contributors](https://github.com/all-contributors/all-contributors) 规范,欢迎任何形式的贡献! +## 友情链接 + +- [Yunzai-Bot插件索引](https://gitee.com/Hikari666/Yunzai-Bot-plugins-index) +- [码云镜像库](https://gitee.com/yeyang52/yenai-plugin) + ## 免责声明 1. 功能仅限内部交流与小范围使用,请勿将Yunzai-Bot及Yenai-Plugin用于任何以盈利为目的的场景. diff --git a/apps/picSearch.js b/apps/picSearch.js index 67e9027..d05f8ed 100644 --- a/apps/picSearch.js +++ b/apps/picSearch.js @@ -37,14 +37,9 @@ export class NewPicSearch extends plugin { if (!await this.handelImg(e, 'SauceNAO')) return await PicSearch.SauceNAO(e.img[0]) .then(async res => { - if (res.message.length == 1)res.message = res.message[0] - await (res.maxSimilarity > 80 || res.message.length == 1 - ? common.recallsendMsg(e, res.message, true) - : common.getRecallsendMsg(e, res.message)) - if (res.maxSimilarity < Config.picSearch.SauceNAOMinSim) { - e.reply(`SauceNAO 相似度 ${res.maxSimilarity}% 过低,使用Ascii2D进行搜索`) - await this.Ascii2D(e) - } + res.length == 1 + ? common.recallsendMsg(e, res[0], true) + : common.getRecallsendMsg(e, res, { isxmlMsg: false }) }) .catch(async err => { await e.reply(err.message) diff --git a/model/PicSearch/saucenao.js b/model/PicSearch/saucenao.js index 0c1891b..69690a0 100644 --- a/model/PicSearch/saucenao.js +++ b/model/PicSearch/saucenao.js @@ -2,6 +2,7 @@ import _ from 'lodash' import { Config } from '../../components/index.js' import sagiri from '../../tools/sagiri.js' import request from '../../lib/request/request.js' +import Ascii2D from './ascii2d.js' export default async function doSearch (url) { let res = await getSearchResult(url) logger.debug('SauceNAO result:', res) @@ -22,21 +23,29 @@ export default async function doSearch (url) { if (!_.isEmpty(filterSimilarity)) { let filterPixiv = filterSimilarity.filter(item => item.site == 'Pixiv') if (!_.isEmpty(filterPixiv)) { - message = await msgMap(filterPixiv[0]) + message.push(await msgMap(filterPixiv[0])) } else { - message = await msgMap(filterSimilarity[0]) + message.push(await msgMap(filterSimilarity[0])) } } else { message = await Promise.all(format.map(msgMap)) } let n = maxSimilarity > 80 ? '\n' : '' if (res.header.long_remaining < 30) { - message.push(`${n}SauceNAO 24h 内仅剩 ${res.header.long_remaining} 次使用次数`) + const msg = `${n}SauceNAO 24h 内仅剩 ${res.header.long_remaining} 次使用次数` + n ? message[0].push(msg) : message.push(msg) } if (res.header.short_remaining < 3) { - message.push(`${n}SauceNAO 30s 内仅剩 ${res.header.short_remaining} 次。`) + const msg = `${n}SauceNAO 30s 内仅剩 ${res.header.short_remaining} 次。` + n ? message[0].push(msg) : message.push(msg) } - return { message, maxSimilarity } + if (maxSimilarity < Config.picSearch.SauceNAOMinSim) { + message.push(`SauceNAO 相似度 ${maxSimilarity}% 过低,使用Ascii2D进行搜索`) + await Ascii2D(url) + .then(res => message.push(...res.color, ...res.bovw)) + .catch(err => message.push(err.message)) + } + return message } async function getSearchResult (imgURL, db = 999) {