koishi-plugin-echo-cave 1.24.1 → 1.24.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.
Files changed (2) hide show
  1. package/lib/index.cjs +11 -12
  2. package/package.json +1 -1
package/lib/index.cjs CHANGED
@@ -908,24 +908,22 @@ var PREDEFINED_PERIODS = [
908
908
  "all"
909
909
  ];
910
910
  var TIME_UNITS = {
911
- m: 60 * 1e3,
912
- // minutes
913
- h: 60 * 60 * 1e3,
914
- // hours
915
- d: 24 * 60 * 60 * 1e3,
916
- // days
911
+ m: 30 * 24 * 60 * 60 * 1e3,
912
+ // 月(按约 30 天算)
917
913
  w: 7 * 24 * 60 * 60 * 1e3,
918
- // weeks
919
- M: 30 * 24 * 60 * 60 * 1e3
920
- // months (approximate)
914
+ //
915
+ d: 24 * 60 * 60 * 1e3,
916
+ //
917
+ h: 60 * 60 * 1e3
918
+ // 小时
921
919
  };
922
920
  function parseCustomTime(timeStr) {
923
- const regex = /(\d+)([mhdwM])/g;
921
+ const regex = /(\d+)([mwdh])/g;
924
922
  let match;
925
923
  let totalMs = 0;
926
924
  let lastUnit = "";
927
- const unitOrder = ["M", "w", "d", "h", "m"];
928
- if (!/^(\d+[mhdwM])+$/.test(timeStr)) {
925
+ const unitOrder = ["m", "w", "d", "h"];
926
+ if (!/^(\d+[mwdh])+$/i.test(timeStr)) {
929
927
  return null;
930
928
  }
931
929
  while ((match = regex.exec(timeStr)) !== null) {
@@ -933,6 +931,7 @@ function parseCustomTime(timeStr) {
933
931
  const num = parseInt(value, 10);
934
932
  const currentIndex = unitOrder.indexOf(unit);
935
933
  const lastIndex = unitOrder.indexOf(lastUnit);
934
+ if (lastUnit && currentIndex < 0) return null;
936
935
  if (lastUnit && currentIndex > lastIndex) {
937
936
  return null;
938
937
  }
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.24.1",
4
+ "version": "1.24.2",
5
5
  "main": "lib/index.cjs",
6
6
  "typings": "lib/index.d.ts",
7
7
  "type": "module",