koishi-plugin-zaoan-leafing 0.0.1 → 0.0.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.js +22 -2
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -5091,7 +5091,7 @@ function apply(ctx, config) {
|
|
|
5091
5091
|
const result = await triggerTravelSequence(ctx, config, userInfo, platform, session.guildId || "");
|
|
5092
5092
|
return formatTravelMessage(result, userId, config);
|
|
5093
5093
|
});
|
|
5094
|
-
ctx.command("pig.summary [year:number] [month:number] [user:user]", "生成月度旅行总结").option("all", "-
|
|
5094
|
+
ctx.command("pig.summary [year:number] [month:number] [user:user]", "生成月度旅行总结").option("all", "-A 生成所有用户的总结").action(async ({ session, options }, yearArg, monthArg, targetUser) => {
|
|
5095
5095
|
const now = /* @__PURE__ */ new Date();
|
|
5096
5096
|
let year = yearArg ?? now.getFullYear();
|
|
5097
5097
|
let month = monthArg ?? now.getMonth();
|
|
@@ -5299,7 +5299,7 @@ ${import_koishi3.segment.image(`data:image/png;base64,${base64}`)}`;
|
|
|
5299
5299
|
return `生成熬夜王榜失败: ${e}`;
|
|
5300
5300
|
}
|
|
5301
5301
|
});
|
|
5302
|
-
ctx.command("pig.map [user:user]", "查看用户的世界足迹地图").alias("世界足迹").option("all", "-
|
|
5302
|
+
ctx.command("pig.map [user:user]", "查看用户的世界足迹地图").alias("世界足迹").option("all", "-A 显示本群全部成员的足迹").action(async ({ session, options }, user) => {
|
|
5303
5303
|
const platform = session.platform;
|
|
5304
5304
|
const guildId = session.guildId;
|
|
5305
5305
|
if (options.all) {
|
|
@@ -5506,6 +5506,26 @@ ${import_koishi3.segment.image(`data:image/png;base64,${base64}`)}`;
|
|
|
5506
5506
|
return `保存群组背景图片失败: ${e}`;
|
|
5507
5507
|
}
|
|
5508
5508
|
});
|
|
5509
|
+
ctx.command("pig.cleardb", "清空数据库(仅管理员可用)").option("confirm", "-f 确认清空").action(async ({ session, options }) => {
|
|
5510
|
+
const user = await ctx.database.getUser(session.platform, session.userId, ["authority"]);
|
|
5511
|
+
if (!user || user.authority < 4) {
|
|
5512
|
+
return "权限不足,无法执行此操作。";
|
|
5513
|
+
}
|
|
5514
|
+
if (!options.confirm) {
|
|
5515
|
+
return '警告:此操作将永久清空所有用户状态、旅行记录和群组配置!\n请使用 "pig.cleardb -f" 确认执行。';
|
|
5516
|
+
}
|
|
5517
|
+
try {
|
|
5518
|
+
await session.send("正在清空数据库...");
|
|
5519
|
+
await ctx.database.remove("pig_user_state", {});
|
|
5520
|
+
await ctx.database.remove("pig_travel_log", {});
|
|
5521
|
+
await ctx.database.remove("pig_guild_config", {});
|
|
5522
|
+
ctx.logger("zaoan-leafing").warn(`Database cleared by user ${session.userId} (${session.platform})`);
|
|
5523
|
+
return "数据库已清空。";
|
|
5524
|
+
} catch (e) {
|
|
5525
|
+
ctx.logger("zaoan-leafing").error("Failed to clear database:", e);
|
|
5526
|
+
return `清空数据库失败: ${e}`;
|
|
5527
|
+
}
|
|
5528
|
+
});
|
|
5509
5529
|
ctx.middleware(async (session, next) => {
|
|
5510
5530
|
if (!config.silentRecordEnabled) return next();
|
|
5511
5531
|
if (!session.userId || !session.guildId) return next();
|