@nestim/koishi-plugin-qq-group-manager 1.0.3 → 1.1.0

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
@@ -51,6 +51,7 @@ export interface Config {
51
51
  joinRequestReviewTtlMinutes: number;
52
52
  pendingJoinFileName: string;
53
53
  bannedWords: string[];
54
+ strongKeywords: string[];
54
55
  blockCardMessage: boolean;
55
56
  blockForwardMessage: boolean;
56
57
  autoDeleteViolation: boolean;
@@ -82,6 +83,7 @@ export interface GroupRule {
82
83
  guildId: string;
83
84
  enableAiReply?: boolean;
84
85
  bannedWords: string[];
86
+ strongKeywords?: string[];
85
87
  blockCardMessage: boolean;
86
88
  blockForwardMessage: boolean;
87
89
  autoDeleteViolation: boolean;
package/lib/index.js CHANGED
@@ -31,6 +31,7 @@ exports.Config = koishi_1.Schema.intersect([
31
31
  koishi_1.Schema.object({
32
32
  bannedWords: koishi_1.Schema.array(String).role('table').default([]).description('违禁词列表。支持顺序模糊匹配(如“领红包”可命中“领xxx元红包”)。可用“关键词|分值”自定义权重,分值越高越容易单独触发。'),
33
33
  bannedWordScoreThreshold: koishi_1.Schema.natural().min(1).max(100).default(70).description('违禁词评分触发阈值:整条消息累计得分达到该值才触发管控(默认 70)。'),
34
+ strongKeywords: koishi_1.Schema.array(String).role('table').default([]).description('强关键词列表:命中即可触发管控,且【无视白名单豁免】。用于「有没有美女」这类与招新无关的骚扰/找对象话术——即使消息里带了「宣传部」等白名单词也照样命中,堵住「附一个白名单词即可绕过管控」的漏洞。支持“关键词|分值”语法,与违禁词共用同一评分阈值。'),
34
35
  blockCardMessage: koishi_1.Schema.boolean().default(true).description('是否禁止卡片消息(json/xml)。'),
35
36
  blockForwardMessage: koishi_1.Schema.boolean().default(true).description('是否禁止合并转发消息(forward)。'),
36
37
  autoDeleteViolation: koishi_1.Schema.boolean().default(true).description('违规消息是否自动撤回。'),
@@ -40,6 +41,7 @@ exports.Config = koishi_1.Schema.intersect([
40
41
  enableAiReply: koishi_1.Schema.boolean().description('该群是否启用 AI 回复(留空则跟随全局设置)。'),
41
42
  bannedWords: koishi_1.Schema.array(String).role('table').default([]).description('该群专属违禁词列表(同样支持“关键词|分值”与顺序模糊匹配)。'),
42
43
  whitelistKeywords: koishi_1.Schema.array(String).role('table').default([]).description('该群违禁词白名单:消息只要命中其中任意一个关键词,就整条跳过违禁词评分(用于校学生会招新等允许的宣传场景)。'),
44
+ strongKeywords: koishi_1.Schema.array(String).role('table').description('该群强关键词(留空则跟随全局设置)。命中后无视白名单豁免,用于堵住「附一个白名单词即可绕过管控」的漏洞。'),
43
45
  whitelistOnlyOwners: koishi_1.Schema.boolean().default(false).description('白名单是否仅对群主/管理员生效。关闭时所有群成员命中白名单均可豁免。'),
44
46
  blockCardMessage: koishi_1.Schema.boolean().default(true).description('该群是否禁止卡片消息(json/xml)。'),
45
47
  blockForwardMessage: koishi_1.Schema.boolean().default(true).description('该群是否禁止合并转发消息(forward)。'),
package/lib/service.js CHANGED
@@ -2876,6 +2876,7 @@ class QQGroupManagerService extends koishi_1.Service {
2876
2876
  if (!rule) {
2877
2877
  return {
2878
2878
  bannedWords: this.config.bannedWords,
2879
+ strongKeywords: this.config.strongKeywords ?? [],
2879
2880
  whitelistKeywords: [],
2880
2881
  whitelistOnlyOwners: false,
2881
2882
  blockCardMessage: this.config.blockCardMessage,
@@ -2892,6 +2893,9 @@ class QQGroupManagerService extends koishi_1.Service {
2892
2893
  }
2893
2894
  return {
2894
2895
  bannedWords: rule.bannedWords,
2896
+ strongKeywords: (Array.isArray(rule.strongKeywords) && rule.strongKeywords.length)
2897
+ ? rule.strongKeywords
2898
+ : (this.config.strongKeywords ?? []),
2895
2899
  whitelistKeywords: rule.whitelistKeywords || [],
2896
2900
  whitelistOnlyOwners: rule.whitelistOnlyOwners === true,
2897
2901
  blockCardMessage: rule.blockCardMessage,
@@ -3106,6 +3110,23 @@ class QQGroupManagerService extends koishi_1.Service {
3106
3110
  const text = this.extractTextForFilter(session);
3107
3111
  if (!text)
3108
3112
  return null;
3113
+ const threshold = Math.max(1, Math.min(100, Number(this.config.bannedWordScoreThreshold ?? 70)));
3114
+ // 强关键词:在【白名单豁免之前】判定。命中即可触发管控,白名单不豁免。
3115
+ // 用于「有没有美女」这类与招新无关的骚扰/找对象话术——即使消息里带了
3116
+ // 「宣传部」等白名单词也照样命中,堵住「附一个白名单词即可绕过管控」的漏洞。
3117
+ const strong = this.evaluateBannedWords(text, { bannedWords: policy?.strongKeywords ?? [] });
3118
+ if (strong.total >= threshold) {
3119
+ const strongTop = strong.evaluations.slice(0, 4)
3120
+ .map((item) => `${item.keyword}(+${item.gained}${item.exact ? '' : `/${item.confidence}`})`)
3121
+ .join(' ');
3122
+ this._logger.info(`[strong] 强关键词评分 ${strong.total}/${threshold}(无视白名单):${strongTop} | ${this.sessionTag(session)}`);
3123
+ return {
3124
+ type: 'banned-word',
3125
+ detail: `强关键词评分 ${strong.total}/${threshold}(无视白名单):${strongTop}`,
3126
+ assessment: strong,
3127
+ strong: true,
3128
+ };
3129
+ }
3109
3130
  // 白名单豁免:命中白名单关键词则跳过违禁词评分(招新等允许的宣传场景)。
3110
3131
  // 注意:卡片/合并转发的拦截在上面已判定,白名单只豁免「违禁词」,不放过卡片类消息。
3111
3132
  const bypass = await this.checkWhitelistBypass(session, policy, text);
@@ -3114,7 +3135,6 @@ class QQGroupManagerService extends koishi_1.Service {
3114
3135
  return null;
3115
3136
  }
3116
3137
  const assessment = this.evaluateBannedWords(text, policy);
3117
- const threshold = Math.max(1, Math.min(100, Number(this.config.bannedWordScoreThreshold ?? 70)));
3118
3138
  if (assessment.total >= threshold) {
3119
3139
  const top = assessment.evaluations.slice(0, 4)
3120
3140
  .map((item) => `${item.keyword}(+${item.gained}${item.exact ? '' : `/${item.confidence}`})`)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nestim/koishi-plugin-qq-group-manager",
3
3
  "description": "Koishi QQ群管理插件(OneBot/LLOneBot):群管命令、权限校验、图片菜单、状态卡片、复读、AI群聊回复、记忆库、识图与自动管控(禁言/踢人)。",
4
- "version": "1.0.3",
4
+ "version": "1.1.0",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [
package/readme.md CHANGED
@@ -23,7 +23,8 @@ Koishi 控制台「探索器 Explorer」里查看和手改。
23
23
  | **群管动作** | 禁言 / 解除禁言 / 踢人(可拒绝其再次加群);时长支持 `10`、`10m`、`1h`、`1d`、`1w`,上限 30 天 |
24
24
  | **权限校验** | 账号白名单 + 群主 / 群管理员;可要求 bot 为群主才放行管理动作 |
25
25
  | **消息管控** | 违禁词**整条消息评分制**(顺序模糊匹配 + 置信度衰减 + 可配权重),卡片消息、合并转发拦截,可自动撤回并群内提示 |
26
- | **按群覆盖** | `groupRules` 可为每个群单独设定违禁词、白名单关键词与各类开关,未配置则跟随全局 |
26
+ | **强关键词** | `strongKeywords`:命中即可触发管控,且**无视白名单豁免**,堵住「附一个白名单词即可绕过管控」的口子;判定顺序为 强关键词 → 白名单 → 普通违禁词 |
27
+ | **按群覆盖** | `groupRules` 可为每个群单独设定违禁词、强关键词、白名单关键词与各类开关,未配置则跟随全局 |
27
28
  | **自动处罚** | 统计窗口内累计违规达到阈值后自动禁言 / 自动踢人,阈值、时长、窗口均可配 |
28
29
  | **黑名单** | 按群独立存储(`banMember_<群号>.md`);入群自动比对并踢出,可选踢人时自动记录 |
29
30
  | **入群审核** | 新申请推送到群内,管理员用 `approve` / `reject` 放行或拒绝;待审单落盘,**重启不丢** |
@@ -87,8 +88,9 @@ npm i @nestim/koishi-plugin-qq-group-manager
87
88
  | `command` | `[bot]` | 菜单入口前缀 |
88
89
  | `allowedUserIds` | `[]` | 可直接使用管理指令的账号白名单 |
89
90
  | `bannedWords` | `[]` | 违禁词;支持 `关键词\|分值` 自定义权重 |
90
- | `bannedWordScoreThreshold` | `70` | 违禁词评分触发阈值 |
91
- | `groupRules` | `[]` | 按群覆盖策略(违禁词、白名单关键词、AI 开关、自动处罚阈值等) |
91
+ | `bannedWordScoreThreshold` | `70` | 违禁词评分触发阈值(强关键词共用) |
92
+ | `strongKeywords` | `[]` | 强关键词;命中即触发且**无视白名单豁免**,支持 `关键词\|分值` |
93
+ | `groupRules` | `[]` | 按群覆盖策略(违禁词、强关键词、白名单关键词、AI 开关、自动处罚阈值等) |
92
94
  | `memoryFileName` | `Memory.md` | 记忆库文件名(存放在 Koishi 数据目录) |
93
95
  | `blacklistFileName` | `banMember.md` | 黑名单文件名模板,实际为 `banMember_<群号>.md` |
94
96
  | `pendingJoinFileName` | `JoinRequests.md` | 待审入群申请落盘文件名 |
@@ -125,10 +127,6 @@ npm i @nestim/koishi-plugin-qq-group-manager
125
127
 
126
128
  鉴权细节与指令执行结果只写日志,不回显到群聊。
127
129
 
128
- ## 更新日志
129
-
130
- 见 [CHANGELOG.md](./CHANGELOG.md)。
131
-
132
130
  ## License
133
131
 
134
132
  MIT