koishi-plugin-group-analysis-mx 1.7.8 → 1.7.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/utils.js +26 -0
- package/package.json +2 -1
package/lib/utils.js
CHANGED
|
@@ -28,6 +28,7 @@ exports.buildGroupAnalysisCacheKey = buildGroupAnalysisCacheKey;
|
|
|
28
28
|
exports.buildMessagePersistenceKey = buildMessagePersistenceKey;
|
|
29
29
|
exports.isNapCatBot = isNapCatBot;
|
|
30
30
|
exports.isJunkMessage = isJunkMessage;
|
|
31
|
+
exports.isForwardedChatRecord = isForwardedChatRecord;
|
|
31
32
|
exports.cleanContent = cleanContent;
|
|
32
33
|
const koishi_1 = require("koishi");
|
|
33
34
|
const skins_1 = require("./skins");
|
|
@@ -372,6 +373,28 @@ async function isNapCatBot(bot) {
|
|
|
372
373
|
const name = versionInfo.data['app_name'].toLowerCase();
|
|
373
374
|
return { isRunningNapCat: name.includes('napcat'), botAppName: name };
|
|
374
375
|
}
|
|
376
|
+
/**
|
|
377
|
+
* 判断消息是否为 QQ“合并转发/聊天记录”卡片。
|
|
378
|
+
* 官方适配器没有解析 102 类型的聊天记录,只把卡片预览文字当成普通文本,
|
|
379
|
+
* 直接分析会把它当成转发者的发言,因此这里整体识别并跳过。
|
|
380
|
+
*/
|
|
381
|
+
function isForwardedChatRecord(content) {
|
|
382
|
+
if (content === null || content === undefined)
|
|
383
|
+
return false;
|
|
384
|
+
const s = String(content).replace(/\s+/g, ' ').trim();
|
|
385
|
+
if (!s)
|
|
386
|
+
return false;
|
|
387
|
+
// 卡片底部固定文案,如“查看2条转发消息”
|
|
388
|
+
if (/查看\s*\d+\s*条(?:转发)?消息/.test(s))
|
|
389
|
+
return true;
|
|
390
|
+
// 卡片标题,如“群聊的聊天记录”
|
|
391
|
+
if (/^群聊的聊天记录(?:$|\s|[::])/.test(s))
|
|
392
|
+
return true;
|
|
393
|
+
// 部分版本只给占位标签
|
|
394
|
+
if (/^\[(?:聊天记录|合并转发)\]$/.test(s))
|
|
395
|
+
return true;
|
|
396
|
+
return false;
|
|
397
|
+
}
|
|
375
398
|
/**
|
|
376
399
|
* 判断消息是否为非聊天的垃圾内容(腾讯官方 bot 的 ROBOT1.0_ 签名、超长无空白 token 串等)。
|
|
377
400
|
* 这类内容不应存入消息库,也不应参与分析。
|
|
@@ -382,6 +405,9 @@ function isJunkMessage(content) {
|
|
|
382
405
|
const s = String(content).trim();
|
|
383
406
|
if (!s)
|
|
384
407
|
return false;
|
|
408
|
+
// 合并转发/聊天记录卡片
|
|
409
|
+
if (isForwardedChatRecord(s))
|
|
410
|
+
return true;
|
|
385
411
|
// 腾讯 QQ 官方机器人消息签名(任意位置出现都过滤)
|
|
386
412
|
if (/ROBOT1\.0_/.test(s))
|
|
387
413
|
return true;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koishi-plugin-group-analysis-mx",
|
|
3
3
|
"description": "群聊分析插件 - 生成精美群聊统计报告,支持 AI 话题总结(独立版,不依赖 ChatLuna)",
|
|
4
|
-
"version": "1.7.
|
|
4
|
+
"version": "1.7.9",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib/index.mjs",
|
|
7
7
|
"typings": "lib/index.d.ts",
|
|
@@ -63,3 +63,4 @@
|
|
|
63
63
|
|
|
64
64
|
|
|
65
65
|
|
|
66
|
+
|