koishi-plugin-onebot-verifier 1.1.4 → 1.1.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.d.ts CHANGED
@@ -8,13 +8,18 @@ export interface Config {
8
8
  notifyTarget?: string;
9
9
  debugMode?: boolean;
10
10
  kickBan?: boolean;
11
- timeout?: number;
12
- timeoutAction?: 'accept' | 'reject';
11
+ friendTimeout: 'manual' | {
12
+ action: 'accept' | 'reject';
13
+ timeout: number;
14
+ };
13
15
  friendLevel?: number;
14
16
  friendRegex?: string;
15
17
  minMembers?: number;
16
18
  maxCapacity?: number;
17
- verifyMode?: 'accept' | 'reject' | 'manual';
19
+ memberTimeout: 'manual' | {
20
+ action: 'accept' | 'reject';
21
+ timeout: number;
22
+ };
18
23
  verifyRules?: {
19
24
  guildId: string;
20
25
  keyword?: string;
@@ -31,4 +36,4 @@ export interface Config {
31
36
  voteInSitu?: boolean;
32
37
  }
33
38
  export declare const Config: Schema<Config>;
34
- export declare function apply(ctx: Context, config?: Config): void;
39
+ export declare function apply(ctx: Context, config: Config): void;
package/lib/index.js CHANGED
@@ -49,22 +49,32 @@ var Config = import_koishi.Schema.intersect([
49
49
  kickBan: import_koishi.Schema.boolean().description("被踢自动处理").default(false)
50
50
  }).description("基础配置"),
51
51
  import_koishi.Schema.object({
52
- timeout: import_koishi.Schema.number().description("请求超时时长").default(360).min(0),
53
- timeoutAction: import_koishi.Schema.union([
54
- import_koishi.Schema.const("accept").description("同意"),
55
- import_koishi.Schema.const("reject").description("拒绝")
56
- ]).description("默认超时操作").default("accept"),
52
+ friendTimeout: import_koishi.Schema.union([
53
+ import_koishi.Schema.const("manual").description("手动"),
54
+ import_koishi.Schema.object({
55
+ action: import_koishi.Schema.union([
56
+ import_koishi.Schema.const("accept").description("同意"),
57
+ import_koishi.Schema.const("reject").description("拒绝")
58
+ ]).description("操作").required(),
59
+ timeout: import_koishi.Schema.number().description("时长").default(360).min(1)
60
+ }).description("自动")
61
+ ]).description("模式").default("manual"),
57
62
  friendLevel: import_koishi.Schema.number().description("最低好友等级").default(0).min(0).max(256),
58
63
  friendRegex: import_koishi.Schema.string().description("好友验证正则"),
59
64
  minMembers: import_koishi.Schema.number().description("最低群成员数").default(0).min(0).max(3e3),
60
65
  maxCapacity: import_koishi.Schema.number().description("最低受邀容量").default(0).min(0).max(3e3)
61
66
  }).description("好友邀群配置"),
62
67
  import_koishi.Schema.object({
63
- verifyMode: import_koishi.Schema.union([
64
- import_koishi.Schema.const("accept").description("同意"),
65
- import_koishi.Schema.const("reject").description("拒绝"),
66
- import_koishi.Schema.const("manual").description("手动")
67
- ]).description("处理模式").default("manual"),
68
+ memberTimeout: import_koishi.Schema.union([
69
+ import_koishi.Schema.const("manual").description("手动"),
70
+ import_koishi.Schema.object({
71
+ action: import_koishi.Schema.union([
72
+ import_koishi.Schema.const("accept").description("同意"),
73
+ import_koishi.Schema.const("reject").description("拒绝")
74
+ ]).description("操作").required(),
75
+ timeout: import_koishi.Schema.number().description("超时").default(360).min(1)
76
+ }).description("自动")
77
+ ]).description("模式").default("manual"),
68
78
  verifyRules: import_koishi.Schema.array(import_koishi.Schema.object({
69
79
  guildId: import_koishi.Schema.string().description("群号").required(),
70
80
  keyword: import_koishi.Schema.string().description("正则"),
@@ -93,7 +103,7 @@ var Config = import_koishi.Schema.intersect([
93
103
  ]).description("[验证]难度").default("simple")
94
104
  }).description("特殊验证配置")
95
105
  ]);
96
- function apply(ctx, config = {}) {
106
+ function apply(ctx, config) {
97
107
  const logger = new import_koishi.Logger("onebot-verifier");
98
108
  const activeTasks = /* @__PURE__ */ new Map();
99
109
  const activeCaptchas = /* @__PURE__ */ new Map();
@@ -158,8 +168,7 @@ function apply(ctx, config = {}) {
158
168
  }
159
169
  }, "sendNotice");
160
170
  const setupManual = /* @__PURE__ */ __name(async (session, kind, specialMode, useInSitu) => {
161
- const waitMinutes = config.timeout ?? 0;
162
- const action = kind === "member" ? config.verifyMode : config.timeoutAction;
171
+ const mode = kind === "member" ? config.memberTimeout : config.friendTimeout;
163
172
  let targetStr = config.notifyTarget || "";
164
173
  if (useInSitu && kind === "member" && session.guildId) targetStr = `guild:${session.guildId}`;
165
174
  const msgIds = await sendNotice(session, kind, "waiting", targetStr);
@@ -171,13 +180,13 @@ function apply(ctx, config = {}) {
171
180
  task.votes = { yes: /* @__PURE__ */ new Set(), no: /* @__PURE__ */ new Set() };
172
181
  }
173
182
  msgIds.forEach((id) => activeTasks.set(id, task));
174
- if (waitMinutes > 0 && (specialMode === "vote" || action !== "manual")) {
183
+ if (mode !== "manual" && typeof mode === "object") {
184
+ const { action, timeout } = mode;
175
185
  task.timer = setTimeout(async () => {
176
186
  if (!activeTasks.has(msgIds[0])) return;
177
187
  msgIds.forEach((id) => activeTasks.delete(id));
178
188
  let finalAction = action;
179
- if (specialMode === "vote" && finalAction === "manual") finalAction = "reject";
180
- if (finalAction === "manual") return;
189
+ if (specialMode === "vote") finalAction = "reject";
181
190
  const isPass = finalAction === "accept";
182
191
  await executeAction(session, kind, isPass, isPass ? "" : "等待超时,自动拒绝");
183
192
  const [targetType, targetId] = targetStr.split(":");
@@ -187,7 +196,7 @@ function apply(ctx, config = {}) {
187
196
  });
188
197
  }
189
198
  if (config.debugMode) logger.info(`[操作] 等待超时,默认${isPass ? "通过" : "拒绝"}`);
190
- }, waitMinutes * 6e4);
199
+ }, timeout * 6e4);
191
200
  }
192
201
  }, "setupManual");
193
202
  const hookEvent = /* @__PURE__ */ __name((kind) => async (session) => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-onebot-verifier",
3
3
  "description": "适用于 Onebot 的审核插件,支持自动审核好友/加群/邀请请求",
4
- "version": "1.1.4",
4
+ "version": "1.1.5",
5
5
  "contributors": [
6
6
  "Yis_Rime <yis_rime@outlook.com>"
7
7
  ],