koishi-plugin-onebot-verifier 1.1.6 → 1.1.8
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 +0 -1
- package/lib/index.js +22 -15
- package/package.json +2 -2
- package/readme.md +42 -45
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -51,7 +51,7 @@ var Config = import_koishi.Schema.intersect([
|
|
|
51
51
|
import_koishi.Schema.object({
|
|
52
52
|
friendTimeout: import_koishi.Schema.union([
|
|
53
53
|
import_koishi.Schema.const(false).description("手动"),
|
|
54
|
-
import_koishi.Schema.number().description("
|
|
54
|
+
import_koishi.Schema.number().description("自动").default(360)
|
|
55
55
|
]).description("超时处理").default(false),
|
|
56
56
|
friendLevel: import_koishi.Schema.number().description("最低好友等级").default(0).min(0).max(256),
|
|
57
57
|
friendRegex: import_koishi.Schema.string().description("好友验证正则"),
|
|
@@ -61,7 +61,7 @@ var Config = import_koishi.Schema.intersect([
|
|
|
61
61
|
import_koishi.Schema.object({
|
|
62
62
|
memberTimeout: import_koishi.Schema.union([
|
|
63
63
|
import_koishi.Schema.const(false).description("手动"),
|
|
64
|
-
import_koishi.Schema.number().description("
|
|
64
|
+
import_koishi.Schema.number().description("自动").default(360)
|
|
65
65
|
]).description("超时处理").default(false),
|
|
66
66
|
verifyRules: import_koishi.Schema.array(import_koishi.Schema.object({
|
|
67
67
|
guildId: import_koishi.Schema.string().description("群号").required(),
|
|
@@ -71,25 +71,24 @@ var Config = import_koishi.Schema.intersect([
|
|
|
71
71
|
import_koishi.Schema.const("accept").description("同意"),
|
|
72
72
|
import_koishi.Schema.const("reject").description("拒绝")
|
|
73
73
|
]).description("操作")
|
|
74
|
-
})).description("
|
|
75
|
-
}).description("加群请求配置"),
|
|
76
|
-
import_koishi.Schema.object({
|
|
74
|
+
})).description("普通验证").role("table"),
|
|
77
75
|
specialRules: import_koishi.Schema.array(import_koishi.Schema.object({
|
|
78
76
|
guildId: import_koishi.Schema.string().description("群号").required(),
|
|
79
77
|
mode: import_koishi.Schema.union([
|
|
80
78
|
import_koishi.Schema.const("vote").description("投票"),
|
|
81
79
|
import_koishi.Schema.const("captcha").description("验证码")
|
|
82
|
-
]).description("模式").default("vote")
|
|
83
|
-
|
|
84
|
-
|
|
80
|
+
]).description("模式").default("vote")
|
|
81
|
+
})).description("高级验证").role("table")
|
|
82
|
+
}).description("加群请求配置"),
|
|
83
|
+
import_koishi.Schema.object({
|
|
84
|
+
voteInSitu: import_koishi.Schema.boolean().description("[投票]原群投票模式").default(true),
|
|
85
85
|
voteRatio: import_koishi.Schema.string().description("[投票]支持/反对人数").default("3:2"),
|
|
86
|
-
voteInSitu: import_koishi.Schema.boolean().description("[投票]对应群中发起").default(true),
|
|
87
86
|
captchaDiff: import_koishi.Schema.union([
|
|
88
87
|
import_koishi.Schema.const("simple").description("简单"),
|
|
89
88
|
import_koishi.Schema.const("medium").description("中等"),
|
|
90
89
|
import_koishi.Schema.const("hard").description("困难")
|
|
91
|
-
]).description("[验证]
|
|
92
|
-
}).description("
|
|
90
|
+
]).description("[验证]计算难度").default("simple")
|
|
91
|
+
}).description("模式配置")
|
|
93
92
|
]);
|
|
94
93
|
function apply(ctx, config) {
|
|
95
94
|
const logger = new import_koishi.Logger("onebot-verifier");
|
|
@@ -212,7 +211,7 @@ function apply(ctx, config) {
|
|
|
212
211
|
}
|
|
213
212
|
}
|
|
214
213
|
}
|
|
215
|
-
const specialRule = config.specialRules?.find((r) => String(r.guildId) === String(session.guildId)
|
|
214
|
+
const specialRule = config.specialRules?.find((r) => String(r.guildId) === String(session.guildId));
|
|
216
215
|
if (specialRule) {
|
|
217
216
|
if (specialRule.mode === "vote") return await setupManual(session, kind, "vote", config.voteInSitu);
|
|
218
217
|
if (specialRule.mode === "captcha") {
|
|
@@ -305,7 +304,7 @@ function apply(ctx, config) {
|
|
|
305
304
|
ctx.on("guild-added", hookEvent("guild"));
|
|
306
305
|
ctx.on("guild-member-added", async (session) => {
|
|
307
306
|
if (!config.specialRules || !session.guildId || !session.userId) return;
|
|
308
|
-
const rule = config.specialRules.find((r) => String(r.guildId) === String(session.guildId)
|
|
307
|
+
const rule = config.specialRules.find((r) => String(r.guildId) === String(session.guildId));
|
|
309
308
|
if (rule?.mode === "captcha") {
|
|
310
309
|
let a, b, op = "+", answer;
|
|
311
310
|
if (config.captchaDiff === "simple") {
|
|
@@ -344,13 +343,21 @@ function apply(ctx, config) {
|
|
|
344
343
|
});
|
|
345
344
|
ctx.on("guild-removed", async (session) => {
|
|
346
345
|
if (session.guildId) {
|
|
347
|
-
if (session.event?._data
|
|
346
|
+
if (config.debugMode) logger.info(`[事件] 退出: ${session.guildId} 数据: ${JSON.stringify(session.event?._data)}`);
|
|
347
|
+
const eventData = session.event?._data || {};
|
|
348
|
+
if (eventData.sub_type === "kick_me") {
|
|
348
349
|
const inviterId = inviterMap.get(session.guildId);
|
|
349
350
|
if (inviterId) {
|
|
350
351
|
await session.onebot?.deleteFriend(inviterId).catch(() => {
|
|
351
352
|
});
|
|
352
353
|
inviterMap.delete(session.guildId);
|
|
353
|
-
if (config.debugMode) logger.info(`[操作]
|
|
354
|
+
if (config.debugMode) logger.info(`[操作] 删除邀请者好友: ${inviterId}`);
|
|
355
|
+
}
|
|
356
|
+
const adminId = String(eventData.operator_id || session.event?.operator?.id || "");
|
|
357
|
+
if (adminId && adminId !== inviterId) {
|
|
358
|
+
await session.onebot?.deleteFriend(adminId).catch(() => {
|
|
359
|
+
});
|
|
360
|
+
if (config.debugMode) logger.info(`[操作] 删除管理员好友: ${adminId}`);
|
|
354
361
|
}
|
|
355
362
|
}
|
|
356
363
|
await session.execute(`analyse.clear -g ${session.guildId}`).catch(() => {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koishi-plugin-onebot-verifier",
|
|
3
|
-
"description": "适用于
|
|
4
|
-
"version": "1.1.
|
|
3
|
+
"description": "适用于 OneBot 的审核插件。不仅支持好友/加群自动审核,还支持入群验证码、投票表决、被踢自动清理等功能。",
|
|
4
|
+
"version": "1.1.8",
|
|
5
5
|
"contributors": [
|
|
6
6
|
"Yis_Rime <yis_rime@outlook.com>"
|
|
7
7
|
],
|
package/readme.md
CHANGED
|
@@ -2,66 +2,63 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/koishi-plugin-onebot-verifier)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
适用于 OneBot 的审核插件。不仅支持好友/加群自动审核,还支持**入群验证码**、**投票表决**、**被踢自动清理**等功能。
|
|
6
6
|
|
|
7
|
-
## ✨
|
|
7
|
+
## ✨ 核心特性
|
|
8
8
|
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
- `manual`(手动模式):全人工介入。
|
|
18
|
-
- **交互式人工审核**:通过引用通知消息并回复 `y/n` 即可快速通过或拒绝申请。
|
|
19
|
-
- **超时自动处理**:防止人工审核积压,支持超时后自动通过或拒绝。
|
|
9
|
+
- 🛡️ **全场景覆盖**:好友申请、用户加群、机器人受邀进群、被踢后续处理。
|
|
10
|
+
- 🧩 **多种验证模式**:
|
|
11
|
+
- **自动规则**:基于 QQ 等级、正则关键词、群规模(成员数/容量)的秒级自动化处理。
|
|
12
|
+
- **入群验证码**:新成员进群后触发数学运算挑战,失败自动移出。
|
|
13
|
+
- **民主投票**:将加群申请转为群内投票,达到指定票数自动通过/拒绝。
|
|
14
|
+
- 交互式人工干预:引用通知消息回复 `y/n` 即可操作,支持超时自动决策。
|
|
15
|
+
- 🧹 **智能清理**:机器人被恶意踢出时,可自动删除邀请者或操作者的好友,并清理数据统计。
|
|
16
|
+
- 📍 **就地审核**:支持在发生申请的群内直接发起审核,无需跳转管理群。
|
|
20
17
|
|
|
21
|
-
## ⚙️
|
|
18
|
+
## ⚙️ 配置项深度解析
|
|
22
19
|
|
|
23
20
|
### 1. 基础配置
|
|
24
21
|
|
|
25
|
-
- **通知目标 (`notifyTarget`)**:
|
|
26
|
-
-
|
|
27
|
-
- **调试模式 (`debugMode`)**: 开启后将输出更详细的日志。
|
|
22
|
+
- **通知目标 (`notifyTarget`)**: 必填。格式为 `private:QQ号` 或 `guild:群号`。
|
|
23
|
+
- **被踢自动处理 (`kickBan`)**: 开启后,若机器人被移出群组,将自动尝试删除邀请者和操作者的好友。
|
|
28
24
|
|
|
29
|
-
### 2.
|
|
25
|
+
### 2. 好友与邀群 (机器人被邀)
|
|
30
26
|
|
|
31
|
-
-
|
|
32
|
-
-
|
|
33
|
-
-
|
|
34
|
-
-
|
|
35
|
-
-
|
|
36
|
-
- **最低受邀容量 (`maxCapacity`)**: 机器人被邀请进群时,该群的群上限人数要求。
|
|
27
|
+
- **超时处理 (`friendTimeout`)**: 数字表示分钟。正数表示超时自动同意,负数表示超时自动拒绝,`false` 表示永久等待。
|
|
28
|
+
- **验证维度**:
|
|
29
|
+
- `friendLevel`: 申请人最低 QQ 等级。
|
|
30
|
+
- `friendRegex`: 匹配好友申请说明。
|
|
31
|
+
- `minMembers` / `maxCapacity`: 校验目标群的活跃程度与规模。
|
|
37
32
|
|
|
38
|
-
### 3.
|
|
33
|
+
### 3. 加群请求 (用户入群)
|
|
39
34
|
|
|
40
|
-
-
|
|
41
|
-
|
|
42
|
-
-
|
|
43
|
-
-
|
|
44
|
-
- **加群验证配置 (`verifyRules`)**:
|
|
45
|
-
- 为特定群设置专属的验证正则、最低等级要求及超时处理动作。
|
|
35
|
+
- **普通验证规则 (`verifyRules`)**: 表格化配置。可针对不同群设置不同的关键词正则和等级要求。
|
|
36
|
+
- **特殊验证模式 (`specialRules`)**:
|
|
37
|
+
- **投票模式 (vote)**: 引用通知回复 `y/n` 累计票数。
|
|
38
|
+
- **验证码模式 (captcha)**: 机器人自动先通过申请,用户进群后需在 60s 内回复计算题。
|
|
46
39
|
|
|
47
|
-
|
|
40
|
+
### 4. 进阶安全
|
|
48
41
|
|
|
49
|
-
|
|
42
|
+
- **投票比例 (`voteRatio`)**: 格式如 `3:2`,表示 3 票赞成则通过,2 票反对则拒绝。
|
|
43
|
+
- **就地投票 (`voteInSitu`)**: 开启后,投票通知将直接发往“该申请所属的群”而非全局通知目标。
|
|
44
|
+
- **验证码难度 (`captchaDiff`)**: 简单(100以内加减)、中等(两位数乘一位数)、困难(两位数乘两位数)。
|
|
50
45
|
|
|
51
|
-
|
|
46
|
+
## 🎮 指令交互指南
|
|
52
47
|
|
|
53
|
-
|
|
54
|
-
- *提示:若是好友申请,后面可跟备注(如:`y 朋友`)。*
|
|
55
|
-
- **拒绝申请**:回复 `n` 或 `拒绝`。
|
|
56
|
-
- *提示:后面可以跟拒绝理由(如:`n 等级太低`)。*
|
|
48
|
+
### 人工审核 / 投票
|
|
57
49
|
|
|
58
|
-
|
|
50
|
+
当收到审核通知时,**引用该消息**并回复:
|
|
59
51
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
52
|
+
- **通过**:回复 `y` 或 `通过`。
|
|
53
|
+
- **拒绝**:回复 `n` 或 `拒绝 [理由]`。
|
|
54
|
+
- **备注**:好友申请通过时,`y 备注名` 可直接修改好友备注。
|
|
63
55
|
|
|
64
|
-
|
|
56
|
+
### 自动清理逻辑
|
|
65
57
|
|
|
66
|
-
|
|
67
|
-
|
|
58
|
+
1. **数据清理**:当机器人退出或被踢出群组时,插件会自动执行 `analyse.clear`清理相关统计。
|
|
59
|
+
2. **反制措施**:若开启 `kickBan`,被踢后会自动切断与相关管理员的好友关系。
|
|
60
|
+
|
|
61
|
+
## ⚠️ 注意事项
|
|
62
|
+
|
|
63
|
+
- 使用验证码模式时,请确保机器人拥有**管理员权限**,否则无法在验证失败时踢出成员。
|
|
64
|
+
- `notifyTarget` 必须符合 `platform:id` 格式,且机器人必须与该目标存在好友或群成员关系。
|