koishi-plugin-group-verification 1.0.20 → 1.0.21
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.js +38 -5
- package/package.json +1 -1
- package/src/index.ts +41 -5
package/lib/index.js
CHANGED
|
@@ -716,7 +716,7 @@ gvc -r # 删除配置`;
|
|
|
716
716
|
await ctx.database.set("group_verification_config", { id: existingConfig.id }, {
|
|
717
717
|
reviewParameters,
|
|
718
718
|
updatedBy: session.username || session.userId,
|
|
719
|
-
updatedAt: /* @__PURE__ */ new Date()
|
|
719
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
720
720
|
});
|
|
721
721
|
logger.info(`已更新数据库阈值为: ${reviewParameters}`);
|
|
722
722
|
} else {
|
|
@@ -735,17 +735,20 @@ gvc -r # 删除配置`;
|
|
|
735
735
|
reminderEnabled,
|
|
736
736
|
reminderMessage,
|
|
737
737
|
updatedBy: session.username || session.userId,
|
|
738
|
-
updatedAt: /* @__PURE__ */ new Date()
|
|
738
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
739
739
|
};
|
|
740
740
|
if (existingConfig) {
|
|
741
|
-
await ctx.database.set("group_verification_config", { id: existingConfig.id },
|
|
741
|
+
await ctx.database.set("group_verification_config", { id: existingConfig.id }, {
|
|
742
|
+
...dbData,
|
|
743
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
744
|
+
});
|
|
742
745
|
logger.info(`更新配置成功 - 审核方式: ${reviewMethod}, 阈值: ${reviewParameters}`);
|
|
743
746
|
} else {
|
|
744
747
|
await ctx.database.create("group_verification_config", {
|
|
745
748
|
groupId: targetGroupId,
|
|
746
749
|
...dbData,
|
|
747
750
|
createdBy: session.username || session.userId,
|
|
748
|
-
createdAt: /* @__PURE__ */ new Date()
|
|
751
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
749
752
|
});
|
|
750
753
|
logger.info(`创建配置成功 - 审核方式: ${reviewMethod}, 阈值: ${reviewParameters}`);
|
|
751
754
|
}
|
|
@@ -1051,6 +1054,36 @@ gvc -r # 删除配置`;
|
|
|
1051
1054
|
- 私聊时必须指定群号(-i参数)`;
|
|
1052
1055
|
});
|
|
1053
1056
|
ctx.on("ready", async () => {
|
|
1057
|
+
try {
|
|
1058
|
+
const configs = await ctx.database.get("group_verification_config", {});
|
|
1059
|
+
for (const cfg of configs) {
|
|
1060
|
+
const updates = {};
|
|
1061
|
+
if (cfg.createdAt instanceof Date) updates.createdAt = cfg.createdAt.toISOString();
|
|
1062
|
+
if (cfg.updatedAt instanceof Date) updates.updatedAt = cfg.updatedAt.toISOString();
|
|
1063
|
+
if (Object.keys(updates).length) {
|
|
1064
|
+
await ctx.database.set("group_verification_config", { id: cfg.id }, updates);
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1067
|
+
const stats = await ctx.database.get("group_verification_stats", {});
|
|
1068
|
+
for (const st of stats) {
|
|
1069
|
+
const updates = {};
|
|
1070
|
+
if (st.lastUpdated instanceof Date) updates.lastUpdated = st.lastUpdated.toISOString();
|
|
1071
|
+
if (Object.keys(updates).length) {
|
|
1072
|
+
await ctx.database.set("group_verification_stats", { id: st.id }, updates);
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
const pendings = await ctx.database.get("group_verification_pending", {});
|
|
1076
|
+
for (const p of pendings) {
|
|
1077
|
+
const updates = {};
|
|
1078
|
+
if (p.applyTime instanceof Date) updates.applyTime = p.applyTime.toISOString();
|
|
1079
|
+
if (Object.keys(updates).length) {
|
|
1080
|
+
await ctx.database.set("group_verification_pending", { id: p.id }, updates);
|
|
1081
|
+
}
|
|
1082
|
+
}
|
|
1083
|
+
logger.info("旧版日期字段迁移完成");
|
|
1084
|
+
} catch (e) {
|
|
1085
|
+
logger.warn("迁移旧日期字段时出错", e);
|
|
1086
|
+
}
|
|
1054
1087
|
const totalStats = await ctx.database.get("group_verification_stats", { groupId: "TOTAL" });
|
|
1055
1088
|
if (totalStats.length === 0) {
|
|
1056
1089
|
await ctx.database.create("group_verification_stats", {
|
|
@@ -1058,7 +1091,7 @@ gvc -r # 删除配置`;
|
|
|
1058
1091
|
autoApproved: 0,
|
|
1059
1092
|
manuallyApproved: 0,
|
|
1060
1093
|
rejected: 0,
|
|
1061
|
-
lastUpdated: /* @__PURE__ */ new Date()
|
|
1094
|
+
lastUpdated: (/* @__PURE__ */ new Date()).toISOString()
|
|
1062
1095
|
});
|
|
1063
1096
|
logger.info("已创建总计统计行");
|
|
1064
1097
|
} else {
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -1008,7 +1008,7 @@ gvc -r # 删除配置`
|
|
|
1008
1008
|
await ctx.database.set('group_verification_config', { id: existingConfig.id }, {
|
|
1009
1009
|
reviewParameters: reviewParameters,
|
|
1010
1010
|
updatedBy: session.username || session.userId,
|
|
1011
|
-
updatedAt: new Date()
|
|
1011
|
+
updatedAt: new Date().toISOString()
|
|
1012
1012
|
})
|
|
1013
1013
|
logger.info(`已更新数据库阈值为: ${reviewParameters}`)
|
|
1014
1014
|
} else {
|
|
@@ -1034,18 +1034,22 @@ gvc -r # 删除配置`
|
|
|
1034
1034
|
reminderEnabled: reminderEnabled,
|
|
1035
1035
|
reminderMessage: reminderMessage,
|
|
1036
1036
|
updatedBy: session.username || session.userId,
|
|
1037
|
-
updatedAt: new Date()
|
|
1037
|
+
updatedAt: new Date().toISOString()
|
|
1038
1038
|
}
|
|
1039
1039
|
|
|
1040
1040
|
if (existingConfig) {
|
|
1041
|
-
|
|
1041
|
+
// ensure timestamp strings for compatibility
|
|
1042
|
+
await ctx.database.set('group_verification_config', { id: existingConfig.id }, {
|
|
1043
|
+
...dbData,
|
|
1044
|
+
updatedAt: new Date().toISOString(),
|
|
1045
|
+
})
|
|
1042
1046
|
logger.info(`更新配置成功 - 审核方式: ${reviewMethod}, 阈值: ${reviewParameters}`)
|
|
1043
1047
|
} else {
|
|
1044
1048
|
await ctx.database.create('group_verification_config', {
|
|
1045
1049
|
groupId: targetGroupId,
|
|
1046
1050
|
...dbData,
|
|
1047
1051
|
createdBy: session.username || session.userId,
|
|
1048
|
-
createdAt: new Date()
|
|
1052
|
+
createdAt: new Date().toISOString()
|
|
1049
1053
|
})
|
|
1050
1054
|
logger.info(`创建配置成功 - 审核方式: ${reviewMethod}, 阈值: ${reviewParameters}`)
|
|
1051
1055
|
}
|
|
@@ -1428,6 +1432,38 @@ gvc -r # 删除配置`
|
|
|
1428
1432
|
|
|
1429
1433
|
// 插件初始化时确保总计统计行存在
|
|
1430
1434
|
ctx.on('ready', async () => {
|
|
1435
|
+
// 迁移:将旧版保留的 Date 对象字段转换为 ISO 字符串,以避免绑定错误
|
|
1436
|
+
try {
|
|
1437
|
+
const configs = await ctx.database.get('group_verification_config', {})
|
|
1438
|
+
for (const cfg of configs) {
|
|
1439
|
+
const updates: any = {}
|
|
1440
|
+
if (cfg.createdAt instanceof Date) updates.createdAt = cfg.createdAt.toISOString()
|
|
1441
|
+
if (cfg.updatedAt instanceof Date) updates.updatedAt = cfg.updatedAt.toISOString()
|
|
1442
|
+
if (Object.keys(updates).length) {
|
|
1443
|
+
await ctx.database.set('group_verification_config', { id: cfg.id }, updates)
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1446
|
+
const stats = await ctx.database.get('group_verification_stats', {})
|
|
1447
|
+
for (const st of stats) {
|
|
1448
|
+
const updates: any = {}
|
|
1449
|
+
if (st.lastUpdated instanceof Date) updates.lastUpdated = st.lastUpdated.toISOString()
|
|
1450
|
+
if (Object.keys(updates).length) {
|
|
1451
|
+
await ctx.database.set('group_verification_stats', { id: st.id }, updates)
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
const pendings = await ctx.database.get('group_verification_pending', {})
|
|
1455
|
+
for (const p of pendings) {
|
|
1456
|
+
const updates: any = {}
|
|
1457
|
+
if (p.applyTime instanceof Date) updates.applyTime = p.applyTime.toISOString()
|
|
1458
|
+
if (Object.keys(updates).length) {
|
|
1459
|
+
await ctx.database.set('group_verification_pending', { id: p.id }, updates)
|
|
1460
|
+
}
|
|
1461
|
+
}
|
|
1462
|
+
logger.info('旧版日期字段迁移完成')
|
|
1463
|
+
} catch (e) {
|
|
1464
|
+
logger.warn('迁移旧日期字段时出错', e)
|
|
1465
|
+
}
|
|
1466
|
+
|
|
1431
1467
|
// 检查是否已存在总计行(groupId为'TOTAL')
|
|
1432
1468
|
const totalStats = await ctx.database.get('group_verification_stats', { groupId: 'TOTAL' })
|
|
1433
1469
|
|
|
@@ -1438,7 +1474,7 @@ gvc -r # 删除配置`
|
|
|
1438
1474
|
autoApproved: 0,
|
|
1439
1475
|
manuallyApproved: 0,
|
|
1440
1476
|
rejected: 0,
|
|
1441
|
-
lastUpdated: new Date()
|
|
1477
|
+
lastUpdated: new Date().toISOString()
|
|
1442
1478
|
})
|
|
1443
1479
|
logger.info('已创建总计统计行')
|
|
1444
1480
|
} else {
|