koishi-plugin-ccb-plus 1.0.3 → 1.0.4

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/config.d.ts CHANGED
@@ -17,5 +17,6 @@ export interface CCBConfig {
17
17
  critProb: number;
18
18
  toggleCooldown: number;
19
19
  cheatList: CheatConfig[];
20
+ resetAllUsers?: 'on' | 'off';
20
21
  }
21
22
  export declare const Config: Schema<CCBConfig>;
package/lib/index.js CHANGED
@@ -56,7 +56,11 @@ var Config = import_koishi.Schema.object({
56
56
  ywProbability: import_koishi.Schema.number().default(0).min(0).max(1).description("特权冷却概率"),
57
57
  critProb: import_koishi.Schema.number().default(0.8).min(0).max(1).description("特权暴击概率"),
58
58
  ywBanDuration: import_koishi.Schema.number().default(60).description("特权冷却时长(秒)")
59
- })).role("table").description("开挂名单(优先级高于全局设置)")
59
+ })).role("table").description("开挂名单(优先级高于全局设置)"),
60
+ resetAllUsers: import_koishi.Schema.union([
61
+ import_koishi.Schema.const("on").description("重置为开放模式"),
62
+ import_koishi.Schema.const("off").description("重置为保护模式")
63
+ ]).description("一键重置所有用户的全局状态(针对性设置不变)").role("radio")
60
64
  });
61
65
 
62
66
  // src/model.ts
@@ -439,8 +443,10 @@ function applyCcbCommand(ctx, config, state) {
439
443
  }
440
444
  const [senderSetting] = await ctx.database.get("ccb_setting", { userId: senderId });
441
445
  const senderOptOut = senderSetting?.optOut ?? true;
446
+ const senderIsInitial = !senderSetting;
442
447
  if (senderOptOut) {
443
- return "你已开启保护模式,无法ccb他人。请先使用 ccb --on 解除保护。";
448
+ const message2 = senderIsInitial ? "你还未开启ccb功能。请先使用 ccb --on 来开启。" : "你已开启保护模式,无法ccb他人。请先使用 ccb --on 解除保护。";
449
+ return message2;
444
450
  }
445
451
  const actorId = senderId;
446
452
  const now = Date.now() / 1e3;
@@ -732,6 +738,24 @@ function apply(ctx, config) {
732
738
  applyDatabase(ctx);
733
739
  const state = new CcbState(ctx);
734
740
  applyCommands(ctx, config, state);
741
+ ctx.on("ready", async () => {
742
+ if (config.resetAllUsers) {
743
+ const mode = config.resetAllUsers;
744
+ const newOptOut = mode === "off";
745
+ const allSettings = await ctx.database.get("ccb_setting", {});
746
+ const updates = allSettings.map((setting) => ({
747
+ userId: setting.userId,
748
+ optOut: newOptOut,
749
+ overrides: setting.overrides,
750
+ lastToggleTime: setting.lastToggleTime,
751
+ lastToggleTimes: setting.lastToggleTimes
752
+ }));
753
+ if (updates.length > 0) {
754
+ await ctx.database.upsert("ccb_setting", updates);
755
+ }
756
+ ctx.logger.info(`已将 ${updates.length} 个用户的全局状态重置为${mode === "off" ? "保护" : "开放"}模式`);
757
+ }
758
+ });
735
759
  }
736
760
  __name(apply, "apply");
737
761
  // Annotate the CommonJS export names for ESM import in node:
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-ccb-plus",
3
3
  "description": "Koishi 插件,与群友发生 ccb 行为。(移植自 astrbot_plugin_ccb_plus )",
4
- "version": "1.0.3",
4
+ "version": "1.0.4",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [
package/readme.md CHANGED
@@ -42,6 +42,14 @@ npm install koishi-plugin-ccb-plus
42
42
 
43
43
  **注意:** 处于保护模式的用户无法 ccb 他人,需先使用 `ccb --on` 解除。
44
44
 
45
+ ### 管理功能
46
+
47
+ 管理员可以在插件配置界面使用"重置所有用户状态"功能:
48
+ - 选择"重置为开放模式" - 一键将所有用户的全局状态设为开放
49
+ - 选择"重置为保护模式" - 一键将所有用户的全局状态设为保护
50
+
51
+ **说明:** 重置功能只影响全局状态,用户的针对性设置不受影响。
52
+
45
53
  ## 配置项
46
54
 
47
55
  | 配置项 | 类型 | 默认值 | 说明 |