koishi-plugin-echo-cave 1.22.1 → 1.22.2

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.
@@ -12,6 +12,5 @@ export interface Config {
12
12
  useBase64ForMedia?: boolean;
13
13
  sendAllAsForwardMsg?: boolean;
14
14
  rankingTopCount?: number;
15
- considerOriginUserAsRelated?: boolean;
16
15
  }
17
16
  export declare const Config: Schema<Config>;
package/lib/index.cjs CHANGED
@@ -44,8 +44,7 @@ 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",
48
- considerOriginUserAsRelated: "\u662F\u5426\u5C06\u539F\u6D88\u606F\u53D1\u9001\u8005\u89C6\u4E3A\u76F8\u5173\u7528\u6237\uFF0C\u9ED8\u8BA4\u4E0D\u8003\u8651"
47
+ rankingTopCount: "\u6392\u884C\u699C\u663E\u793A\u7684\u7528\u6237\u6570\u91CF"
49
48
  };
50
49
  }
51
50
  });
@@ -176,7 +175,7 @@ var require_zh_CN2 = __commonJS({
176
175
  userBoundSuccess: "\u2705 \u5DF2\u6210\u529F\u5C06\u7528\u6237\u7ED1\u5B9A\u5230\u56DE\u58F0\u6D1E #{0}\uFF01"
177
176
  }
178
177
  },
179
- "cave.ranking": {
178
+ "cave.rank": {
180
179
  description: "\u67E5\u770B\u56DE\u58F0\u6D1E\u6392\u884C\u699C",
181
180
  messages: {
182
181
  invalidPeriod: "\u65E0\u6548\u7684\u65F6\u95F4\u6BB5\u53C2\u6570\u3002\u652F\u6301\u7684\u65F6\u95F4\u6BB5\uFF1A{0}",
@@ -895,7 +894,7 @@ async function bindUsersToCave(ctx, session, id, userIds) {
895
894
  return session.text(".userBoundSuccess", [id]);
896
895
  }
897
896
 
898
- // src/core/command/ranking.ts
897
+ // src/core/command/rank.ts
899
898
  var SUPPORTED_PERIODS = ["day", "week", "month", "all"];
900
899
  function getStartTime(period) {
901
900
  const now = /* @__PURE__ */ new Date();
@@ -916,14 +915,15 @@ function getStartTime(period) {
916
915
  }
917
916
  return startTime;
918
917
  }
919
- function countUserOccurrences(caves, considerOriginUser) {
918
+ function countUserOccurrences(caves) {
920
919
  const countMap = /* @__PURE__ */ new Map();
921
920
  caves.forEach((cave) => {
922
- cave.relatedUsers.forEach((userId) => {
923
- countMap.set(userId, (countMap.get(userId) || 0) + 1);
924
- });
925
- if (considerOriginUser) {
921
+ if (cave.relatedUsers.length === 0) {
926
922
  countMap.set(cave.originUserId, (countMap.get(cave.originUserId) || 0) + 1);
923
+ } else {
924
+ cave.relatedUsers.forEach((userId) => {
925
+ countMap.set(userId, (countMap.get(userId) || 0) + 1);
926
+ });
927
927
  }
928
928
  });
929
929
  return countMap;
@@ -981,7 +981,7 @@ async function getRanking(ctx, session, cfg, period = "all") {
981
981
  $gte: startTime
982
982
  }
983
983
  });
984
- const countMap = countUserOccurrences(caves, cfg.considerOriginUserAsRelated || false);
984
+ const countMap = countUserOccurrences(caves);
985
985
  const rankingText = await generateRankingText(ctx, session, countMap, topCount);
986
986
  const botName = await getUserName(this.ctx, session, session.bot?.userId) || "Bot";
987
987
  const periodText = session.text(`.period.${period}`);
@@ -1042,8 +1042,7 @@ var Config = import_koishi2.Schema.object({
1042
1042
  maxRecordSize: import_koishi2.Schema.number().default(512),
1043
1043
  useBase64ForMedia: import_koishi2.Schema.boolean().default(false),
1044
1044
  sendAllAsForwardMsg: import_koishi2.Schema.boolean().default(false),
1045
- rankingTopCount: import_koishi2.Schema.number().default(10),
1046
- considerOriginUserAsRelated: import_koishi2.Schema.boolean().default(true)
1045
+ rankingTopCount: import_koishi2.Schema.number().default(10)
1047
1046
  }).i18n({
1048
1047
  "zh-CN": require_zh_CN()
1049
1048
  });
@@ -1119,7 +1118,7 @@ function apply(ctx, cfg) {
1119
1118
  ctx.command("cave.bind <id:number> <...userIds>", { authority: 4 }).action(
1120
1119
  async ({ session }, id, ...userIds) => await bindUsersToCave(ctx, session, id, userIds)
1121
1120
  );
1122
- ctx.command("cave.ranking [period:string]").action(
1121
+ ctx.command("cave.rank [period:string]").action(
1123
1122
  async ({ session }, period) => await getRanking(ctx, session, cfg, period)
1124
1123
  );
1125
1124
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-echo-cave",
3
3
  "description": "Group echo cave",
4
- "version": "1.22.1",
4
+ "version": "1.22.2",
5
5
  "main": "lib/index.cjs",
6
6
  "typings": "lib/index.d.ts",
7
7
  "type": "module",
File without changes