koishi-plugin-group-control 0.1.1 → 0.1.3
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 +9 -1
- package/package.json +2 -1
package/lib/index.js
CHANGED
|
@@ -33,7 +33,7 @@ var Config = import_koishi.Schema.intersect([
|
|
|
33
33
|
welcomeMessage: import_koishi.Schema.string().default("你好,我是机器人。感谢邀请我加入!").description("机器人加入群聊时发送的欢迎消息"),
|
|
34
34
|
blacklistMessage: import_koishi.Schema.string().default("此群聊已被拉黑,机器人将自动退出,请联系管理员移出黑名单。").description("被拉入黑名单群后在群内发送的提示"),
|
|
35
35
|
quitMessage: import_koishi.Schema.string().default("收到来自{userId}的指令,即将退出群聊。").description("用户发送quit指令后在群内发送的提示,支持变量{userId}"),
|
|
36
|
-
enableBlacklist: import_koishi.Schema.boolean().default(true).description("
|
|
36
|
+
enableBlacklist: import_koishi.Schema.boolean().default(true).description('启用"被踢出自动拉黑"功能'),
|
|
37
37
|
quitCommandEnabled: import_koishi.Schema.boolean().default(true).description("启用quit"),
|
|
38
38
|
quitCommandAuthority: import_koishi.Schema.number().default(3).description("quit指令所需权限")
|
|
39
39
|
}).description("基础群组管理")
|
|
@@ -111,6 +111,7 @@ function isCurrentlyBlocked(record) {
|
|
|
111
111
|
}
|
|
112
112
|
__name(isCurrentlyBlocked, "isCurrentlyBlocked");
|
|
113
113
|
function apply(ctx, config) {
|
|
114
|
+
const quittingGuilds = /* @__PURE__ */ new Set();
|
|
114
115
|
ctx.model.extend("blacklisted_guild", {
|
|
115
116
|
platform: "string",
|
|
116
117
|
guildId: "string",
|
|
@@ -165,6 +166,11 @@ function apply(ctx, config) {
|
|
|
165
166
|
if (!config.basic.enableBlacklist) {
|
|
166
167
|
return;
|
|
167
168
|
}
|
|
169
|
+
const quittingKey = `${platform}:${guildId}`;
|
|
170
|
+
if (quittingGuilds.has(quittingKey)) {
|
|
171
|
+
quittingGuilds.delete(quittingKey);
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
168
174
|
await ctx.model.upsert("blacklisted_guild", [{
|
|
169
175
|
platform,
|
|
170
176
|
guildId,
|
|
@@ -303,6 +309,7 @@ function apply(ctx, config) {
|
|
|
303
309
|
ctx.command("quit", "让机器人主动退出当前群聊", { authority: config.basic.quitCommandAuthority }).action(async ({ session }) => {
|
|
304
310
|
if (!session.guildId) return "quit 指令只能在群聊中使用。";
|
|
305
311
|
const { guildId, platform, userId } = session;
|
|
312
|
+
quittingGuilds.add(`${platform}:${guildId}`);
|
|
306
313
|
const message = config.basic.quitMessage.replace("{userId}", userId);
|
|
307
314
|
try {
|
|
308
315
|
await session.bot.sendMessage(session.guildId, message, platform);
|
|
@@ -312,6 +319,7 @@ function apply(ctx, config) {
|
|
|
312
319
|
try {
|
|
313
320
|
await session.bot.internal.setGroupLeave(parseInt(guildId));
|
|
314
321
|
} catch (leaveError) {
|
|
322
|
+
quittingGuilds.delete(`${platform}:${guildId}`);
|
|
315
323
|
console.error("退出群聊失败:", leaveError);
|
|
316
324
|
const failMessage = `退出失败: ${leaveError.message || "OneBot API 调用失败"}`;
|
|
317
325
|
try {
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koishi-plugin-group-control",
|
|
3
3
|
"description": "Koishi群聊自管理插件,支持自定义机器人进群消息、被踢出自动拉黑、刷屏自动屏蔽功能和主动退群指令。(仅支持OneBot适配器)",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.3",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
7
7
|
"files": [
|
|
8
8
|
"lib",
|
|
9
9
|
"dist"
|
|
10
10
|
],
|
|
11
|
+
"homepage": "https://github.com/muyni233/koishi-plugin-group-control",
|
|
11
12
|
"license": "MIT",
|
|
12
13
|
"keywords": [
|
|
13
14
|
"chatbot",
|