From 95f39326d7a991044d20288198fb6668f893f3e8 Mon Sep 17 00:00:00 2001 From: zhiyu1998 <542716863@qq.com> Date: Sat, 10 Aug 2024 23:20:58 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=AA=9B=20chore:=20=E5=B0=81=E8=A3=85=20`t?= =?UTF-8?q?extArrayToMakeForward`=20=E5=B7=A5=E5=85=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/tools.js | 15 +++------------ utils/yunzai-util.js | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 12 deletions(-) create mode 100644 utils/yunzai-util.js diff --git a/apps/tools.js b/apps/tools.js index 3126114..54acdf4 100644 --- a/apps/tools.js +++ b/apps/tools.js @@ -82,6 +82,7 @@ import path from "path"; import { OpenaiBuilder } from "../utils/openai-builder.js"; import { contentEstimator } from "../utils/link-share-summary-util.js"; import { checkBBDown, startBBDown } from "../utils/bbdown-util.js"; +import { textArrayToMakeForward } from "../utils/yunzai-util.js"; export class tools extends plugin { /** @@ -582,11 +583,7 @@ export class tools extends plugin { // 总结 const summary = await this.getBiliSummary(bvid, cid, owner.mid); // 封装总结 - const Msg = await Bot.makeForwardMsg([{ - message: { type: "text", text: summary }, - nickname: e.sender.card || e.user_id, - user_id: e.user_id, - }]); + const Msg = await Bot.makeForwardMsg(textArrayToMakeForward(e, [`「R插件 x bilibili」联合为您总结内容:`, summary])); // 不提取音乐,正常处理 if (isLimitDuration) { // 加入图片 @@ -1687,13 +1684,7 @@ export class tools extends plugin { // 计算阅读时间 const stats = estimateReadingTime(kimiAns); e.reply(`当前 ${ name } 预计阅读时间: ${ stats.minutes } 分钟,总字数: ${ stats.words }`) - 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, - }; - })); + const Msg = await Bot.makeForwardMsg(textArrayToMakeForward(e, [`「R插件 x ${ model }」联合为您总结内容:`, kimiAns])); await e.reply(Msg); return true; } diff --git a/utils/yunzai-util.js b/utils/yunzai-util.js new file mode 100644 index 0000000..8d181b9 --- /dev/null +++ b/utils/yunzai-util.js @@ -0,0 +1,14 @@ +/** + * 将只有string的数组转换为原生的 {Bot.makeForwardMsg} + * @param e + * @param textArray {string[]} + */ +export function textArrayToMakeForward(e, textArray) { + return textArray.map(item => { + return { + message: { type: "text", text: item }, + nickname: e.sender.card || e.user_id, + user_id: e.user_id, + }; + }) +} \ No newline at end of file