From 1eaa43c91b0d4c6cc5a12972b6b71637c92a0702 Mon Sep 17 00:00:00 2001 From: zhiyu1998 <542716863@qq.com> Date: Wed, 21 Aug 2024 13:51:42 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20=E6=96=B0=E5=A2=9E=E6=8C=87?= =?UTF-8?q?=E4=BB=A4`#r=E7=95=AA=E5=89=A7`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/query.js | 19 +++++++++---------- apps/tools.js | 5 +++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/apps/query.js b/apps/query.js index b1de241..e0842e8 100644 --- a/apps/query.js +++ b/apps/query.js @@ -5,7 +5,7 @@ import puppeteer from "../../../lib/puppeteer/puppeteer.js"; // http库 import axios from "axios"; // 常量 -import { CAT_LIMIT, COMMON_USER_AGENT, REDIS_YUNZAI_ANIMELIST } from "../constants/constant.js"; +import { CAT_LIMIT, COMMON_USER_AGENT, DIVIDING_LINE, REDIS_YUNZAI_ANIMELIST } from "../constants/constant.js"; // 配置文件 import config from "../model/config.js"; import { redisExistAndGetKey } from "../utils/redis-util.js"; @@ -44,7 +44,7 @@ export class query extends plugin { fnc: "zhubaiSearch", }, { - reg: "^#汇集番剧$", + reg: "^#(r|R)番剧(.*)", fnc: "myAnimeList", } ], @@ -231,20 +231,19 @@ export class query extends plugin { } async myAnimeList(e) { + const title = e.msg.replace(/^#([rR])番剧/, "").trim(); const animeList = await redisExistAndGetKey(REDIS_YUNZAI_ANIMELIST) if (animeList == null) { e.reply("暂无番剧信息"); return; } - let forwardMsg = []; - for (let [key, value] of Object.entries(animeList)) { - forwardMsg.push({ - message: { type: 'text', text: `《${key}》\n🪶 在线观看:${value.shortLink}\n🌸 在线观看:${value.shortLink2}` }, - nickname: this.e.sender.card || this.e.user_id, - user_id: this.e.user_id, - }) + const findRes = Object.entries(animeList).find(([key, value]) => key.includes(title)); + if (findRes == null) { + e.reply("未找到相关番剧"); + return; } - e.reply(await Bot.makeForwardMsg(forwardMsg)); + const { cover, shortLink, shortLink2 } = findRes[1]; + e.reply([segment.image(cover), `《${findRes[0]}》\n\n🪶 在线观看: ${ shortLink }\n🌸 在线观看: ${ shortLink2 }\n${DIVIDING_LINE.replace("{}", "收录信息")}\n当前管理员已经收录了: ${ Object.keys(animeList).length } 个番剧`]); return true; } diff --git a/apps/tools.js b/apps/tools.js index 6451e56..feec0c4 100644 --- a/apps/tools.js +++ b/apps/tools.js @@ -662,7 +662,7 @@ export class tools extends plugin { "收藏": favorite, }; // 截断标题,查看Redis中是否存在,避免频繁走网络连接 - const { shortLink, shortLink2 } = await this.biliAnimeCacheDetect(result.title); + const { shortLink, shortLink2 } = await this.biliAnimeCacheDetect(result.title, result.cover); e.reply([ segment.image(resp.result.cover), `${ this.identifyPrefix }识别:哔哩哔哩番剧,${ result.title }\n🎯 评分: ${ result?.rating?.score ?? '-' } / ${ result?.rating?.count ?? '-' }\n📺 ${ result.new_ep.desc }, ${ result.seasons[0].new_ep.index_show }\n`, @@ -678,7 +678,7 @@ export class tools extends plugin { * @param title * @returns {Promise<{shortLink2: string, shortLink: string}|*>} */ - async biliAnimeCacheDetect(title) { + async biliAnimeCacheDetect(title, cover) { const animeList = await redisExistAndGetKey(REDIS_YUNZAI_ANIMELIST) if (animeList && animeList?.[title] !== undefined) { return animeList?.[title]; @@ -687,6 +687,7 @@ export class tools extends plugin { const shortLink2 = await urlTransformShortLink(ANIME_SERIES_SEARCH_LINK2 + title); await redisExistAndInsertObject(REDIS_YUNZAI_ANIMELIST, { [title]: { + cover, shortLink, shortLink2 }