koishi-plugin-group-analysis-mx 1.5.3 → 1.5.4
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 +39 -0
- package/package.json +1 -1
package/lib/service/analysis.js
CHANGED
|
@@ -897,6 +897,45 @@ class AnalysisService extends koishi_1.Service {
|
|
|
897
897
|
// 排行榜显示名使用群名片
|
|
898
898
|
user.nickname = displayName;
|
|
899
899
|
}
|
|
900
|
+
// 话题:参与者/描述里的用户 ID(官方 bot 为 openid)回填为昵称,回填不到显示"群友"
|
|
901
|
+
if (Array.isArray(topics)) {
|
|
902
|
+
const topicIdToName = new Map();
|
|
903
|
+
for (const msg of messages) {
|
|
904
|
+
const un = msg.username ? String(msg.username) : '';
|
|
905
|
+
if (msg.userId && un && un !== String(msg.userId) && !/^[0-9A-Fa-f]{16,}$/.test(un))
|
|
906
|
+
topicIdToName.set(String(msg.userId), un);
|
|
907
|
+
}
|
|
908
|
+
for (const [uid, gname] of groupNicknameMap) {
|
|
909
|
+
if (gname)
|
|
910
|
+
topicIdToName.set(uid, gname);
|
|
911
|
+
}
|
|
912
|
+
const resolveTopicName = (raw) => {
|
|
913
|
+
const sVal = String(raw || '').trim();
|
|
914
|
+
const cleaned = sVal.replace(/[\[\]()()]/g, '').trim();
|
|
915
|
+
if (topicIdToName.has(cleaned))
|
|
916
|
+
return topicIdToName.get(cleaned);
|
|
917
|
+
if (nicknameMap.has(sVal))
|
|
918
|
+
return nicknameMap.get(sVal);
|
|
919
|
+
const norm = (0, utils_1.normalizeNickname)(sVal);
|
|
920
|
+
if (norm && nicknameMap.has(norm))
|
|
921
|
+
return nicknameMap.get(norm);
|
|
922
|
+
if (/^[0-9A-Fa-f]{16,}$/.test(cleaned) || (cleaned.length > 12 && !/^\d+$/.test(cleaned)))
|
|
923
|
+
return '群友';
|
|
924
|
+
return sVal;
|
|
925
|
+
};
|
|
926
|
+
topics.forEach((topic) => {
|
|
927
|
+
if (!topic)
|
|
928
|
+
return;
|
|
929
|
+
if (Array.isArray(topic.contributors)) {
|
|
930
|
+
topic.contributors = [...new Set(topic.contributors.map(resolveTopicName).filter(Boolean))];
|
|
931
|
+
}
|
|
932
|
+
if (typeof topic.description === 'string') {
|
|
933
|
+
topic.description = topic.description
|
|
934
|
+
.replace(/[\[((]?([0-9A-Fa-f]{16,})[\]))]?/g, (m, id) => topicIdToName.get(id) || '群友')
|
|
935
|
+
.replace(/[\[((]?(\d{5,12})[\]))]?/g, (m, id) => topicIdToName.get(id) || m);
|
|
936
|
+
}
|
|
937
|
+
});
|
|
938
|
+
}
|
|
900
939
|
// 用户称号:用真实昵称替换 LLM 生成的 name(保留 emoji),并补全头像
|
|
901
940
|
if (Array.isArray(userTitles)) {
|
|
902
941
|
userTitles.forEach((title) => {
|
package/package.json
CHANGED