@zhin.js/plugin-content-moderation 1.1.7 → 1.1.9
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/README.md +43 -45
- package/package.json +7 -8
package/README.md
CHANGED
|
@@ -5,58 +5,56 @@
|
|
|
5
5
|
## 安装
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
|
|
8
|
+
pnpm exec zhin install @zhin.js/plugin-content-moderation
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
## 配置
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
在应用目录运行安装命令,会安装依赖并挂载到 `package.json#zhin.plugins`,实例名为 `content-moderation`。在 `zhin.config.yml` 的实例节点修改配置:
|
|
14
14
|
|
|
15
15
|
```yaml
|
|
16
16
|
plugins:
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
content-moderation:
|
|
20
|
-
enabled: true
|
|
21
|
-
onError: open # 源失败默认:open | closed
|
|
22
|
-
maskChar: "*"
|
|
23
|
-
replyTemplate: "消息含不当内容,已拦截。"
|
|
24
|
-
masters: [] # 额外 master userId(兜底)
|
|
25
|
-
inbound:
|
|
17
|
+
content-moderation:
|
|
26
18
|
enabled: true
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
high: drop
|
|
39
|
-
critical: [drop, recall]
|
|
40
|
-
sources:
|
|
41
|
-
- id: local
|
|
42
|
-
type: local
|
|
19
|
+
onError: open # 源失败默认:open | closed
|
|
20
|
+
maskChar: "*"
|
|
21
|
+
replyTemplate: "消息含不当内容,已拦截。"
|
|
22
|
+
masters: [] # 额外 master userId(兜底)
|
|
23
|
+
inbound:
|
|
24
|
+
enabled: true
|
|
25
|
+
bypassMasters: true
|
|
26
|
+
whitelist:
|
|
27
|
+
userIds: []
|
|
28
|
+
conversationIds: []
|
|
29
|
+
outbound:
|
|
43
30
|
enabled: true
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
31
|
+
bypass: false # true 才跳过出站审查
|
|
32
|
+
actions: # 可整表覆盖;缺省偏严
|
|
33
|
+
pass: allow
|
|
34
|
+
low: log
|
|
35
|
+
medium: redact
|
|
36
|
+
high: drop
|
|
37
|
+
critical: [drop, recall]
|
|
38
|
+
sources:
|
|
39
|
+
- id: local
|
|
40
|
+
type: local
|
|
41
|
+
enabled: true
|
|
42
|
+
includeBuiltin: true # 默认 true:合并内置分级词库
|
|
43
|
+
defaultSeverity: high # 未标注分级的自定义词默认等级(兼容旧字段 severity)
|
|
44
|
+
words:
|
|
45
|
+
- 自定义敏感词 # → defaultSeverity
|
|
46
|
+
- word: 擦边广告
|
|
47
|
+
severity: low
|
|
48
|
+
- word: 诈骗话术
|
|
49
|
+
severity: high
|
|
50
|
+
# wordFiles: ["./data/bad-words.txt"]
|
|
51
|
+
# 词库文件行:word / severity:word / word|severity
|
|
52
|
+
# - id: http-1
|
|
53
|
+
# type: http
|
|
54
|
+
# url: "https://example.com/moderate"
|
|
55
|
+
# onError: closed
|
|
56
|
+
# timeoutMs: 5000
|
|
57
|
+
# forceUpload: false
|
|
60
58
|
```
|
|
61
59
|
|
|
62
60
|
|
|
@@ -99,7 +97,7 @@ content-moderation:
|
|
|
99
97
|
| `critical` | `[drop, recall]` | 入站丢弃并尽量撤回;出站不发(`recall` 忽略) |
|
|
100
98
|
|
|
101
99
|
|
|
102
|
-
示例:入站 medium
|
|
100
|
+
示例:入站 medium 想「提示但仍放行」,在 `plugins.content-moderation.actions` 中修改:
|
|
103
101
|
|
|
104
102
|
```yaml
|
|
105
103
|
actions:
|
|
@@ -170,4 +168,4 @@ actions:
|
|
|
170
168
|
|
|
171
169
|
## 许可
|
|
172
170
|
|
|
173
|
-
MIT
|
|
171
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zhin.js/plugin-content-moderation",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.9",
|
|
4
4
|
"description": "Content moderation plugin for Zhin.js — inbound/outbound multi-source scanning (Plugin Runtime)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
10
|
"types": "./lib/index.d.ts",
|
|
11
|
-
"development": "./src/index.ts",
|
|
12
11
|
"import": "./lib/index.js"
|
|
13
12
|
},
|
|
14
13
|
"./package.json": "./package.json"
|
|
@@ -38,13 +37,13 @@
|
|
|
38
37
|
},
|
|
39
38
|
"license": "MIT",
|
|
40
39
|
"dependencies": {
|
|
41
|
-
"@zhin.js/core": "1.1.
|
|
42
|
-
"@zhin.js/logger": "1.1.
|
|
40
|
+
"@zhin.js/core": "1.1.44",
|
|
41
|
+
"@zhin.js/logger": "1.1.2"
|
|
43
42
|
},
|
|
44
43
|
"devDependencies": {
|
|
45
44
|
"typescript": "^6.0.3",
|
|
46
45
|
"vitest": "^4.1.10",
|
|
47
|
-
"zhin.js": "1.1.
|
|
46
|
+
"zhin.js": "1.1.9"
|
|
48
47
|
},
|
|
49
48
|
"repository": {
|
|
50
49
|
"type": "git",
|
|
@@ -56,7 +55,7 @@
|
|
|
56
55
|
"registry": "https://registry.npmjs.org"
|
|
57
56
|
},
|
|
58
57
|
"engines": {
|
|
59
|
-
"node": "
|
|
58
|
+
"node": ">=22.19.0"
|
|
60
59
|
},
|
|
61
60
|
"zhin": {
|
|
62
61
|
"protocol": 1,
|
|
@@ -73,8 +72,8 @@
|
|
|
73
72
|
"plugins": []
|
|
74
73
|
},
|
|
75
74
|
"peerDependencies": {
|
|
76
|
-
"@zhin.js/middleware": "^1.1.
|
|
77
|
-
"zhin.js": "^1.1.
|
|
75
|
+
"@zhin.js/middleware": "^1.1.6",
|
|
76
|
+
"zhin.js": "^1.1.9"
|
|
78
77
|
},
|
|
79
78
|
"peerDependenciesMeta": {
|
|
80
79
|
"@zhin.js/middleware": {
|