koishi-plugin-onebot-verifier 1.1.0 → 1.1.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.d.ts CHANGED
@@ -27,6 +27,7 @@ export interface Config {
27
27
  enabled: boolean;
28
28
  mode: 'vote' | 'captcha';
29
29
  }[];
30
+ captchaDiff?: 'simple' | 'medium' | 'hard';
30
31
  voteRatio?: string;
31
32
  }
32
33
  export declare const Config: Schema<Config>;
package/lib/index.js CHANGED
@@ -85,7 +85,12 @@ var Config = import_koishi.Schema.intersect([
85
85
  ]).description("模式").default("vote"),
86
86
  enabled: import_koishi.Schema.boolean().description("前置规则").default(true)
87
87
  })).description("配置列表").role("table"),
88
- voteRatio: import_koishi.Schema.string().description("投票比例").default("3:2")
88
+ voteRatio: import_koishi.Schema.string().description("[投票]人数").default("3:2"),
89
+ captchaDiff: import_koishi.Schema.union([
90
+ import_koishi.Schema.const("simple").description("简单"),
91
+ import_koishi.Schema.const("medium").description("中等"),
92
+ import_koishi.Schema.const("hard").description("困难")
93
+ ]).description("[验证码]难度").default("simple")
89
94
  }).description("特殊验证配置")
90
95
  ]);
91
96
  function apply(ctx, config = {}) {
@@ -228,12 +233,6 @@ function apply(ctx, config = {}) {
228
233
  return;
229
234
  }
230
235
  }
231
- if (config.verifyMode && config.verifyMode !== "manual") {
232
- const isApprove = config.verifyMode === "accept";
233
- await executeAction(session, kind, isApprove, "默认规则,自动处理");
234
- await sendNotice(session, kind, isApprove ? "auto_pass" : "auto_reject");
235
- return;
236
- }
237
236
  return await setupManual(session, kind);
238
237
  }
239
238
  let verdict = false;
@@ -325,11 +324,31 @@ function apply(ctx, config = {}) {
325
324
  if (!config.specialRules || !session.guildId || !session.userId) return;
326
325
  const rule = config.specialRules.find((r) => String(r.guildId) === String(session.guildId) && r.enabled);
327
326
  if (rule?.mode === "captcha") {
328
- const a = Math.floor(Math.random() * 20) + 1;
329
- const b = Math.floor(Math.random() * 20) + 1;
330
- const answer = (a + b).toString();
327
+ let a, b, op = "+", answer;
328
+ if (config.captchaDiff === "simple") {
329
+ a = Math.floor(Math.random() * 80) + 10;
330
+ b = Math.floor(Math.random() * 80) + 10;
331
+ if (Math.random() > 0.5) {
332
+ op = "+";
333
+ answer = (a + b).toString();
334
+ } else {
335
+ op = "-";
336
+ if (a < b) [a, b] = [b, a];
337
+ answer = (a - b).toString();
338
+ }
339
+ } else if (config.captchaDiff === "medium") {
340
+ a = Math.floor(Math.random() * 89) + 11;
341
+ b = Math.floor(Math.random() * 8) + 2;
342
+ op = "×";
343
+ answer = (a * b).toString();
344
+ } else {
345
+ a = Math.floor(Math.random() * 40) + 11;
346
+ b = Math.floor(Math.random() * 10) + 11;
347
+ op = "×";
348
+ answer = (a * b).toString();
349
+ }
331
350
  const captchaKey = `${session.guildId}:${session.userId}`;
332
- await session.send(`<at id="${session.userId}"/> 请在 60 秒内回复计算结果,以进行验证:${a} + ${b} =`);
351
+ await session.send(`<at id="${session.userId}"/> 请在 60 秒内回复计算结果,以进行验证:${a} ${op} ${b} =`);
333
352
  const timer = setTimeout(async () => {
334
353
  if (activeCaptchas.has(captchaKey)) {
335
354
  activeCaptchas.delete(captchaKey);
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.0",
4
+ "version": "1.1.2",
5
5
  "contributors": [
6
6
  "Yis_Rime <yis_rime@outlook.com>"
7
7
  ],