koishi-plugin-group-analysis-mx 1.5.4 → 1.5.5
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/service/analysis.js +2 -2
- package/lib/service/renderer.js +31 -0
- package/package.json +2 -1
package/lib/service/analysis.js
CHANGED
|
@@ -929,8 +929,8 @@ class AnalysisService extends koishi_1.Service {
|
|
|
929
929
|
if (Array.isArray(topic.contributors)) {
|
|
930
930
|
topic.contributors = [...new Set(topic.contributors.map(resolveTopicName).filter(Boolean))];
|
|
931
931
|
}
|
|
932
|
-
if (typeof topic.
|
|
933
|
-
topic.
|
|
932
|
+
if (typeof topic.detail === 'string') {
|
|
933
|
+
topic.detail = topic.detail
|
|
934
934
|
.replace(/[\[((]?([0-9A-Fa-f]{16,})[\]))]?/g, (m, id) => topicIdToName.get(id) || '群友')
|
|
935
935
|
.replace(/[\[((]?(\d{5,12})[\]))]?/g, (m, id) => topicIdToName.get(id) || m);
|
|
936
936
|
}
|
package/lib/service/renderer.js
CHANGED
|
@@ -225,6 +225,37 @@ class RendererService extends koishi_1.Service {
|
|
|
225
225
|
userStats: await Promise.all((data.userStats || []).map(inlineAvatar)),
|
|
226
226
|
userTitles: await Promise.all((data.userTitles || []).map(inlineAvatar)),
|
|
227
227
|
};
|
|
228
|
+
|
|
229
|
+
// 话题昵称装饰:把参与者/详情里出现的昵称包成带头像的小标签 chip
|
|
230
|
+
const nameAvatar = new Map();
|
|
231
|
+
for (const u of (data.userStats || [])) {
|
|
232
|
+
if (u && u.nickname && u.avatar && String(u.avatar).startsWith('data:'))
|
|
233
|
+
nameAvatar.set(String(u.nickname), u.avatar);
|
|
234
|
+
}
|
|
235
|
+
const chipNames = [...nameAvatar.keys()].filter((n) => n && n.length >= 2).sort((x, y) => y.length - x.length);
|
|
236
|
+
const chipOf = (name) => {
|
|
237
|
+
const av = nameAvatar.get(name);
|
|
238
|
+
return '<span class="topic-user">' + (av ? '<img src="' + av + '" alt="">' : '') + name + '</span>';
|
|
239
|
+
};
|
|
240
|
+
data = {
|
|
241
|
+
...data,
|
|
242
|
+
topics: (data.topics || []).map((t) => {
|
|
243
|
+
if (!t) return t;
|
|
244
|
+
const contributors = Array.isArray(t.contributors)
|
|
245
|
+
? t.contributors.map((c) => { const n = String(c); return chipNames.includes(n) ? chipOf(n) : n; })
|
|
246
|
+
: t.contributors;
|
|
247
|
+
let detail = String(t.detail || '');
|
|
248
|
+
const ph = [];
|
|
249
|
+
for (const n of chipNames) {
|
|
250
|
+
if (!detail.includes(n)) continue;
|
|
251
|
+
const tag = '\u0001' + ph.length + '\u0002';
|
|
252
|
+
detail = detail.split(n).join(tag);
|
|
253
|
+
ph.push(chipOf(n));
|
|
254
|
+
}
|
|
255
|
+
detail = detail.replace(/\u0001(\d+)\u0002/g, (m, i) => ph[+i] || '');
|
|
256
|
+
return { ...t, contributors, detail };
|
|
257
|
+
}),
|
|
258
|
+
};
|
|
228
259
|
const templatePath = this.getSkinPath('template_group.html');
|
|
229
260
|
const randomId = Math.random().toString(36).substring(2, 15);
|
|
230
261
|
const skin = this.config.skin || 'md3';
|
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.5.
|
|
4
|
+
"version": "1.5.5",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib/index.mjs",
|
|
7
7
|
"typings": "lib/index.d.ts",
|
|
@@ -47,3 +47,4 @@
|
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
|
+
|