MCPcopy Create free account
hub / github.com/TeleBoxOrg/TeleBox_Plugins / SummaryPlugin

Class SummaryPlugin

sum/sum.ts:922–1860  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

920 if (task.timeRange) {
921 messageData = await getGroupMessagesByTime(task.chatId, task.timeRange);
922 } else {
923 messageData = await getGroupMessages(task.chatId, task.messageCount);
924 }
925
926 if (!messageData || messageData.length === 0) {
927 return { success: false, message: "未找到可总结的消息" };
928 }
929
930 // AI 总结
931 const summaryResult = await summarizeMessages(task, messageData);
932 if (!summaryResult.success) {
933 return { success: false, message: summaryResult.error! };
934 }
935
936 // 发送总结
937 const pushTarget = task.pushTarget || db.data.defaultPushTarget || "me";
938 let summaryContent = summaryResult.result!;
939
940 // 过滤掉思考标签内容(如 <thinking>...</thinking>、<think>...</think>)
941 summaryContent = summaryContent.replace(
942 /<thinking>[\s\S]*?<\/thinking>/gi,
943 "",
944 );
945 summaryContent = summaryContent.replace(/<think>[\s\S]*?<\/think>/gi, "");
946 summaryContent = summaryContent.trim();
947
948 // 应用最大输出长度限制(过滤思考内容后再计算)
949 // 应用最大输出长度限制(0表示不限制)
950 const maxOutputLength = db.data.aiConfig.max_output_length ?? 0;
951 if (maxOutputLength > 0 && summaryContent.length > maxOutputLength) {
952 summaryContent =
953 summaryContent.substring(0, maxOutputLength) +
954 "\n\n⚠️ 内容已截断(超过最大长度限制)";
955 }
956
957 const chatName = task.chatDisplay
958 ? task.chatDisplay.replace(/\s*<code>.*?<\/code>/gi, "")
959 : htmlEscape(task.chatId);
960 const header = `📊 <b>群组总结</b>\n${chatName} · ${formatDate(new Date())}\n\n`;
961
962 // 应用折叠标签(如果启用)
963 const wrappedContent = wrapWithSpoiler(
964 summaryContent,
965 task.useSpoiler || false,
966 );
967 const summaryText = `${header}${wrappedContent}`;
968
969 await client.sendMessage(pushTarget, {
970 message: summaryText,
971 parseMode: "html",
972 linkPreview: db.data.aiConfig.link_preview === true,
973 });
974
975 return { success: true, message: `总结完成,已推送到 ${pushTarget}` };
976 } catch (e: any) {
977 return { success: false, message: `总结失败: ${e?.message || e}` };
978 }
979}

Callers

nothing calls this directly

Calls 15

getGroupMessagesFunction · 0.85
summarizeMessagesFunction · 0.85
wrapWithSpoilerFunction · 0.85
parseIntervalFunction · 0.85
parseChatIdentifierFunction · 0.85
buildChatLinkFunction · 0.85
executeSummaryFunction · 0.85
errorMethod · 0.80
writeMethod · 0.80
htmlEscapeFunction · 0.70
codeTagFunction · 0.70
toIntFunction · 0.70

Tested by

no test coverage detected