koishi-plugin-group-verification 1.0.31 → 1.0.32
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.js +12 -2
- package/package.json +50 -51
- package/src/index.ts +15 -2
package/lib/index.js
CHANGED
|
@@ -348,7 +348,7 @@ async function checkPermission(session, targetGroupId) {
|
|
|
348
348
|
});
|
|
349
349
|
}
|
|
350
350
|
if (koishiAuthority && koishiAuthority >= 3) {
|
|
351
|
-
logger.
|
|
351
|
+
logger.debug(`权限检查 - 通过koishi权限检查: ${koishiAuthority}`);
|
|
352
352
|
return [true];
|
|
353
353
|
}
|
|
354
354
|
try {
|
|
@@ -661,7 +661,9 @@ async function processBlacklistCommand(ctx, session, rawArgs, config) {
|
|
|
661
661
|
targetUser = parts[1];
|
|
662
662
|
if (!targetUser) return "请提供用户ID";
|
|
663
663
|
const rest = parts.slice(2);
|
|
664
|
-
if (rest.length
|
|
664
|
+
if (rest.length === 1) {
|
|
665
|
+
reason = rest[0];
|
|
666
|
+
} else if (rest.length > 1) {
|
|
665
667
|
const last = rest[rest.length - 1];
|
|
666
668
|
if (/^\d+$/.test(last) || last.toLowerCase() === "all") {
|
|
667
669
|
group = last;
|
|
@@ -700,6 +702,14 @@ async function processBlacklistCommand(ctx, session, rawArgs, config) {
|
|
|
700
702
|
entries[targetUser] = storedReason;
|
|
701
703
|
await ctx.database.create("group_verification_blacklist", { groupId: group, entries });
|
|
702
704
|
}
|
|
705
|
+
if (session.bot && typeof session.bot.kickGuildMember === "function") {
|
|
706
|
+
try {
|
|
707
|
+
await session.bot.kickGuildMember(group, targetUser);
|
|
708
|
+
logger.info(`已将黑名单用户 ${targetUser} 从群 ${group} 踢出`);
|
|
709
|
+
} catch (e) {
|
|
710
|
+
logger.warn(`踢出用户 ${targetUser} 失败`, e);
|
|
711
|
+
}
|
|
712
|
+
}
|
|
703
713
|
const tmpl = config && config.blacklistAddSuccess || "已将用户 {user} 加入群 {group} 黑名单{reason}";
|
|
704
714
|
return tmpl.replace("{user}", targetUser).replace("{group}", group).replace("{reason}", reason ? `,原因:${reason}` : "");
|
|
705
715
|
}
|
package/package.json
CHANGED
|
@@ -1,51 +1,50 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "koishi-plugin-group-verification",
|
|
3
|
-
"description": "Koishi 群组加群验证插件,支持多关键词匹配审核、多种审核方式和详细统计功能",
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
"
|
|
28
|
-
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
"
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "koishi-plugin-group-verification",
|
|
3
|
+
"description": "Koishi 群组加群验证插件,支持多关键词匹配审核、多种审核方式和详细统计功能",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "https://github.com/LHDyx/koishi-plugin-group-verification.git"
|
|
7
|
+
},
|
|
8
|
+
"bugs": {
|
|
9
|
+
"url": "https://github.com/LHDyx/koishi-plugin-group-verification/issues"
|
|
10
|
+
},
|
|
11
|
+
"version": "1.0.32",
|
|
12
|
+
"main": "lib/index.js",
|
|
13
|
+
"typings": "lib/index.d.ts",
|
|
14
|
+
"files": [
|
|
15
|
+
"lib",
|
|
16
|
+
"dist",
|
|
17
|
+
"src",
|
|
18
|
+
"README.md",
|
|
19
|
+
"USAGE_EXAMPLE.md"
|
|
20
|
+
],
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "tsc",
|
|
23
|
+
"dev": "tsc -w",
|
|
24
|
+
"test": "ts-node test/basic-test.ts"
|
|
25
|
+
},
|
|
26
|
+
"license": "MIT",
|
|
27
|
+
"keywords": [
|
|
28
|
+
"chatbot",
|
|
29
|
+
"koishi",
|
|
30
|
+
"plugin",
|
|
31
|
+
"group-verification",
|
|
32
|
+
"guild-management",
|
|
33
|
+
"join-request",
|
|
34
|
+
"moderation"
|
|
35
|
+
],
|
|
36
|
+
"koishi": {
|
|
37
|
+
"service": {
|
|
38
|
+
"required": [
|
|
39
|
+
"database"
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"peerDependencies": {
|
|
44
|
+
"koishi": "^4.15.0"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"typescript": "^4.9.0",
|
|
48
|
+
"@types/node": "^16.0.0"
|
|
49
|
+
}
|
|
50
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -498,7 +498,7 @@ export async function checkPermission(session: any, targetGroupId?: string): Pro
|
|
|
498
498
|
}
|
|
499
499
|
|
|
500
500
|
if (koishiAuthority && koishiAuthority >= 3) {
|
|
501
|
-
logger.
|
|
501
|
+
logger.debug(`权限检查 - 通过koishi权限检查: ${koishiAuthority}`)
|
|
502
502
|
return [true]
|
|
503
503
|
}
|
|
504
504
|
|
|
@@ -886,13 +886,17 @@ export async function processBlacklistCommand(ctx: Context, session: any, rawArg
|
|
|
886
886
|
targetUser = parts[1]
|
|
887
887
|
if (!targetUser) return '请提供用户ID'
|
|
888
888
|
// handle optional reason and group at end
|
|
889
|
+
// 规则:如果只有一个附加参数,则作为 reason;两个及以上时最后一个为群号,其余拼成 reason
|
|
889
890
|
const rest = parts.slice(2)
|
|
890
|
-
if (rest.length
|
|
891
|
+
if (rest.length === 1) {
|
|
892
|
+
reason = rest[0]
|
|
893
|
+
} else if (rest.length > 1) {
|
|
891
894
|
const last = rest[rest.length - 1]
|
|
892
895
|
if (/^\d+$/.test(last) || last.toLowerCase() === 'all') {
|
|
893
896
|
group = last
|
|
894
897
|
reason = rest.slice(0, -1).join(' ')
|
|
895
898
|
} else {
|
|
899
|
+
// 虽然数量>=2,但最后一个不是数字,全部作为reason
|
|
896
900
|
reason = rest.join(' ')
|
|
897
901
|
}
|
|
898
902
|
}
|
|
@@ -930,6 +934,15 @@ export async function processBlacklistCommand(ctx: Context, session: any, rawArg
|
|
|
930
934
|
entries[targetUser] = storedReason
|
|
931
935
|
await ctx.database.create('group_verification_blacklist', { groupId: group, entries })
|
|
932
936
|
}
|
|
937
|
+
// 添加成功后尝试踢人
|
|
938
|
+
if (session.bot && typeof session.bot.kickGuildMember === 'function') {
|
|
939
|
+
try {
|
|
940
|
+
await session.bot.kickGuildMember(group, targetUser)
|
|
941
|
+
logger.info(`已将黑名单用户 ${targetUser} 从群 ${group} 踢出`)
|
|
942
|
+
} catch (e) {
|
|
943
|
+
logger.warn(`踢出用户 ${targetUser} 失败`, e)
|
|
944
|
+
}
|
|
945
|
+
}
|
|
933
946
|
const tmpl = (config && config.blacklistAddSuccess) || '已将用户 {user} 加入群 {group} 黑名单{reason}'
|
|
934
947
|
return tmpl.replace('{user}', targetUser).replace('{group}', group).replace('{reason}', reason ? `,原因:${reason}` : '')
|
|
935
948
|
}
|