@zhin.js/plugin-content-moderation 1.1.10 → 1.1.13

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