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.
- package/lib/index.cjs +11 -12
- 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
|
-
//
|
|
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
|
-
//
|
|
919
|
-
|
|
920
|
-
//
|
|
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+)([
|
|
921
|
+
const regex = /(\d+)([mwdh])/g;
|
|
924
922
|
let match;
|
|
925
923
|
let totalMs = 0;
|
|
926
924
|
let lastUnit = "";
|
|
927
|
-
const unitOrder = ["
|
|
928
|
-
if (!/^(\d+[
|
|
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
|
}
|