From 6eb3689d99a13166163d88898b1ccb3ff255a66a Mon Sep 17 00:00:00 2001 From: zhiyu1998 <542716863@qq.com> Date: Sat, 10 Aug 2024 16:50:16 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=AA=9B=20chore:=20=E6=B8=85=E7=90=86?= =?UTF-8?q?=E8=BD=AC=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/tools.js | 55 +++++++++++---------------------------------------- 1 file changed, 12 insertions(+), 43 deletions(-) diff --git a/apps/tools.js b/apps/tools.js index d5d58a1..465b7a8 100644 --- a/apps/tools.js +++ b/apps/tools.js @@ -582,7 +582,11 @@ export class tools extends plugin { // 总结 const summary = await this.getBiliSummary(bvid, cid, owner.mid); // 封装总结 - const Msg = await this.makeForwardMsg(e, [`「R插件 x B站」联合为您总结内容:`, summary]); + const Msg = await Bot.makeForwardMsg([{ + message: { type: "text", text: summary }, + nickname: e.sender.card || e.user_id, + user_id: e.user_id, + }]); // 不提取音乐,正常处理 if (isLimitDuration) { // 加入图片 @@ -1682,7 +1686,13 @@ export class tools extends plugin { // 计算阅读时间 const stats = estimateReadingTime(kimiAns); e.reply(`当前 ${ name } 预计阅读时间: ${ stats.minutes } 分钟,总字数: ${ stats.words }`) - const Msg = await this.makeForwardMsg(e, [`「R插件 x ${ model }」联合为您总结内容:`, kimiAns]); + const Msg = await Bot.makeForwardMsg([`「R插件 x ${ model }」联合为您总结内容:`, kimiAns].map(item => { + return { + message: { type: "text", text: item }, + nickname: e.sender.card || e.user_id, + user_id: e.user_id, + }; + })); await e.reply(Msg); return true; } @@ -2092,45 +2102,4 @@ export class tools extends plugin { await e.group.sendFile(path); } } - - async makeForwardMsg(e, msg = [], dec = '') { - let userInfo = { - nickname: e.nickname, - user_id: e.user_id - } - - let forwardMsg = [] - msg.forEach(v => { - forwardMsg.push({ - ...userInfo, - message: v - }) - }) - - if (e.isGroup) { - forwardMsg = await e.group.makeForwardMsg(forwardMsg) - } else if (e.friend) { - forwardMsg = await e.friend.makeForwardMsg(forwardMsg) - } else { - return false - } - - if (dec) { - if (typeof (forwardMsg.data) === 'object') { - let detail = forwardMsg.data?.meta?.detail - if (detail) { - detail.news = [{ text: dec }] - } - } else { - forwardMsg.data = forwardMsg.data - .replace('', '') - .replace(/\n/g, '') - .replace(/(.+?)<\/title>/g, '___') - .replace(/___+/, `<title color="#777777" size="26">${ dec }`) - } - - } - - return forwardMsg - } }