koishi-plugin-group-control 1.0.0-alpha.7 → 1.0.1
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/LICENSE +21 -21
- package/lib/config.d.ts +3 -0
- package/lib/database.d.ts +80 -80
- package/lib/index.d.ts +5 -5
- package/lib/index.js +31 -21
- package/lib/modules/basic.d.ts +4 -4
- package/lib/modules/commands.d.ts +4 -4
- package/lib/modules/frequency.d.ts +4 -4
- package/lib/modules/friend.d.ts +4 -4
- package/lib/modules/invite.d.ts +4 -4
- package/lib/modules/switch.d.ts +4 -4
- package/lib/state.d.ts +6 -6
- package/lib/utils.d.ts +17 -17
- package/package.json +1 -4
- package/readme.md +199 -199
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 muyni
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 muyni
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/lib/config.d.ts
CHANGED
|
@@ -26,6 +26,9 @@ export interface GroupInviteConfig {
|
|
|
26
26
|
inviteWaitMessage: string;
|
|
27
27
|
inviteRequestMessage: string;
|
|
28
28
|
autoApprove: boolean;
|
|
29
|
+
notifyAdminOnApprove: boolean;
|
|
30
|
+
inviteApproveMessage: string;
|
|
31
|
+
inviteApproveNotificationMessage: string;
|
|
29
32
|
showDetailedLog: boolean;
|
|
30
33
|
inviteExpireDays: number;
|
|
31
34
|
}
|
package/lib/database.d.ts
CHANGED
|
@@ -1,80 +1,80 @@
|
|
|
1
|
-
import { Context } from 'koishi';
|
|
2
|
-
export interface BlacklistedGuild {
|
|
3
|
-
platform: string;
|
|
4
|
-
guildId: string;
|
|
5
|
-
timestamp: number;
|
|
6
|
-
reason: string;
|
|
7
|
-
}
|
|
8
|
-
export interface CommandFrequencyRecord {
|
|
9
|
-
platform: string;
|
|
10
|
-
guildId: string;
|
|
11
|
-
commandCount: number;
|
|
12
|
-
lastCommandTime: number;
|
|
13
|
-
warningSent: boolean;
|
|
14
|
-
blockExpiryTime: number;
|
|
15
|
-
firstWarningTime: number;
|
|
16
|
-
blockCount: number;
|
|
17
|
-
lastBlockNotifyTime: number;
|
|
18
|
-
}
|
|
19
|
-
export interface GroupBotStatus {
|
|
20
|
-
platform: string;
|
|
21
|
-
guildId: string;
|
|
22
|
-
botEnabled: boolean;
|
|
23
|
-
}
|
|
24
|
-
export interface SmallGroupWhitelist {
|
|
25
|
-
platform: string;
|
|
26
|
-
guildId: string;
|
|
27
|
-
}
|
|
28
|
-
export interface PendingInvite {
|
|
29
|
-
platform: string;
|
|
30
|
-
groupId: string;
|
|
31
|
-
userId: string;
|
|
32
|
-
userName: string;
|
|
33
|
-
groupName: string;
|
|
34
|
-
time: number;
|
|
35
|
-
flag: string;
|
|
36
|
-
}
|
|
37
|
-
export interface PendingFriendRequest {
|
|
38
|
-
platform: string;
|
|
39
|
-
userId: string;
|
|
40
|
-
nickname: string;
|
|
41
|
-
comment: string;
|
|
42
|
-
flag: string;
|
|
43
|
-
time: number;
|
|
44
|
-
}
|
|
45
|
-
declare module 'koishi' {
|
|
46
|
-
interface Tables {
|
|
47
|
-
blacklisted_guild: BlacklistedGuild;
|
|
48
|
-
command_frequency_record: CommandFrequencyRecord;
|
|
49
|
-
group_bot_status: GroupBotStatus;
|
|
50
|
-
small_group_whitelist: SmallGroupWhitelist;
|
|
51
|
-
pending_invite: PendingInvite;
|
|
52
|
-
pending_friend_request: PendingFriendRequest;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
export declare const name = "group-control-database";
|
|
56
|
-
export declare function apply(ctx: Context): void;
|
|
57
|
-
export declare const BLACKLIST_PLATFORM = "onebot";
|
|
58
|
-
export declare function getBlacklistedGuild(ctx: Context, guildId: string): Promise<BlacklistedGuild[]>;
|
|
59
|
-
export declare function removeBlacklistedGuild(ctx: Context, guildId: string): Promise<import("minato").Driver.WriteResult>;
|
|
60
|
-
export declare function createBlacklistedGuild(ctx: Context, guildId: string, reason: string): Promise<import("minato").Driver.WriteResult>;
|
|
61
|
-
export declare function getAllBlacklistedGuilds(ctx: Context): Promise<BlacklistedGuild[]>;
|
|
62
|
-
export declare function clearBlacklistedGuilds(ctx: Context): Promise<import("minato").Driver.WriteResult>;
|
|
63
|
-
export declare function getCommandFrequencyRecord(ctx: Context, platform: string, guildId: string): Promise<CommandFrequencyRecord>;
|
|
64
|
-
export declare function updateCommandFrequencyRecord(ctx: Context, platform: string, guildId: string, data: Partial<CommandFrequencyRecord>): Promise<void>;
|
|
65
|
-
export declare function getGroupBotStatus(ctx: Context, platform: string, guildId: string): Promise<GroupBotStatus | null>;
|
|
66
|
-
export declare function setGroupBotStatus(ctx: Context, platform: string, guildId: string, botEnabled: boolean): Promise<void>;
|
|
67
|
-
export declare function isInSmallGroupWhitelist(ctx: Context, guildId: string): Promise<boolean>;
|
|
68
|
-
export declare function addToSmallGroupWhitelist(ctx: Context, guildId: string): Promise<void>;
|
|
69
|
-
export declare function removeFromSmallGroupWhitelist(ctx: Context, guildId: string): Promise<void>;
|
|
70
|
-
export declare function getAllSmallGroupWhitelist(ctx: Context): Promise<SmallGroupWhitelist[]>;
|
|
71
|
-
export declare function getPendingInvite(ctx: Context, groupId: string): Promise<PendingInvite>;
|
|
72
|
-
export declare function addPendingInvite(ctx: Context, inviteUser: Omit<PendingInvite, 'platform'>): Promise<void>;
|
|
73
|
-
export declare function removePendingInvite(ctx: Context, groupId: string): Promise<void>;
|
|
74
|
-
export declare function getAllPendingInvites(ctx: Context): Promise<PendingInvite[]>;
|
|
75
|
-
export declare function clearExpiredPendingInvites(ctx: Context, expireTimeMs: number): Promise<number>;
|
|
76
|
-
export declare function getPendingFriendRequest(ctx: Context, platform: string, userId: string): Promise<PendingFriendRequest>;
|
|
77
|
-
export declare function addPendingFriendRequest(ctx: Context, platform: string, data: Omit<PendingFriendRequest, 'platform'>): Promise<void>;
|
|
78
|
-
export declare function removePendingFriendRequest(ctx: Context, platform: string, userId: string): Promise<void>;
|
|
79
|
-
export declare function getAllPendingFriendRequests(ctx: Context, platform: string): Promise<PendingFriendRequest[]>;
|
|
80
|
-
export declare function clearExpiredPendingFriendRequests(ctx: Context, platform: string, expireTimeMs: number): Promise<number>;
|
|
1
|
+
import { Context } from 'koishi';
|
|
2
|
+
export interface BlacklistedGuild {
|
|
3
|
+
platform: string;
|
|
4
|
+
guildId: string;
|
|
5
|
+
timestamp: number;
|
|
6
|
+
reason: string;
|
|
7
|
+
}
|
|
8
|
+
export interface CommandFrequencyRecord {
|
|
9
|
+
platform: string;
|
|
10
|
+
guildId: string;
|
|
11
|
+
commandCount: number;
|
|
12
|
+
lastCommandTime: number;
|
|
13
|
+
warningSent: boolean;
|
|
14
|
+
blockExpiryTime: number;
|
|
15
|
+
firstWarningTime: number;
|
|
16
|
+
blockCount: number;
|
|
17
|
+
lastBlockNotifyTime: number;
|
|
18
|
+
}
|
|
19
|
+
export interface GroupBotStatus {
|
|
20
|
+
platform: string;
|
|
21
|
+
guildId: string;
|
|
22
|
+
botEnabled: boolean;
|
|
23
|
+
}
|
|
24
|
+
export interface SmallGroupWhitelist {
|
|
25
|
+
platform: string;
|
|
26
|
+
guildId: string;
|
|
27
|
+
}
|
|
28
|
+
export interface PendingInvite {
|
|
29
|
+
platform: string;
|
|
30
|
+
groupId: string;
|
|
31
|
+
userId: string;
|
|
32
|
+
userName: string;
|
|
33
|
+
groupName: string;
|
|
34
|
+
time: number;
|
|
35
|
+
flag: string;
|
|
36
|
+
}
|
|
37
|
+
export interface PendingFriendRequest {
|
|
38
|
+
platform: string;
|
|
39
|
+
userId: string;
|
|
40
|
+
nickname: string;
|
|
41
|
+
comment: string;
|
|
42
|
+
flag: string;
|
|
43
|
+
time: number;
|
|
44
|
+
}
|
|
45
|
+
declare module 'koishi' {
|
|
46
|
+
interface Tables {
|
|
47
|
+
blacklisted_guild: BlacklistedGuild;
|
|
48
|
+
command_frequency_record: CommandFrequencyRecord;
|
|
49
|
+
group_bot_status: GroupBotStatus;
|
|
50
|
+
small_group_whitelist: SmallGroupWhitelist;
|
|
51
|
+
pending_invite: PendingInvite;
|
|
52
|
+
pending_friend_request: PendingFriendRequest;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
export declare const name = "group-control-database";
|
|
56
|
+
export declare function apply(ctx: Context): void;
|
|
57
|
+
export declare const BLACKLIST_PLATFORM = "onebot";
|
|
58
|
+
export declare function getBlacklistedGuild(ctx: Context, guildId: string): Promise<BlacklistedGuild[]>;
|
|
59
|
+
export declare function removeBlacklistedGuild(ctx: Context, guildId: string): Promise<import("minato").Driver.WriteResult>;
|
|
60
|
+
export declare function createBlacklistedGuild(ctx: Context, guildId: string, reason: string): Promise<import("minato").Driver.WriteResult>;
|
|
61
|
+
export declare function getAllBlacklistedGuilds(ctx: Context): Promise<BlacklistedGuild[]>;
|
|
62
|
+
export declare function clearBlacklistedGuilds(ctx: Context): Promise<import("minato").Driver.WriteResult>;
|
|
63
|
+
export declare function getCommandFrequencyRecord(ctx: Context, platform: string, guildId: string): Promise<CommandFrequencyRecord>;
|
|
64
|
+
export declare function updateCommandFrequencyRecord(ctx: Context, platform: string, guildId: string, data: Partial<CommandFrequencyRecord>): Promise<void>;
|
|
65
|
+
export declare function getGroupBotStatus(ctx: Context, platform: string, guildId: string): Promise<GroupBotStatus | null>;
|
|
66
|
+
export declare function setGroupBotStatus(ctx: Context, platform: string, guildId: string, botEnabled: boolean): Promise<void>;
|
|
67
|
+
export declare function isInSmallGroupWhitelist(ctx: Context, guildId: string): Promise<boolean>;
|
|
68
|
+
export declare function addToSmallGroupWhitelist(ctx: Context, guildId: string): Promise<void>;
|
|
69
|
+
export declare function removeFromSmallGroupWhitelist(ctx: Context, guildId: string): Promise<void>;
|
|
70
|
+
export declare function getAllSmallGroupWhitelist(ctx: Context): Promise<SmallGroupWhitelist[]>;
|
|
71
|
+
export declare function getPendingInvite(ctx: Context, groupId: string): Promise<PendingInvite>;
|
|
72
|
+
export declare function addPendingInvite(ctx: Context, inviteUser: Omit<PendingInvite, 'platform'>): Promise<void>;
|
|
73
|
+
export declare function removePendingInvite(ctx: Context, groupId: string): Promise<void>;
|
|
74
|
+
export declare function getAllPendingInvites(ctx: Context): Promise<PendingInvite[]>;
|
|
75
|
+
export declare function clearExpiredPendingInvites(ctx: Context, expireTimeMs: number): Promise<number>;
|
|
76
|
+
export declare function getPendingFriendRequest(ctx: Context, platform: string, userId: string): Promise<PendingFriendRequest>;
|
|
77
|
+
export declare function addPendingFriendRequest(ctx: Context, platform: string, data: Omit<PendingFriendRequest, 'platform'>): Promise<void>;
|
|
78
|
+
export declare function removePendingFriendRequest(ctx: Context, platform: string, userId: string): Promise<void>;
|
|
79
|
+
export declare function getAllPendingFriendRequests(ctx: Context, platform: string): Promise<PendingFriendRequest[]>;
|
|
80
|
+
export declare function clearExpiredPendingFriendRequests(ctx: Context, platform: string, expireTimeMs: number): Promise<number>;
|
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Context } from 'koishi';
|
|
2
|
-
import { Config } from './config';
|
|
3
|
-
export * from './config';
|
|
4
|
-
export declare const name = "group-control";
|
|
5
|
-
export declare function apply(ctx: Context, config: Config): void;
|
|
1
|
+
import { Context } from 'koishi';
|
|
2
|
+
import { Config } from './config';
|
|
3
|
+
export * from './config';
|
|
4
|
+
export declare const name = "group-control";
|
|
5
|
+
export declare function apply(ctx: Context, config: Config): void;
|
package/lib/index.js
CHANGED
|
@@ -349,8 +349,8 @@ __name(getGroupName, "getGroupName");
|
|
|
349
349
|
function apply2(ctx, config) {
|
|
350
350
|
const quittingGuilds = /* @__PURE__ */ new Map();
|
|
351
351
|
const processedKicks = /* @__PURE__ */ new Map();
|
|
352
|
-
const QUITTING_EXPIRE_MS =
|
|
353
|
-
const KICK_DEDUP_MS =
|
|
352
|
+
const QUITTING_EXPIRE_MS = 60 * 1e3;
|
|
353
|
+
const KICK_DEDUP_MS = 60 * 1e3;
|
|
354
354
|
setInterval(() => {
|
|
355
355
|
const now = Date.now();
|
|
356
356
|
for (const [key, time] of quittingGuilds) {
|
|
@@ -459,7 +459,6 @@ function apply2(ctx, config) {
|
|
|
459
459
|
ctx.on("guild-removed", async (session) => {
|
|
460
460
|
const { guildId, platform } = session;
|
|
461
461
|
const quittingKey = `${platform}:${guildId}`;
|
|
462
|
-
ctx.logger("group-control-basic").info(`[guild-removed] 触发!guildId=${guildId}, platform=${platform}, isQuitting=${quittingGuilds.has(quittingKey)}, isProcessed=${processedKicks.has(quittingKey)}`);
|
|
463
462
|
if (quittingGuilds.has(quittingKey)) {
|
|
464
463
|
return;
|
|
465
464
|
}
|
|
@@ -576,6 +575,29 @@ function apply3(ctx, config) {
|
|
|
576
575
|
} catch (error) {
|
|
577
576
|
console.error("获取群信息失败:", error);
|
|
578
577
|
}
|
|
578
|
+
if (config.invite.autoApprove) {
|
|
579
|
+
try {
|
|
580
|
+
await session.bot.internal.setGroupAddRequest(flag, "invite", true, "");
|
|
581
|
+
approvedGroups.add(rawGroupId);
|
|
582
|
+
if (config.invite.showDetailedLog) {
|
|
583
|
+
console.log(`自动同意群聊邀请: 群号 ${rawGroupId}, 邀请者 ${rawUserId}`);
|
|
584
|
+
}
|
|
585
|
+
} catch (error) {
|
|
586
|
+
console.error("自动同意群聊邀请失败:", error);
|
|
587
|
+
return;
|
|
588
|
+
}
|
|
589
|
+
try {
|
|
590
|
+
const approveMessage = config.invite.inviteApproveMessage.replaceAll("{groupName}", groupName).replaceAll("{groupId}", rawGroupId).replaceAll("{userName}", userName).replaceAll("{userId}", rawUserId);
|
|
591
|
+
await session.bot.sendPrivateMessage(rawUserId, approveMessage);
|
|
592
|
+
} catch (error) {
|
|
593
|
+
console.error(`发送自动通过提示给 ${rawUserId} 失败:`, error);
|
|
594
|
+
}
|
|
595
|
+
if (config.invite.notifyAdminOnApprove) {
|
|
596
|
+
const notifyMessage = config.invite.inviteApproveNotificationMessage.replaceAll("{groupName}", groupName).replaceAll("{groupId}", rawGroupId).replaceAll("{userName}", userName).replaceAll("{userId}", rawUserId);
|
|
597
|
+
await notifyAdmins(session.bot, config, notifyMessage);
|
|
598
|
+
}
|
|
599
|
+
return;
|
|
600
|
+
}
|
|
579
601
|
try {
|
|
580
602
|
const waitMessage = config.invite.inviteWaitMessage.replaceAll("{groupName}", groupName).replaceAll("{groupId}", rawGroupId).replaceAll("{userName}", userName).replaceAll("{userId}", rawUserId);
|
|
581
603
|
await session.bot.sendPrivateMessage(rawUserId, waitMessage);
|
|
@@ -583,17 +605,6 @@ function apply3(ctx, config) {
|
|
|
583
605
|
console.error(`发送等待审核提示给 ${rawUserId} 失败:`, error);
|
|
584
606
|
}
|
|
585
607
|
if (!config.admin.adminQQs || config.admin.adminQQs.length === 0) {
|
|
586
|
-
if (config.invite.autoApprove) {
|
|
587
|
-
try {
|
|
588
|
-
await session.bot.internal.setGroupAddRequest(flag, "invite", true, "");
|
|
589
|
-
approvedGroups.add(rawGroupId);
|
|
590
|
-
if (config.invite.showDetailedLog) {
|
|
591
|
-
console.log(`自动同意群聊邀请: 群号 ${rawGroupId}, 邀请者 ${rawUserId}`);
|
|
592
|
-
}
|
|
593
|
-
} catch (error) {
|
|
594
|
-
console.error("自动同意群聊邀请失败:", error);
|
|
595
|
-
}
|
|
596
|
-
}
|
|
597
608
|
return;
|
|
598
609
|
}
|
|
599
610
|
await addPendingInvite(ctx, {
|
|
@@ -921,12 +932,8 @@ function apply5(ctx, config) {
|
|
|
921
932
|
if (errorMsg) return errorMsg;
|
|
922
933
|
const guildId = parseGuildId(input);
|
|
923
934
|
if (!guildId) return `输入格式错误。`;
|
|
924
|
-
const
|
|
925
|
-
|
|
926
|
-
await removeBlacklistedGuild(ctx, guildId);
|
|
927
|
-
const check = await getBlacklistedGuild(ctx, guildId);
|
|
928
|
-
if (check.length > 0) return `群聊 ${guildId} 移除失败,请重试。`;
|
|
929
|
-
return `已移除群聊 ${guildId},当前黑名单中已不存在该群。`;
|
|
935
|
+
const removed = await removeBlacklistedGuild(ctx, guildId);
|
|
936
|
+
return removed ? `已移除群聊 ${guildId}` : `群聊 ${guildId} 不在黑名单中。`;
|
|
930
937
|
});
|
|
931
938
|
ctx.command("gc.banlist", "查看黑名单").action(async ({ session }) => {
|
|
932
939
|
if (!hasGlobalPermission(session, config)) return "权限不足,只有全局管理员可以执行此操作。";
|
|
@@ -1187,9 +1194,12 @@ var Config = import_koishi.Schema.intersect([
|
|
|
1187
1194
|
import_koishi.Schema.object({
|
|
1188
1195
|
invite: import_koishi.Schema.object({
|
|
1189
1196
|
enabled: import_koishi.Schema.boolean().default(false).description("启用群聊邀请审核"),
|
|
1190
|
-
autoApprove: import_koishi.Schema.boolean().default(false).description("
|
|
1197
|
+
autoApprove: import_koishi.Schema.boolean().default(false).description("自动同意邀请"),
|
|
1198
|
+
notifyAdminOnApprove: import_koishi.Schema.boolean().default(true).description("自动同意时是否仍通知管理员"),
|
|
1191
1199
|
inviteWaitMessage: import_koishi.Schema.string().default("已收到您的群聊邀请,正在等待管理员审核,请耐心等待。").description("发给邀请者的等待提示"),
|
|
1200
|
+
inviteApproveMessage: import_koishi.Schema.string().default("已自动通过您的群聊邀请,机器人正在加入群聊。").description("自动同意时发给邀请者的提示,支持变量 {groupName}, {groupId}, {userName}, {userId}"),
|
|
1192
1201
|
inviteRequestMessage: import_koishi.Schema.string().default("收到新的群聊邀请请求:\n群名称:{groupName}\n群号:{groupId}\n邀请者:{userName} (QQ: {userId})\n\n请使用指令 gc.approve {groupId} 同意或 gc.reject {groupId} 拒绝。").description("发给管理员的请求消息模板,支持变量 {groupName}, {groupId}, {userName}, {userId}"),
|
|
1202
|
+
inviteApproveNotificationMessage: import_koishi.Schema.string().default("已自动通过群聊邀请\n群名称:{groupName}\n群号:{groupId}\n邀请者:{userName} (QQ: {userId})").description("自动同意时发给管理员的通知模板,支持变量 {groupName}, {groupId}, {userName}, {userId}"),
|
|
1193
1203
|
inviteExpireDays: import_koishi.Schema.number().default(3).description("邀请记录过期天数"),
|
|
1194
1204
|
showDetailedLog: import_koishi.Schema.boolean().default(false).description("显示详细日志")
|
|
1195
1205
|
}).description("群聊邀请审核")
|
package/lib/modules/basic.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Context } from 'koishi';
|
|
2
|
-
import { Config } from '../config';
|
|
3
|
-
export declare const name = "group-control-basic";
|
|
4
|
-
export declare function apply(ctx: Context, config: Config): void;
|
|
1
|
+
import { Context } from 'koishi';
|
|
2
|
+
import { Config } from '../config';
|
|
3
|
+
export declare const name = "group-control-basic";
|
|
4
|
+
export declare function apply(ctx: Context, config: Config): void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Context } from 'koishi';
|
|
2
|
-
import { Config } from '../config';
|
|
3
|
-
export declare const name = "group-control-commands";
|
|
4
|
-
export declare function apply(ctx: Context, config: Config): void;
|
|
1
|
+
import { Context } from 'koishi';
|
|
2
|
+
import { Config } from '../config';
|
|
3
|
+
export declare const name = "group-control-commands";
|
|
4
|
+
export declare function apply(ctx: Context, config: Config): void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Context } from 'koishi';
|
|
2
|
-
import { Config } from '../config';
|
|
3
|
-
export declare const name = "group-control-frequency";
|
|
4
|
-
export declare function apply(ctx: Context, config: Config): void;
|
|
1
|
+
import { Context } from 'koishi';
|
|
2
|
+
import { Config } from '../config';
|
|
3
|
+
export declare const name = "group-control-frequency";
|
|
4
|
+
export declare function apply(ctx: Context, config: Config): void;
|
package/lib/modules/friend.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Context } from 'koishi';
|
|
2
|
-
import { Config } from '../config';
|
|
3
|
-
export declare const name = "group-control-friend";
|
|
4
|
-
export declare function apply(ctx: Context, config: Config): void;
|
|
1
|
+
import { Context } from 'koishi';
|
|
2
|
+
import { Config } from '../config';
|
|
3
|
+
export declare const name = "group-control-friend";
|
|
4
|
+
export declare function apply(ctx: Context, config: Config): void;
|
package/lib/modules/invite.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Context } from 'koishi';
|
|
2
|
-
import { Config } from '../config';
|
|
3
|
-
export declare const name = "group-control-invite";
|
|
4
|
-
export declare function apply(ctx: Context, config: Config): void;
|
|
1
|
+
import { Context } from 'koishi';
|
|
2
|
+
import { Config } from '../config';
|
|
3
|
+
export declare const name = "group-control-invite";
|
|
4
|
+
export declare function apply(ctx: Context, config: Config): void;
|
package/lib/modules/switch.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Context } from 'koishi';
|
|
2
|
-
import { Config } from '../config';
|
|
3
|
-
export declare const name = "group-control-switch";
|
|
4
|
-
export declare function apply(ctx: Context, config: Config): void;
|
|
1
|
+
import { Context } from 'koishi';
|
|
2
|
+
import { Config } from '../config';
|
|
3
|
+
export declare const name = "group-control-switch";
|
|
4
|
+
export declare function apply(ctx: Context, config: Config): void;
|
package/lib/state.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 跨模块共享状态
|
|
3
|
-
* 用于在 invite 和 basic 等模块间传递信息
|
|
4
|
-
*/
|
|
5
|
-
/** 管理员已审核通过的群号集合(approve 指令通过后添加) */
|
|
6
|
-
export declare const approvedGroups: Set<string>;
|
|
1
|
+
/**
|
|
2
|
+
* 跨模块共享状态
|
|
3
|
+
* 用于在 invite 和 basic 等模块间传递信息
|
|
4
|
+
*/
|
|
5
|
+
/** 管理员已审核通过的群号集合(approve 指令通过后添加) */
|
|
6
|
+
export declare const approvedGroups: Set<string>;
|
package/lib/utils.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { Session } from 'koishi';
|
|
2
|
-
import { Config } from './config';
|
|
3
|
-
export declare function isBlacklistEnabled(config: Config['basic']): string | null;
|
|
4
|
-
export declare function parseGuildId(input: string): string | null;
|
|
5
|
-
export declare function formatDate(timestamp: number): string;
|
|
6
|
-
export declare function notifyAdmins(bot: any, config: Config, message: string): Promise<void>;
|
|
7
|
-
/** 是否为全局管理员(填在 adminQQs 里的) */
|
|
8
|
-
export declare function isGlobalAdmin(session: Session, config: Config): boolean;
|
|
9
|
-
/**
|
|
10
|
-
* 检查群级权限(bot-on/off、quit、protectedCommands)
|
|
11
|
-
* builtin 模式:群管理员或全局管理员均可
|
|
12
|
-
* koishi 模式:由 authority 决定
|
|
13
|
-
*/
|
|
14
|
-
export declare function hasGuildPermission(session: Session, config: Config): Promise<boolean>;
|
|
15
|
-
export declare function hasGlobalPermission(session: Session, config: Config): boolean;
|
|
16
|
-
/** 管理指令列表 - 这些指令始终不受 bot-off 影响 */
|
|
17
|
-
export declare const ADMIN_COMMANDS: Set<string>;
|
|
1
|
+
import { Session } from 'koishi';
|
|
2
|
+
import { Config } from './config';
|
|
3
|
+
export declare function isBlacklistEnabled(config: Config['basic']): string | null;
|
|
4
|
+
export declare function parseGuildId(input: string): string | null;
|
|
5
|
+
export declare function formatDate(timestamp: number): string;
|
|
6
|
+
export declare function notifyAdmins(bot: any, config: Config, message: string): Promise<void>;
|
|
7
|
+
/** 是否为全局管理员(填在 adminQQs 里的) */
|
|
8
|
+
export declare function isGlobalAdmin(session: Session, config: Config): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* 检查群级权限(bot-on/off、quit、protectedCommands)
|
|
11
|
+
* builtin 模式:群管理员或全局管理员均可
|
|
12
|
+
* koishi 模式:由 authority 决定
|
|
13
|
+
*/
|
|
14
|
+
export declare function hasGuildPermission(session: Session, config: Config): Promise<boolean>;
|
|
15
|
+
export declare function hasGlobalPermission(session: Session, config: Config): boolean;
|
|
16
|
+
/** 管理指令列表 - 这些指令始终不受 bot-off 影响 */
|
|
17
|
+
export declare const ADMIN_COMMANDS: Set<string>;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koishi-plugin-group-control",
|
|
3
3
|
"description": "Koishi 插件,一个多功能的群聊自管理工具。支持被踢出自动拉黑、刷屏自动屏蔽、开关控制等功能。(仅支持 OneBot 适配器)",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.1",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
7
7
|
"files": [
|
|
@@ -22,8 +22,5 @@
|
|
|
22
22
|
],
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"koishi": "^4.18.7"
|
|
25
|
-
},
|
|
26
|
-
"devDependencies": {
|
|
27
|
-
"@types/node": "^22.19.7"
|
|
28
25
|
}
|
|
29
26
|
}
|
package/readme.md
CHANGED
|
@@ -1,199 +1,199 @@
|
|
|
1
|
-
# koishi-plugin-group-control
|
|
2
|
-
|
|
3
|
-
[](https://www.npmjs.com/package/koishi-plugin-group-control)
|
|
4
|
-
|
|
5
|
-
Koishi 插件,多功能群聊自管理工具。仅支持 OneBot 适配器。
|
|
6
|
-
|
|
7
|
-
> 使用 Qwen3-Coder & Gemini-3.1-Pro-Preview & Claude Sonnet/Opus 4.6 协助完成
|
|
8
|
-
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
## 功能概览
|
|
12
|
-
|
|
13
|
-
- **黑名单管理**:被踢出群后自动拉黑,下次被邀请时自动退出
|
|
14
|
-
- **小群自动退群**:加入人数不足的群时自动退出并通知管理员
|
|
15
|
-
- **合格小群通知**:未经审核被拉入人数达标的群时,通知管理员确认
|
|
16
|
-
- **群聊邀请审核**:收到邀请时暂缓加入,等待管理员审核
|
|
17
|
-
- **好友申请管理**:收到好友申请时通知管理员,或自动通过
|
|
18
|
-
- **频率控制**:限制群聊/私聊的指令及对话频率,支持指数增长屏蔽时长
|
|
19
|
-
- **Bot 开关**:按群独立开关 bot,关闭后屏蔽所有响应
|
|
20
|
-
- **被禁言通知**:bot 被禁言时可选通知管理员
|
|
21
|
-
- **权限管理**:支持 Koishi authority 或内置群管理员两种权限模式
|
|
22
|
-
|
|
23
|
-
---
|
|
24
|
-
|
|
25
|
-
## 配置说明
|
|
26
|
-
|
|
27
|
-
### 管理员配置
|
|
28
|
-
|
|
29
|
-
| 配置项 | 默认值 | 说明 |
|
|
30
|
-
|--------|--------|------|
|
|
31
|
-
| `admin.adminQQs` | `[]` | 管理员QQ号列表(权限验证及通知) |
|
|
32
|
-
| `admin.notificationGroupId` | *(空)* | 通知群号(填写后发到此群,否则私聊管理员) |
|
|
33
|
-
|
|
34
|
-
### 权限管理
|
|
35
|
-
|
|
36
|
-
| 配置项 | 默认值 | 说明 |
|
|
37
|
-
|--------|--------|------|
|
|
38
|
-
| `mode` | `builtin` | `builtin`:使用群管理员/群主权限;`koishi`:使用 Koishi authority |
|
|
39
|
-
| `koishiAuthority` | `3` | Koishi 模式下管理指令所需的最低权限等级 |
|
|
40
|
-
| `protectedCommands` | `[]` | 需要群管理员权限才能使用的自定义指令名列表 |
|
|
41
|
-
|
|
42
|
-
### 基础群组管理
|
|
43
|
-
|
|
44
|
-
**欢迎 & 退群**
|
|
45
|
-
|
|
46
|
-
| 配置项 | 默认值 | 说明 |
|
|
47
|
-
|--------|--------|------|
|
|
48
|
-
| `welcomeMessage` | `你好,我是机器人。` | 加入群聊时发送的欢迎消息 |
|
|
49
|
-
| `quitMessage` | `收到来自{userId}的指令,即将退出群聊。` | quit 指令触发后的群内提示,支持 `{userId}` |
|
|
50
|
-
| `quitCommandEnabled` | `true` | 是否启用 quit 指令 |
|
|
51
|
-
|
|
52
|
-
**黑名单**
|
|
53
|
-
|
|
54
|
-
| 配置项 | 默认值 | 说明 |
|
|
55
|
-
|--------|--------|------|
|
|
56
|
-
| `enableBlacklist` | `true` | 启用被踢出自动拉黑 |
|
|
57
|
-
| `blacklistMessage` | *(见配置)* | 被拉入黑名单群后的提示 |
|
|
58
|
-
|
|
59
|
-
**踢出通知**
|
|
60
|
-
|
|
61
|
-
| 配置项 | 默认值 | 说明 |
|
|
62
|
-
|--------|--------|------|
|
|
63
|
-
| `notifyAdminOnKick` | `true` | 被踢出时通知管理员 |
|
|
64
|
-
| `kickNotificationMessage` | *(见配置)* | 通知消息模板,支持 `{groupId}`, `{groupName}` |
|
|
65
|
-
|
|
66
|
-
**小群自动退群**
|
|
67
|
-
|
|
68
|
-
| 配置项 | 默认值 | 说明 |
|
|
69
|
-
|--------|--------|------|
|
|
70
|
-
| `smallGroupAutoQuit` | `false` | 启用小群自动退群 |
|
|
71
|
-
| `smallGroupThreshold` | `30` | 人数阈值,低于等于此值时自动退出 |
|
|
72
|
-
| `smallGroupQuitMessage` | *(见配置)* | 退群提示,支持 `{memberCount}`, `{threshold}`, `{groupName}`, `{groupId}` |
|
|
73
|
-
| `smallGroupNotifyAdmin` | `true` | 自动退群时通知管理员 |
|
|
74
|
-
| `smallGroupCheckDelay` | `3000` | 加入后延迟检测的时间(毫秒) |
|
|
75
|
-
|
|
76
|
-
**合格小群通知**
|
|
77
|
-
|
|
78
|
-
| 配置项 | 默认值 | 说明 |
|
|
79
|
-
|--------|--------|------|
|
|
80
|
-
| `smallGroupQualifiedNotifyAdmin` | `true` | 未经审核被拉入人数达标的群时通知管理员 |
|
|
81
|
-
| `smallGroupQualifiedMessage` | *(见配置)* | 通知消息模板,支持 `{groupName}`, `{groupId}`, `{memberCount}`, `{threshold}` |
|
|
82
|
-
|
|
83
|
-
**被禁言通知**
|
|
84
|
-
|
|
85
|
-
| 配置项 | 默认值 | 说明 |
|
|
86
|
-
|--------|--------|------|
|
|
87
|
-
| `notifyAdminOnMute` | `false` | bot 被禁言时通知管理员 |
|
|
88
|
-
| `muteNotificationMessage` | *(见配置)* | 通知消息模板,支持 `{groupId}`, `{groupName}`, `{operatorId}`, `{duration}` |
|
|
89
|
-
|
|
90
|
-
### 频率控制
|
|
91
|
-
|
|
92
|
-
**群聊**
|
|
93
|
-
|
|
94
|
-
| 配置项 | 默认值 | 说明 |
|
|
95
|
-
|--------|--------|------|
|
|
96
|
-
| `enabled` | `false` | 启用群聊频率控制(指令及 @ 对话均受限) |
|
|
97
|
-
| `limit` | `5` | 时间窗口内允许的最大触发次数 |
|
|
98
|
-
| `window` | `60` | 时间窗口(秒) |
|
|
99
|
-
| `warnDelay` | `30` | 警告后再次触发的时间阈值(秒),超出则进入屏蔽 |
|
|
100
|
-
| `blockDur` | `300` | 首次屏蔽的基础时长(秒) |
|
|
101
|
-
| `whitelist` | `[]` | 不受频率限制的群号列表 |
|
|
102
|
-
|
|
103
|
-
**私聊**
|
|
104
|
-
|
|
105
|
-
| 配置项 | 默认值 | 说明 |
|
|
106
|
-
|--------|--------|------|
|
|
107
|
-
| `privateEnabled` | `false` | 启用私聊频率控制 |
|
|
108
|
-
| `privateLimit` | `10` | 私聊时间窗口内允许的最大触发次数 |
|
|
109
|
-
| `privateWindow` | `60` | 私聊时间窗口(秒) |
|
|
110
|
-
| `privateWarnDelay` | `30` | 私聊警告后再次触发的时间阈值(秒) |
|
|
111
|
-
| `privateBlockDur` | `300` | 私聊首次屏蔽的基础时长(秒) |
|
|
112
|
-
| `privateWhitelist` | `[]` | 不受私聊频率限制的用户ID列表 |
|
|
113
|
-
|
|
114
|
-
**指数增长(群聊和私聊共用)**
|
|
115
|
-
|
|
116
|
-
| 配置项 | 默认值 | 说明 |
|
|
117
|
-
|--------|--------|------|
|
|
118
|
-
| `blockExpBase` | `2` | 指数增长底数,每次屏蔽时长 = `blockDur × base^(次数-1)`,设为 `1` 禁用 |
|
|
119
|
-
| `blockExpWindow` | `3600` | 指数增长重置窗口(秒),从最后一次屏蔽结束计算,超出则重置屏蔽次数 |
|
|
120
|
-
|
|
121
|
-
**提示消息**
|
|
122
|
-
|
|
123
|
-
| 配置项 | 默认值 | 说明 |
|
|
124
|
-
|--------|--------|------|
|
|
125
|
-
| `blockNotifyCooldown` | `60` | 屏蔽期间重复触发时提示消息的冷却时间(秒),避免刷屏 |
|
|
126
|
-
| `warnMsg` | `发言频率过高,请慢一点~` | 首次超限警告消息 |
|
|
127
|
-
| `blockMsg` | `发言频率过高,已被禁用 {duration} 秒。` | 进入屏蔽时的通知,支持 `{duration}` |
|
|
128
|
-
| `blockedMsg` | `暂时被禁用,还有 {time} 秒解禁。` | 屏蔽期间再次触发时的提示,支持 `{time}` |
|
|
129
|
-
|
|
130
|
-
### 好友申请管理
|
|
131
|
-
|
|
132
|
-
| 配置项 | 默认值 | 说明 |
|
|
133
|
-
|--------|--------|------|
|
|
134
|
-
| `enabled` | `false` | 启用好友申请管理 |
|
|
135
|
-
| `autoApprove` | `false` | 自动通过好友申请,否则通知管理员手动处理 |
|
|
136
|
-
| `notifyAdminOnApprove` | `true` | 自动通过时是否仍通知管理员 |
|
|
137
|
-
| `requestExpireDays` | `7` | 待处理申请的过期天数 |
|
|
138
|
-
| `requestMessage` | *(见配置)* | 通知管理员的消息模板,支持 `{userId}`, `{nickname}`, `{comment}` |
|
|
139
|
-
| `approveNotificationMessage` | *(见配置)* | 自动通过时的通知消息模板,支持 `{userId}`, `{nickname}`, `{comment}` |
|
|
140
|
-
|
|
141
|
-
### 群聊邀请审核
|
|
142
|
-
|
|
143
|
-
| 配置项 | 默认值 | 说明 |
|
|
144
|
-
|--------|--------|------|
|
|
145
|
-
| `enabled` | `false` | 启用邀请审核 |
|
|
146
|
-
| `inviteWaitMessage` | *(见配置)* | 发给邀请者的等待提示 |
|
|
147
|
-
| `inviteRequestMessage` | *(见配置)* | 发给管理员的请求消息,支持 `{groupName}`, `{groupId}`, `{userName}`, `{userId}` |
|
|
148
|
-
| `autoApprove` | `false` | 未配置管理员时自动同意邀请 |
|
|
149
|
-
| `showDetailedLog` | `false` | 显示详细日志 |
|
|
150
|
-
| `inviteExpireDays` | `3` | 邀请记录过期天数 |
|
|
151
|
-
|
|
152
|
-
### 机器人开关
|
|
153
|
-
|
|
154
|
-
| 配置项 | 默认值 | 说明 |
|
|
155
|
-
|--------|--------|------|
|
|
156
|
-
| `enabled` | `true` | 启用群聊 bot 开关功能 |
|
|
157
|
-
| `defaultState` | `true` | 默认开启状态 |
|
|
158
|
-
| `disabledMessage` | *(见配置)* | 关闭状态下被 @ 时的提示 |
|
|
159
|
-
|
|
160
|
-
---
|
|
161
|
-
|
|
162
|
-
## 指令列表
|
|
163
|
-
|
|
164
|
-
所有管理员指令统一收纳在 `gc` 主指令下,输入 `gc` 可查看子指令列表。
|
|
165
|
-
|
|
166
|
-
### 管理员指令(gc 子指令,需全局管理员)
|
|
167
|
-
|
|
168
|
-
| 指令 | 说明 |
|
|
169
|
-
|------|------|
|
|
170
|
-
| `gc.banlist` | 查看黑名单列表 |
|
|
171
|
-
| `gc.ban <群号>` | 添加群到黑名单 |
|
|
172
|
-
| `gc.unban <群号>` | 从黑名单移除群 |
|
|
173
|
-
| `gc.clearban` | 清空黑名单 |
|
|
174
|
-
| `gc.sg-add <群号>` | 将群加入小群白名单,不受人数限制 |
|
|
175
|
-
| `gc.sg-rm <群号>` | 从小群白名单移除群 |
|
|
176
|
-
| `gc.sg-list` | 查看小群白名单 |
|
|
177
|
-
| `gc.approve <群号>` | 同意加入指定群 |
|
|
178
|
-
| `gc.reject <群号>` | 拒绝加入指定群 |
|
|
179
|
-
| `gc.pending` | 查看待处理的群聊邀请列表 |
|
|
180
|
-
| `gc.fa <QQ号>` | 同意好友申请 |
|
|
181
|
-
| `gc.fr <QQ号>` | 拒绝好友申请 |
|
|
182
|
-
| `gc.fp` | 查看待处理的好友申请列表 |
|
|
183
|
-
|
|
184
|
-
### 群聊管理
|
|
185
|
-
|
|
186
|
-
| 指令 | 说明 | 权限 |
|
|
187
|
-
|------|------|------|
|
|
188
|
-
| `quit` | 让 bot 退出当前群聊 | 群管理员 |
|
|
189
|
-
| `bot-on` | 开启当前群的 bot | 群管理员 |
|
|
190
|
-
| `bot-off` | 关闭当前群的 bot | 群管理员 |
|
|
191
|
-
|
|
192
|
-
---
|
|
193
|
-
|
|
194
|
-
## 注意事项
|
|
195
|
-
|
|
196
|
-
- 本插件仅支持 **OneBot 适配器**(如 go-cqhttp、LLOneBot 等)
|
|
197
|
-
- 管理员通知依赖 `admin.adminQQs` 或 `admin.notificationGroupId` 的配置,未配置则无法收到通知
|
|
198
|
-
- 频率控制的非指令拦截(@ 对话、私聊)不影响入群欢迎等系统事件
|
|
199
|
-
- 小群合格通知仅在启用了 `smallGroupAutoQuit` 且未经 `gc.approve` 审核通过的情况下触发
|
|
1
|
+
# koishi-plugin-group-control
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/koishi-plugin-group-control)
|
|
4
|
+
|
|
5
|
+
Koishi 插件,多功能群聊自管理工具。仅支持 OneBot 适配器。
|
|
6
|
+
|
|
7
|
+
> 使用 Qwen3-Coder & Gemini-3.1-Pro-Preview & Claude Sonnet/Opus 4.6 协助完成
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## 功能概览
|
|
12
|
+
|
|
13
|
+
- **黑名单管理**:被踢出群后自动拉黑,下次被邀请时自动退出
|
|
14
|
+
- **小群自动退群**:加入人数不足的群时自动退出并通知管理员
|
|
15
|
+
- **合格小群通知**:未经审核被拉入人数达标的群时,通知管理员确认
|
|
16
|
+
- **群聊邀请审核**:收到邀请时暂缓加入,等待管理员审核
|
|
17
|
+
- **好友申请管理**:收到好友申请时通知管理员,或自动通过
|
|
18
|
+
- **频率控制**:限制群聊/私聊的指令及对话频率,支持指数增长屏蔽时长
|
|
19
|
+
- **Bot 开关**:按群独立开关 bot,关闭后屏蔽所有响应
|
|
20
|
+
- **被禁言通知**:bot 被禁言时可选通知管理员
|
|
21
|
+
- **权限管理**:支持 Koishi authority 或内置群管理员两种权限模式
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## 配置说明
|
|
26
|
+
|
|
27
|
+
### 管理员配置
|
|
28
|
+
|
|
29
|
+
| 配置项 | 默认值 | 说明 |
|
|
30
|
+
|--------|--------|------|
|
|
31
|
+
| `admin.adminQQs` | `[]` | 管理员QQ号列表(权限验证及通知) |
|
|
32
|
+
| `admin.notificationGroupId` | *(空)* | 通知群号(填写后发到此群,否则私聊管理员) |
|
|
33
|
+
|
|
34
|
+
### 权限管理
|
|
35
|
+
|
|
36
|
+
| 配置项 | 默认值 | 说明 |
|
|
37
|
+
|--------|--------|------|
|
|
38
|
+
| `mode` | `builtin` | `builtin`:使用群管理员/群主权限;`koishi`:使用 Koishi authority |
|
|
39
|
+
| `koishiAuthority` | `3` | Koishi 模式下管理指令所需的最低权限等级 |
|
|
40
|
+
| `protectedCommands` | `[]` | 需要群管理员权限才能使用的自定义指令名列表 |
|
|
41
|
+
|
|
42
|
+
### 基础群组管理
|
|
43
|
+
|
|
44
|
+
**欢迎 & 退群**
|
|
45
|
+
|
|
46
|
+
| 配置项 | 默认值 | 说明 |
|
|
47
|
+
|--------|--------|------|
|
|
48
|
+
| `welcomeMessage` | `你好,我是机器人。` | 加入群聊时发送的欢迎消息 |
|
|
49
|
+
| `quitMessage` | `收到来自{userId}的指令,即将退出群聊。` | quit 指令触发后的群内提示,支持 `{userId}` |
|
|
50
|
+
| `quitCommandEnabled` | `true` | 是否启用 quit 指令 |
|
|
51
|
+
|
|
52
|
+
**黑名单**
|
|
53
|
+
|
|
54
|
+
| 配置项 | 默认值 | 说明 |
|
|
55
|
+
|--------|--------|------|
|
|
56
|
+
| `enableBlacklist` | `true` | 启用被踢出自动拉黑 |
|
|
57
|
+
| `blacklistMessage` | *(见配置)* | 被拉入黑名单群后的提示 |
|
|
58
|
+
|
|
59
|
+
**踢出通知**
|
|
60
|
+
|
|
61
|
+
| 配置项 | 默认值 | 说明 |
|
|
62
|
+
|--------|--------|------|
|
|
63
|
+
| `notifyAdminOnKick` | `true` | 被踢出时通知管理员 |
|
|
64
|
+
| `kickNotificationMessage` | *(见配置)* | 通知消息模板,支持 `{groupId}`, `{groupName}` |
|
|
65
|
+
|
|
66
|
+
**小群自动退群**
|
|
67
|
+
|
|
68
|
+
| 配置项 | 默认值 | 说明 |
|
|
69
|
+
|--------|--------|------|
|
|
70
|
+
| `smallGroupAutoQuit` | `false` | 启用小群自动退群 |
|
|
71
|
+
| `smallGroupThreshold` | `30` | 人数阈值,低于等于此值时自动退出 |
|
|
72
|
+
| `smallGroupQuitMessage` | *(见配置)* | 退群提示,支持 `{memberCount}`, `{threshold}`, `{groupName}`, `{groupId}` |
|
|
73
|
+
| `smallGroupNotifyAdmin` | `true` | 自动退群时通知管理员 |
|
|
74
|
+
| `smallGroupCheckDelay` | `3000` | 加入后延迟检测的时间(毫秒) |
|
|
75
|
+
|
|
76
|
+
**合格小群通知**
|
|
77
|
+
|
|
78
|
+
| 配置项 | 默认值 | 说明 |
|
|
79
|
+
|--------|--------|------|
|
|
80
|
+
| `smallGroupQualifiedNotifyAdmin` | `true` | 未经审核被拉入人数达标的群时通知管理员 |
|
|
81
|
+
| `smallGroupQualifiedMessage` | *(见配置)* | 通知消息模板,支持 `{groupName}`, `{groupId}`, `{memberCount}`, `{threshold}` |
|
|
82
|
+
|
|
83
|
+
**被禁言通知**
|
|
84
|
+
|
|
85
|
+
| 配置项 | 默认值 | 说明 |
|
|
86
|
+
|--------|--------|------|
|
|
87
|
+
| `notifyAdminOnMute` | `false` | bot 被禁言时通知管理员 |
|
|
88
|
+
| `muteNotificationMessage` | *(见配置)* | 通知消息模板,支持 `{groupId}`, `{groupName}`, `{operatorId}`, `{duration}` |
|
|
89
|
+
|
|
90
|
+
### 频率控制
|
|
91
|
+
|
|
92
|
+
**群聊**
|
|
93
|
+
|
|
94
|
+
| 配置项 | 默认值 | 说明 |
|
|
95
|
+
|--------|--------|------|
|
|
96
|
+
| `enabled` | `false` | 启用群聊频率控制(指令及 @ 对话均受限) |
|
|
97
|
+
| `limit` | `5` | 时间窗口内允许的最大触发次数 |
|
|
98
|
+
| `window` | `60` | 时间窗口(秒) |
|
|
99
|
+
| `warnDelay` | `30` | 警告后再次触发的时间阈值(秒),超出则进入屏蔽 |
|
|
100
|
+
| `blockDur` | `300` | 首次屏蔽的基础时长(秒) |
|
|
101
|
+
| `whitelist` | `[]` | 不受频率限制的群号列表 |
|
|
102
|
+
|
|
103
|
+
**私聊**
|
|
104
|
+
|
|
105
|
+
| 配置项 | 默认值 | 说明 |
|
|
106
|
+
|--------|--------|------|
|
|
107
|
+
| `privateEnabled` | `false` | 启用私聊频率控制 |
|
|
108
|
+
| `privateLimit` | `10` | 私聊时间窗口内允许的最大触发次数 |
|
|
109
|
+
| `privateWindow` | `60` | 私聊时间窗口(秒) |
|
|
110
|
+
| `privateWarnDelay` | `30` | 私聊警告后再次触发的时间阈值(秒) |
|
|
111
|
+
| `privateBlockDur` | `300` | 私聊首次屏蔽的基础时长(秒) |
|
|
112
|
+
| `privateWhitelist` | `[]` | 不受私聊频率限制的用户ID列表 |
|
|
113
|
+
|
|
114
|
+
**指数增长(群聊和私聊共用)**
|
|
115
|
+
|
|
116
|
+
| 配置项 | 默认值 | 说明 |
|
|
117
|
+
|--------|--------|------|
|
|
118
|
+
| `blockExpBase` | `2` | 指数增长底数,每次屏蔽时长 = `blockDur × base^(次数-1)`,设为 `1` 禁用 |
|
|
119
|
+
| `blockExpWindow` | `3600` | 指数增长重置窗口(秒),从最后一次屏蔽结束计算,超出则重置屏蔽次数 |
|
|
120
|
+
|
|
121
|
+
**提示消息**
|
|
122
|
+
|
|
123
|
+
| 配置项 | 默认值 | 说明 |
|
|
124
|
+
|--------|--------|------|
|
|
125
|
+
| `blockNotifyCooldown` | `60` | 屏蔽期间重复触发时提示消息的冷却时间(秒),避免刷屏 |
|
|
126
|
+
| `warnMsg` | `发言频率过高,请慢一点~` | 首次超限警告消息 |
|
|
127
|
+
| `blockMsg` | `发言频率过高,已被禁用 {duration} 秒。` | 进入屏蔽时的通知,支持 `{duration}` |
|
|
128
|
+
| `blockedMsg` | `暂时被禁用,还有 {time} 秒解禁。` | 屏蔽期间再次触发时的提示,支持 `{time}` |
|
|
129
|
+
|
|
130
|
+
### 好友申请管理
|
|
131
|
+
|
|
132
|
+
| 配置项 | 默认值 | 说明 |
|
|
133
|
+
|--------|--------|------|
|
|
134
|
+
| `enabled` | `false` | 启用好友申请管理 |
|
|
135
|
+
| `autoApprove` | `false` | 自动通过好友申请,否则通知管理员手动处理 |
|
|
136
|
+
| `notifyAdminOnApprove` | `true` | 自动通过时是否仍通知管理员 |
|
|
137
|
+
| `requestExpireDays` | `7` | 待处理申请的过期天数 |
|
|
138
|
+
| `requestMessage` | *(见配置)* | 通知管理员的消息模板,支持 `{userId}`, `{nickname}`, `{comment}` |
|
|
139
|
+
| `approveNotificationMessage` | *(见配置)* | 自动通过时的通知消息模板,支持 `{userId}`, `{nickname}`, `{comment}` |
|
|
140
|
+
|
|
141
|
+
### 群聊邀请审核
|
|
142
|
+
|
|
143
|
+
| 配置项 | 默认值 | 说明 |
|
|
144
|
+
|--------|--------|------|
|
|
145
|
+
| `enabled` | `false` | 启用邀请审核 |
|
|
146
|
+
| `inviteWaitMessage` | *(见配置)* | 发给邀请者的等待提示 |
|
|
147
|
+
| `inviteRequestMessage` | *(见配置)* | 发给管理员的请求消息,支持 `{groupName}`, `{groupId}`, `{userName}`, `{userId}` |
|
|
148
|
+
| `autoApprove` | `false` | 未配置管理员时自动同意邀请 |
|
|
149
|
+
| `showDetailedLog` | `false` | 显示详细日志 |
|
|
150
|
+
| `inviteExpireDays` | `3` | 邀请记录过期天数 |
|
|
151
|
+
|
|
152
|
+
### 机器人开关
|
|
153
|
+
|
|
154
|
+
| 配置项 | 默认值 | 说明 |
|
|
155
|
+
|--------|--------|------|
|
|
156
|
+
| `enabled` | `true` | 启用群聊 bot 开关功能 |
|
|
157
|
+
| `defaultState` | `true` | 默认开启状态 |
|
|
158
|
+
| `disabledMessage` | *(见配置)* | 关闭状态下被 @ 时的提示 |
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
## 指令列表
|
|
163
|
+
|
|
164
|
+
所有管理员指令统一收纳在 `gc` 主指令下,输入 `gc` 可查看子指令列表。
|
|
165
|
+
|
|
166
|
+
### 管理员指令(gc 子指令,需全局管理员)
|
|
167
|
+
|
|
168
|
+
| 指令 | 说明 |
|
|
169
|
+
|------|------|
|
|
170
|
+
| `gc.banlist` | 查看黑名单列表 |
|
|
171
|
+
| `gc.ban <群号>` | 添加群到黑名单 |
|
|
172
|
+
| `gc.unban <群号>` | 从黑名单移除群 |
|
|
173
|
+
| `gc.clearban` | 清空黑名单 |
|
|
174
|
+
| `gc.sg-add <群号>` | 将群加入小群白名单,不受人数限制 |
|
|
175
|
+
| `gc.sg-rm <群号>` | 从小群白名单移除群 |
|
|
176
|
+
| `gc.sg-list` | 查看小群白名单 |
|
|
177
|
+
| `gc.approve <群号>` | 同意加入指定群 |
|
|
178
|
+
| `gc.reject <群号>` | 拒绝加入指定群 |
|
|
179
|
+
| `gc.pending` | 查看待处理的群聊邀请列表 |
|
|
180
|
+
| `gc.fa <QQ号>` | 同意好友申请 |
|
|
181
|
+
| `gc.fr <QQ号>` | 拒绝好友申请 |
|
|
182
|
+
| `gc.fp` | 查看待处理的好友申请列表 |
|
|
183
|
+
|
|
184
|
+
### 群聊管理
|
|
185
|
+
|
|
186
|
+
| 指令 | 说明 | 权限 |
|
|
187
|
+
|------|------|------|
|
|
188
|
+
| `quit` | 让 bot 退出当前群聊 | 群管理员 |
|
|
189
|
+
| `bot-on` | 开启当前群的 bot | 群管理员 |
|
|
190
|
+
| `bot-off` | 关闭当前群的 bot | 群管理员 |
|
|
191
|
+
|
|
192
|
+
---
|
|
193
|
+
|
|
194
|
+
## 注意事项
|
|
195
|
+
|
|
196
|
+
- 本插件仅支持 **OneBot 适配器**(如 go-cqhttp、LLOneBot 等)
|
|
197
|
+
- 管理员通知依赖 `admin.adminQQs` 或 `admin.notificationGroupId` 的配置,未配置则无法收到通知
|
|
198
|
+
- 频率控制的非指令拦截(@ 对话、私聊)不影响入群欢迎等系统事件
|
|
199
|
+
- 小群合格通知仅在启用了 `smallGroupAutoQuit` 且未经 `gc.approve` 审核通过的情况下触发
|