koishi-plugin-best-cave 2.4.4 → 2.4.5
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 +12 -0
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -1008,6 +1008,18 @@ function apply(ctx, config) {
|
|
|
1008
1008
|
const reviewManager = config.enablePend ? new PendManager(ctx, config, fileManager, logger, reusableIds) : null;
|
|
1009
1009
|
const hashManager = config.enableSimilarity ? new HashManager(ctx, config, logger, fileManager) : null;
|
|
1010
1010
|
const dataManager = config.enableIO ? new DataManager(ctx, config, fileManager, logger) : null;
|
|
1011
|
+
ctx.on("ready", async () => {
|
|
1012
|
+
try {
|
|
1013
|
+
const staleCaves = await ctx.database.get("cave", { status: "preload" });
|
|
1014
|
+
if (staleCaves.length > 0) {
|
|
1015
|
+
const idsToMark = staleCaves.map((c) => ({ id: c.id, status: "delete" }));
|
|
1016
|
+
await ctx.database.upsert("cave", idsToMark);
|
|
1017
|
+
await cleanupPendingDeletions(ctx, fileManager, logger, reusableIds);
|
|
1018
|
+
}
|
|
1019
|
+
} catch (error) {
|
|
1020
|
+
logger.error("清理残留回声洞时发生错误:", error);
|
|
1021
|
+
}
|
|
1022
|
+
});
|
|
1011
1023
|
const cave = ctx.command("cave", "回声洞").option("add", "-a <content:text> 添加回声洞").option("view", "-g <id:posint> 查看指定回声洞").option("delete", "-r <id:posint> 删除指定回声洞").option("list", "-l 查询投稿统计").usage("随机抽取一条已添加的回声洞。").action(async ({ session, options }) => {
|
|
1012
1024
|
if (options.add) return session.execute(`cave.add ${options.add}`);
|
|
1013
1025
|
if (options.view) return session.execute(`cave.view ${options.view}`);
|