koishi-plugin-echo-cave 1.21.1 → 1.22.0
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/config/config.d.ts +1 -0
- package/lib/index.cjs +13 -8
- package/package.json +1 -1
package/lib/config/config.d.ts
CHANGED
package/lib/index.cjs
CHANGED
|
@@ -44,7 +44,8 @@ var require_zh_CN = __commonJS({
|
|
|
44
44
|
maxRecordSize: "\u6700\u5927\u5F55\u97F3\u5927\u5C0F (MB)",
|
|
45
45
|
useBase64ForMedia: "\u662F\u5426\u4F7F\u7528 Base64 \u7F16\u7801\u53D1\u9001\u5A92\u4F53\u6587\u4EF6\uFF0C\u5F00\u542F\u540E\u5C06\u8BFB\u53D6 base64 \u7F16\u7801\u53D1\u9001\u800C\u4E0D\u662F\u4F7F\u7528 file uri",
|
|
46
46
|
sendAllAsForwardMsg: "\u662F\u5426\u5C06\u6240\u6709\u6D88\u606F\u4EE5\u8F6C\u53D1\u6D88\u606F\u5F62\u5F0F\u53D1\u9001\uFF0C\u5F00\u542F\u540E\u666E\u901A\u6D88\u606F\u4E5F\u4F1A\u8F6C\u6362\u4E3A\u8F6C\u53D1\u6D88\u606F\u683C\u5F0F",
|
|
47
|
-
rankingTopCount: "\u6392\u884C\u699C\u663E\u793A\u7684\u7528\u6237\u6570\u91CF"
|
|
47
|
+
rankingTopCount: "\u6392\u884C\u699C\u663E\u793A\u7684\u7528\u6237\u6570\u91CF",
|
|
48
|
+
considerOriginUserAsRelated: "\u662F\u5426\u5C06\u539F\u6D88\u606F\u53D1\u9001\u8005\u89C6\u4E3A\u76F8\u5173\u7528\u6237\uFF0C\u9ED8\u8BA4\u4E0D\u8003\u8651"
|
|
48
49
|
};
|
|
49
50
|
}
|
|
50
51
|
});
|
|
@@ -181,7 +182,7 @@ var require_zh_CN2 = __commonJS({
|
|
|
181
182
|
invalidPeriod: "\u65E0\u6548\u7684\u65F6\u95F4\u6BB5\u53C2\u6570\u3002\u652F\u6301\u7684\u65F6\u95F4\u6BB5\uFF1A{0}",
|
|
182
183
|
rankingTitle: "\u{1F4CA} \u56DE\u58F0\u6D1E\u6392\u884C\u699C ({0})",
|
|
183
184
|
noData: "\u6682\u65E0\u6570\u636E",
|
|
184
|
-
rankFormat: "{
|
|
185
|
+
rankFormat: "{rankEmoji} {userName}\uFF1A{count} \u4E2A\u56DE\u58F0\u6D1E",
|
|
185
186
|
period: {
|
|
186
187
|
day: "24 \u5C0F\u65F6",
|
|
187
188
|
week: "7 \u5929",
|
|
@@ -915,13 +916,15 @@ function getStartTime(period) {
|
|
|
915
916
|
}
|
|
916
917
|
return startTime;
|
|
917
918
|
}
|
|
918
|
-
function countUserOccurrences(caves) {
|
|
919
|
+
function countUserOccurrences(caves, considerOriginUser) {
|
|
919
920
|
const countMap = /* @__PURE__ */ new Map();
|
|
920
921
|
caves.forEach((cave) => {
|
|
921
922
|
cave.relatedUsers.forEach((userId) => {
|
|
922
923
|
countMap.set(userId, (countMap.get(userId) || 0) + 1);
|
|
923
924
|
});
|
|
924
|
-
|
|
925
|
+
if (considerOriginUser) {
|
|
926
|
+
countMap.set(cave.originUserId, (countMap.get(cave.originUserId) || 0) + 1);
|
|
927
|
+
}
|
|
925
928
|
});
|
|
926
929
|
return countMap;
|
|
927
930
|
}
|
|
@@ -949,10 +952,11 @@ async function generateRankingText(ctx, session, countMap, topCount) {
|
|
|
949
952
|
default:
|
|
950
953
|
rankEmoji = `${rank}.`;
|
|
951
954
|
}
|
|
955
|
+
const rankData = { rankEmoji, userName, count };
|
|
952
956
|
if (i === sortedUsers.length - 1) {
|
|
953
|
-
text += session.text(".rankFormat",
|
|
957
|
+
text += session.text(".rankFormat", rankData);
|
|
954
958
|
} else {
|
|
955
|
-
text += session.text(".rankFormat",
|
|
959
|
+
text += session.text(".rankFormat", rankData) + "\n";
|
|
956
960
|
}
|
|
957
961
|
}
|
|
958
962
|
}
|
|
@@ -977,7 +981,7 @@ async function getRanking(ctx, session, cfg, period = "all") {
|
|
|
977
981
|
$gte: startTime
|
|
978
982
|
}
|
|
979
983
|
});
|
|
980
|
-
const countMap = countUserOccurrences(caves);
|
|
984
|
+
const countMap = countUserOccurrences(caves, cfg.considerOriginUserAsRelated || false);
|
|
981
985
|
const rankingText = await generateRankingText(ctx, session, countMap, topCount);
|
|
982
986
|
const botName = await getUserName(this.ctx, session, session.bot?.userId) || "Bot";
|
|
983
987
|
const periodText = session.text(`.period.${period}`);
|
|
@@ -1038,7 +1042,8 @@ var Config = import_koishi2.Schema.object({
|
|
|
1038
1042
|
maxRecordSize: import_koishi2.Schema.number().default(512),
|
|
1039
1043
|
useBase64ForMedia: import_koishi2.Schema.boolean().default(false),
|
|
1040
1044
|
sendAllAsForwardMsg: import_koishi2.Schema.boolean().default(false),
|
|
1041
|
-
rankingTopCount: import_koishi2.Schema.number().default(10)
|
|
1045
|
+
rankingTopCount: import_koishi2.Schema.number().default(10),
|
|
1046
|
+
considerOriginUserAsRelated: import_koishi2.Schema.boolean().default(true)
|
|
1042
1047
|
}).i18n({
|
|
1043
1048
|
"zh-CN": require_zh_CN()
|
|
1044
1049
|
});
|