From 5badf280de99d46f5e2724b719e037af25493b65 Mon Sep 17 00:00:00 2001 From: zhiyu1998 <542716863@qq.com> Date: Sun, 27 Oct 2024 19:10:50 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat=EF=BC=9A=E9=80=82=E9=85=8D?= =?UTF-8?q?=E4=B8=93=E6=A0=8F=E5=9C=A8=E6=9F=90=E4=BA=9B=E7=A7=BB=E5=8A=A8?= =?UTF-8?q?=E7=AB=AF=E6=83=85=E5=86=B5=E4=B8=8B=E6=97=A0=E6=B3=95=E8=A7=A3?= =?UTF-8?q?=E6=9E=90=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/tools.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/apps/tools.js b/apps/tools.js index 4b5efb0..79a73b5 100644 --- a/apps/tools.js +++ b/apps/tools.js @@ -770,9 +770,8 @@ export class tools extends plugin { return true; } // 处理专栏 - if (e.msg !== undefined && e.msg.includes("read\/cv") || e.msg.includes("read\/mobile")) { - await this.biliArticle(e); - this.linkShareSummary(e); + if (e.msg !== undefined && url.includes("read\/cv") || url.includes("read\/mobile")) { + await this.biliArticle(e, url); return true; } // 动态处理 @@ -835,25 +834,31 @@ export class tools extends plugin { /** * 提取哔哩哔哩专栏 * @param e + * @param url * @returns {Promise} */ - async biliArticle(e) { - const cvid = e.msg.match(/read\/cv(\d+)/)?.[1] || e.msg.match(/read\/mobile\?id=(\d+)/)?.[1]; + async biliArticle(e, url) { + const cvid = url.match(/read\/cv(\d+)/)?.[1] || url.match(/read\/mobile\?id=(\d+)/)?.[1]; const articleResp = await fetch(BILI_ARTICLE_INFO.replace("{}", cvid), { headers: { ...BILI_HEADER } }); const articleData = (await articleResp.json()).data; - const { origin_image_urls } = articleData; + const { title, author_name, origin_image_urls } = articleData; if (origin_image_urls) { + const titleMsg = { + message: { type: "text", text: `标题:${title}\n作者:${author_name}` }, + nickname: e.sender.card || e.user_id, + user_id: e.user_id, + } await e.reply(Bot.makeForwardMsg(origin_image_urls.map(item => { return { message: segment.image(item), nickname: e.sender.card || e.user_id, user_id: e.user_id, } - }))) + }).concat(titleMsg))); } }