koishi-plugin-onebot-verifier 1.1.0 → 1.1.1

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 = {}) {
@@ -325,11 +330,31 @@ function apply(ctx, config = {}) {
325
330
  if (!config.specialRules || !session.guildId || !session.userId) return;
326
331
  const rule = config.specialRules.find((r) => String(r.guildId) === String(session.guildId) && r.enabled);
327
332
  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();
333
+ let a, b, op = "+", answer;
334
+ if (config.captchaDiff === "simple") {
335
+ a = Math.floor(Math.random() * 80) + 10;
336
+ b = Math.floor(Math.random() * 80) + 10;
337
+ if (Math.random() > 0.5) {
338
+ op = "+";
339
+ answer = (a + b).toString();
340
+ } else {
341
+ op = "-";
342
+ if (a < b) [a, b] = [b, a];
343
+ answer = (a - b).toString();
344
+ }
345
+ } else if (config.captchaDiff === "medium") {
346
+ a = Math.floor(Math.random() * 89) + 11;
347
+ b = Math.floor(Math.random() * 8) + 2;
348
+ op = "×";
349
+ answer = (a * b).toString();
350
+ } else {
351
+ a = Math.floor(Math.random() * 40) + 11;
352
+ b = Math.floor(Math.random() * 10) + 11;
353
+ op = "×";
354
+ answer = (a * b).toString();
355
+ }
331
356
  const captchaKey = `${session.guildId}:${session.userId}`;
332
- await session.send(`<at id="${session.userId}"/> 请在 60 秒内回复计算结果,以进行验证:${a} + ${b} =`);
357
+ await session.send(`<at id="${session.userId}"/> 请在 60 秒内回复计算结果,以进行验证:${a} ${op} ${b} =`);
333
358
  const timer = setTimeout(async () => {
334
359
  if (activeCaptchas.has(captchaKey)) {
335
360
  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.1",
5
5
  "contributors": [
6
6
  "Yis_Rime <yis_rime@outlook.com>"
7
7
  ],