koishi-plugin-group-analysis-mx 1.3.8 → 1.3.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.
@@ -226,7 +226,7 @@ class AnalysisService extends koishi_1.Service {
226
226
  limit: totalLimit,
227
227
  purpose: 'user-persona'
228
228
  });
229
- results.push(...history.map((message) => ({
229
+ results.push(...history.filter((message) => !(0, utils_1.isJunkMessage)(message.content)).map((message) => ({
230
230
  ...message,
231
231
  guildId: message.guildId ?? group.guildId,
232
232
  channelId: message.channelId ?? group.channelId
@@ -811,6 +811,8 @@ class AnalysisService extends koishi_1.Service {
811
811
  }
812
812
  }
813
813
  async analyzeGroupMessages(messages, selfId, target, context) {
814
+ // 过滤腾讯官方 bot 签名等非聊天垃圾内容
815
+ messages = (messages || []).filter((m) => !(0, utils_1.isJunkMessage)(m.content));
814
816
  this.ctx.logger.info(`开始分析 ${messages.length} 条消息...`);
815
817
  const { userStats, totalChars, totalEmojiCount, allMessagesText } = (0, utils_1.calculateBasicStats)(messages);
816
818
  const messagesText = allMessagesText.join('\n');
@@ -69,6 +69,10 @@ class MessageService extends koishi_1.Service {
69
69
  if (this.config.personaBlacklist?.includes(session.userId)) {
70
70
  return;
71
71
  }
72
+ // 腾讯官方 bot 的签名等非聊天垃圾内容,不记录
73
+ if ((0, utils_1.isJunkMessage)(session.content)) {
74
+ return;
75
+ }
72
76
  const uniqueId = session.messageId
73
77
  ? `${session.platform}_${session.messageId}`
74
78
  : `${session.platform}_${session.selfId}_${session.channelId}_${Date.now()}_${Math.random()
package/lib/utils.js CHANGED
@@ -27,6 +27,7 @@ exports.isCacheExpiredByMinutes = isCacheExpiredByMinutes;
27
27
  exports.buildGroupAnalysisCacheKey = buildGroupAnalysisCacheKey;
28
28
  exports.buildMessagePersistenceKey = buildMessagePersistenceKey;
29
29
  exports.isNapCatBot = isNapCatBot;
30
+ exports.isJunkMessage = isJunkMessage;
30
31
  const koishi_1 = require("koishi");
31
32
  const skins_1 = require("./skins");
32
33
  function calculateBasicStats(messages) {
@@ -370,4 +371,22 @@ async function isNapCatBot(bot) {
370
371
  const name = versionInfo.data['app_name'].toLowerCase();
371
372
  return { isRunningNapCat: name.includes('napcat'), botAppName: name };
372
373
  }
374
+ /**
375
+ * 判断消息是否为非聊天的垃圾内容(腾讯官方 bot 的 ROBOT1.0_ 签名、超长无空白 token 串等)。
376
+ * 这类内容不应存入消息库,也不应参与分析。
377
+ */
378
+ function isJunkMessage(content) {
379
+ if (content === null || content === undefined)
380
+ return false;
381
+ const s = String(content).trim();
382
+ if (!s)
383
+ return false;
384
+ // 腾讯 QQ 官方机器人消息签名
385
+ if (/^ROBOT1\.0_/i.test(s))
386
+ return true;
387
+ // 超长且无空白的 sign/token 串(正常聊天不会这样)
388
+ if (s.length > 150 && !/\s/.test(s) && /^[A-Za-z0-9+/=_.!-]+$/.test(s))
389
+ return true;
390
+ return false;
391
+ }
373
392
  //# sourceMappingURL=utils.js.map
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.3.8",
4
+ "version": "1.3.9",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/index.mjs",
7
7
  "typings": "lib/index.d.ts",