koishi-plugin-ban-qrcode 1.1.3 → 1.2.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/ad-keywords.txt +24 -0
- package/lib/ad.d.ts +5 -0
- package/lib/ad.js +24 -21
- package/package.json +2 -2
- package/readme.md +11 -8
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# 一行一个关键词。空行和 # 注释会被忽略。
|
|
2
|
+
# [strong] 命中任意一条即撤回
|
|
3
|
+
# [commerce] 需同时出现床品类用词,且至少命中两条
|
|
4
|
+
|
|
5
|
+
[strong]
|
|
6
|
+
校园麦芽
|
|
7
|
+
送货到寝
|
|
8
|
+
配送到寝
|
|
9
|
+
送寝
|
|
10
|
+
名额有限
|
|
11
|
+
营业执照
|
|
12
|
+
联系本校的负责人
|
|
13
|
+
联系本校负责人
|
|
14
|
+
整套四五百
|
|
15
|
+
|
|
16
|
+
[commerce]
|
|
17
|
+
提前预订
|
|
18
|
+
提前预定
|
|
19
|
+
买被子
|
|
20
|
+
购买链接
|
|
21
|
+
质保四年
|
|
22
|
+
厂家直销
|
|
23
|
+
真空包装
|
|
24
|
+
代发到寝
|
package/lib/ad.d.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
export interface AdHit {
|
|
2
2
|
matches: string[];
|
|
3
3
|
}
|
|
4
|
+
export interface AdKeywordLists {
|
|
5
|
+
strong: string[];
|
|
6
|
+
commerce: string[];
|
|
7
|
+
}
|
|
8
|
+
export declare function parseAdKeywords(source: string): AdKeywordLists;
|
|
4
9
|
export declare function detectAdContent(text: string, title?: string, extraKeywords?: readonly string[]): AdHit | null;
|
package/lib/ad.js
CHANGED
|
@@ -1,27 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseAdKeywords = parseAdKeywords;
|
|
3
4
|
exports.detectAdContent = detectAdContent;
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
'
|
|
10
|
-
'
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
5
|
+
const node_fs_1 = require("node:fs");
|
|
6
|
+
const node_path_1 = require("node:path");
|
|
7
|
+
const SECTION = /^\[(strong|commerce)\]$/i;
|
|
8
|
+
function parseAdKeywords(source) {
|
|
9
|
+
const lists = { strong: [], commerce: [] };
|
|
10
|
+
let section = 'strong';
|
|
11
|
+
for (const raw of source.replace(/^\uFEFF/, '').split(/\r?\n/)) {
|
|
12
|
+
const line = raw.trim();
|
|
13
|
+
if (!line || line.startsWith('#'))
|
|
14
|
+
continue;
|
|
15
|
+
const marker = line.match(SECTION);
|
|
16
|
+
if (marker) {
|
|
17
|
+
section = marker[1].toLowerCase();
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
lists[section].push(line);
|
|
21
|
+
}
|
|
22
|
+
return lists;
|
|
23
|
+
}
|
|
24
|
+
function loadAdKeywords() {
|
|
25
|
+
return parseAdKeywords((0, node_fs_1.readFileSync)((0, node_path_1.join)(__dirname, 'ad-keywords.txt'), 'utf8'));
|
|
26
|
+
}
|
|
27
|
+
const { strong: VERY_STRONG, commerce: COMMERCE } = loadAdKeywords();
|
|
25
28
|
const PRODUCT = /被子|床品|四件套|六件套|九件套|被芯|床垫/;
|
|
26
29
|
const SELL = /购买|预订|预定|下单|代购|团购|包邮|厂家|品牌|优惠|联系.{0,8}负责/;
|
|
27
30
|
const CONTACT = /微信|加v|加微|vx[::]|v信/i;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koishi-plugin-ban-qrcode",
|
|
3
3
|
"description": "检测到群内二维码、拉群卡片或文档广告后自动撤回并禁言",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.2.0",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
7
7
|
"files": [
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"access": "public"
|
|
22
22
|
},
|
|
23
23
|
"scripts": {
|
|
24
|
-
"build": "tsc -b",
|
|
24
|
+
"build": "tsc -b && node -e \"require('fs').copyFileSync('src/ad-keywords.txt', 'lib/ad-keywords.txt')\"",
|
|
25
25
|
"test": "tsx --test tests/*.spec.ts"
|
|
26
26
|
},
|
|
27
27
|
"keywords": [
|
package/readme.md
CHANGED
|
@@ -96,11 +96,13 @@ npm run build
|
|
|
96
96
|
| `adKeywords` | `string[]` | `[]` | 额外广告关键词,命中即撤回 |
|
|
97
97
|
| `debug` | `boolean` | `true` | 输出调试日志:跳过原因、消息结构、下载 / 扫码 / 文档结果 |
|
|
98
98
|
|
|
99
|
+
内置词在 `src/ad-keywords.txt`,一行一条。`[strong]` 命中任意一条即撤回;`[commerce]` 要同时出现床品类用词且至少两条。控制台 `adKeywords` 按强匹配叠加。
|
|
100
|
+
|
|
99
101
|
默认提示按原因变化,例如:`检测到拉群卡片,已撤回并禁言 60 秒。` / `检测到文档广告,已撤回并禁言 60 秒。`
|
|
100
102
|
|
|
101
103
|
## API Reference
|
|
102
104
|
|
|
103
|
-
插件入口导出 `name`、`inject`、`Config`、`apply`。判定与扫码编排在 `src/detect.ts`,拉群卡在 `src/share.ts`,文档广告在 `src/ad.ts` / `src/document.ts`,下载和解码在 `src/qrcode.ts
|
|
105
|
+
插件入口导出 `name`、`inject`、`Config`、`apply`。判定与扫码编排在 `src/detect.ts`,拉群卡在 `src/share.ts`,文档广告在 `src/ad.ts` / `src/ad-keywords.txt` / `src/document.ts`,下载和解码在 `src/qrcode.ts`。内置广告词在 `ad-keywords.txt` 里一行一条;控制台 `adKeywords` 仍是额外覆盖。
|
|
104
106
|
|
|
105
107
|
### `collectImageSrcs(nodes)`
|
|
106
108
|
|
|
@@ -122,12 +124,13 @@ npm run build
|
|
|
122
124
|
|
|
123
125
|
```
|
|
124
126
|
src/
|
|
125
|
-
├── index.ts
|
|
126
|
-
├── detect.ts
|
|
127
|
-
├── share.ts
|
|
128
|
-
├── ad.ts
|
|
129
|
-
├──
|
|
130
|
-
|
|
127
|
+
├── index.ts # 插件入口:监听群消息,撤回 / 禁言 / 提示
|
|
128
|
+
├── detect.ts # 收集图片 / 卡片 / 文件、是否处理、提示语
|
|
129
|
+
├── share.ts # 识别 QQ 拉群分享卡
|
|
130
|
+
├── ad.ts # 识别文档里的卖货文案
|
|
131
|
+
├── ad-keywords.txt # 内置广告关键词,一行一条
|
|
132
|
+
├── document.ts # 拉腾讯文档、抽出 Word / 文本
|
|
133
|
+
└── qrcode.ts # 下载图片、解码二维码
|
|
131
134
|
tests/
|
|
132
135
|
├── detect.spec.ts
|
|
133
136
|
├── share.spec.ts
|
|
@@ -275,7 +278,7 @@ Actions 会 `npm ci` → `npm test` → `npm run build` → `npm publish --acces
|
|
|
275
278
|
|
|
276
279
|
## Changelog
|
|
277
280
|
|
|
278
|
-
当前版本 **1.
|
|
281
|
+
当前版本 **1.2.0**:内置广告词改到 `ad-keywords.txt` 维护,控制台 `adKeywords` 仍作额外强匹配。1.1.3 补拦 QQ 群名片。1.1.2 修复 OneBot `getImage` 未绑定导致的生产崩溃。1.1.1 补齐跳过原因日志。1.1.0 起拦截拉群分享卡和腾讯文档 / Word 广告。
|
|
279
282
|
|
|
280
283
|
## License
|
|
281
284
|
|