koishi-plugin-echo-cave 1.21.0 → 1.21.1
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/index.cjs +16 -22
- package/package.json +1 -1
package/lib/index.cjs
CHANGED
|
@@ -179,14 +179,13 @@ var require_zh_CN2 = __commonJS({
|
|
|
179
179
|
description: "\u67E5\u770B\u56DE\u58F0\u6D1E\u6392\u884C\u699C",
|
|
180
180
|
messages: {
|
|
181
181
|
invalidPeriod: "\u65E0\u6548\u7684\u65F6\u95F4\u6BB5\u53C2\u6570\u3002\u652F\u6301\u7684\u65F6\u95F4\u6BB5\uFF1A{0}",
|
|
182
|
-
rankingTitle: "\u{1F4CA} \u56DE\u58F0\u6D1E\u6392\u884C\u699C
|
|
182
|
+
rankingTitle: "\u{1F4CA} \u56DE\u58F0\u6D1E\u6392\u884C\u699C ({0})",
|
|
183
183
|
noData: "\u6682\u65E0\u6570\u636E",
|
|
184
184
|
rankFormat: "{0} {1}\uFF1A{2} \u4E2A\u56DE\u58F0\u6D1E",
|
|
185
|
-
rankingHeader: "\u4ECA\u65E5\u4EBA\u54C1\u6392\u884C\u699C",
|
|
186
185
|
period: {
|
|
187
|
-
day: "24\u5C0F\u65F6",
|
|
188
|
-
week: "7\u5929",
|
|
189
|
-
month: "1\u4E2A\u6708",
|
|
186
|
+
day: "24 \u5C0F\u65F6",
|
|
187
|
+
week: "7 \u5929",
|
|
188
|
+
month: "1 \u4E2A\u6708",
|
|
190
189
|
all: "\u6240\u6709\u65F6\u95F4"
|
|
191
190
|
}
|
|
192
191
|
}
|
|
@@ -926,10 +925,9 @@ function countUserOccurrences(caves) {
|
|
|
926
925
|
});
|
|
927
926
|
return countMap;
|
|
928
927
|
}
|
|
929
|
-
async function generateRankingText(ctx, session, countMap,
|
|
928
|
+
async function generateRankingText(ctx, session, countMap, topCount) {
|
|
930
929
|
const sortedUsers = Array.from(countMap.entries()).sort(([, a], [, b]) => b - a).slice(0, topCount);
|
|
931
|
-
|
|
932
|
-
let text = session.text(".rankingTitle", [periodText]) + "\n\n";
|
|
930
|
+
let text = "";
|
|
933
931
|
if (sortedUsers.length === 0) {
|
|
934
932
|
text += session.text(".noData");
|
|
935
933
|
} else {
|
|
@@ -949,9 +947,13 @@ async function generateRankingText(ctx, session, countMap, period, topCount) {
|
|
|
949
947
|
rankEmoji = "\u{1F949}";
|
|
950
948
|
break;
|
|
951
949
|
default:
|
|
952
|
-
rankEmoji =
|
|
950
|
+
rankEmoji = `${rank}.`;
|
|
951
|
+
}
|
|
952
|
+
if (i === sortedUsers.length - 1) {
|
|
953
|
+
text += session.text(".rankFormat", [rankEmoji, userName, count]);
|
|
954
|
+
} else {
|
|
955
|
+
text += session.text(".rankFormat", [rankEmoji, userName, count]) + "\n";
|
|
953
956
|
}
|
|
954
|
-
text += session.text(".rankFormat", [rankEmoji, userName, count]) + "\n";
|
|
955
957
|
}
|
|
956
958
|
}
|
|
957
959
|
return text;
|
|
@@ -976,20 +978,12 @@ async function getRanking(ctx, session, cfg, period = "all") {
|
|
|
976
978
|
}
|
|
977
979
|
});
|
|
978
980
|
const countMap = countUserOccurrences(caves);
|
|
979
|
-
const rankingText = await generateRankingText(
|
|
980
|
-
ctx,
|
|
981
|
-
session,
|
|
982
|
-
countMap,
|
|
983
|
-
normalizedPeriod,
|
|
984
|
-
topCount
|
|
985
|
-
);
|
|
981
|
+
const rankingText = await generateRankingText(ctx, session, countMap, topCount);
|
|
986
982
|
const botName = await getUserName(this.ctx, session, session.bot?.userId) || "Bot";
|
|
983
|
+
const periodText = session.text(`.period.${period}`);
|
|
984
|
+
let title = session.text(".rankingTitle", [periodText]);
|
|
987
985
|
await session.onebot.sendGroupForwardMsg(channelId, [
|
|
988
|
-
createTextMsgNode(
|
|
989
|
-
session.bot?.userId || session.userId,
|
|
990
|
-
botName,
|
|
991
|
-
session.text(".rankingHeader")
|
|
992
|
-
),
|
|
986
|
+
createTextMsgNode(session.bot?.userId || session.userId, botName, title),
|
|
993
987
|
createTextMsgNode(session.bot?.userId || session.userId, botName, rankingText)
|
|
994
988
|
]);
|
|
995
989
|
}
|