koishi-plugin-echo-cave 1.22.2 → 1.23.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.
@@ -1,5 +1,5 @@
1
1
  import { Config } from '../../config/config';
2
2
  import { Context, Session } from 'koishi';
3
- export type Period = 'day' | 'week' | 'month' | 'all';
3
+ export type Period = 'lday' | 'lweek' | 'lmonth' | 'day' | 'week' | 'month' | 'all';
4
4
  export declare const SUPPORTED_PERIODS: Period[];
5
5
  export declare function getRanking(ctx: Context, session: Session, cfg: Config, period?: string): Promise<void>;
package/lib/index.cjs CHANGED
@@ -183,9 +183,12 @@ var require_zh_CN2 = __commonJS({
183
183
  noData: "\u6682\u65E0\u6570\u636E",
184
184
  rankFormat: "{rankEmoji} {userName}\uFF1A{count} \u4E2A\u56DE\u58F0\u6D1E",
185
185
  period: {
186
- day: "24 \u5C0F\u65F6",
187
- week: "7 \u5929",
188
- month: "1 \u4E2A\u6708",
186
+ lday: "\u8FC7\u53BB 24 \u5C0F\u65F6",
187
+ lweek: "\u8FC7\u53BB 7 \u5929",
188
+ lmonth: "\u8FC7\u53BB 30 \u5929",
189
+ day: "\u4ECA\u5929",
190
+ week: "\u672C\u5468",
191
+ month: "\u672C\u6708",
189
192
  all: "\u6240\u6709\u65F6\u95F4"
190
193
  }
191
194
  }
@@ -895,20 +898,44 @@ async function bindUsersToCave(ctx, session, id, userIds) {
895
898
  }
896
899
 
897
900
  // src/core/command/rank.ts
898
- var SUPPORTED_PERIODS = ["day", "week", "month", "all"];
901
+ var SUPPORTED_PERIODS = [
902
+ "lday",
903
+ "lweek",
904
+ "lmonth",
905
+ "day",
906
+ "week",
907
+ "month",
908
+ "all"
909
+ ];
899
910
  function getStartTime(period) {
900
911
  const now = /* @__PURE__ */ new Date();
901
912
  const startTime = /* @__PURE__ */ new Date();
902
913
  switch (period) {
903
- case "day":
914
+ // Last day/week/month (previous 24h, 7d, 30d)
915
+ case "lday":
904
916
  startTime.setDate(now.getDate() - 1);
905
917
  break;
906
- case "week":
918
+ case "lweek":
907
919
  startTime.setDate(now.getDate() - 7);
908
920
  break;
921
+ case "lmonth":
922
+ startTime.setDate(now.getDate() - 30);
923
+ break;
924
+ // This day/week/month (from start of period to now)
925
+ case "day":
926
+ startTime.setHours(0, 0, 0, 0);
927
+ break;
928
+ case "week":
929
+ const dayOfWeek = now.getDay();
930
+ const daysToMonday = dayOfWeek === 0 ? 6 : dayOfWeek - 1;
931
+ startTime.setDate(now.getDate() - daysToMonday);
932
+ startTime.setHours(0, 0, 0, 0);
933
+ break;
909
934
  case "month":
910
- startTime.setMonth(now.getMonth() - 1);
935
+ startTime.setDate(1);
936
+ startTime.setHours(0, 0, 0, 0);
911
937
  break;
938
+ // All time
912
939
  case "all":
913
940
  startTime.setTime(0);
914
941
  break;
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.2",
4
+ "version": "1.23.0",
5
5
  "main": "lib/index.cjs",
6
6
  "typings": "lib/index.d.ts",
7
7
  "type": "module",