koishi-plugin-minecraft-search 2.0.3 → 2.0.5
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 +0 -1
- package/lib/index.js +7 -33
- package/package.json +1 -1
- package/readme.md +12 -7
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -50,9 +50,9 @@ var Config = import_koishi.Schema.intersect([
|
|
|
50
50
|
showIpInDetail: import_koishi.Schema.boolean().default(true).description("在查询详细状态时显示服务器IP地址")
|
|
51
51
|
}).description("显示配置"),
|
|
52
52
|
import_koishi.Schema.object({
|
|
53
|
-
enablePermissionCheck: import_koishi.Schema.boolean().default(
|
|
54
|
-
allowMemberPowerCommands: import_koishi.Schema.boolean().default(
|
|
55
|
-
}).description("
|
|
53
|
+
enablePermissionCheck: import_koishi.Schema.boolean().default(false).description("启用管理员权限检查"),
|
|
54
|
+
allowMemberPowerCommands: import_koishi.Schema.boolean().default(true).description("允许普通成员使用开服、重启、强制重启指令")
|
|
55
|
+
}).description("权限配置(仅限onebot机器人使用)")
|
|
56
56
|
]);
|
|
57
57
|
var inject = {
|
|
58
58
|
required: ["database"]
|
|
@@ -76,8 +76,7 @@ function apply(ctx, config) {
|
|
|
76
76
|
id: "unsigned",
|
|
77
77
|
userId: "string",
|
|
78
78
|
groupId: "string",
|
|
79
|
-
apiKey: "string"
|
|
80
|
-
allowMemberPowerCommands: "boolean"
|
|
79
|
+
apiKey: "string"
|
|
81
80
|
}, {
|
|
82
81
|
autoInc: true,
|
|
83
82
|
primary: "id"
|
|
@@ -174,17 +173,8 @@ function apply(ctx, config) {
|
|
|
174
173
|
if (!config2.enablePermissionCheck) {
|
|
175
174
|
return null;
|
|
176
175
|
}
|
|
177
|
-
if (isPowerCommand) {
|
|
178
|
-
|
|
179
|
-
const groupId = session.guildId;
|
|
180
|
-
const apiKeys = await ctx.database.get("minecraft_api_key", { groupId });
|
|
181
|
-
if (apiKeys && apiKeys.length > 0) {
|
|
182
|
-
const groupConfig = apiKeys[0];
|
|
183
|
-
if (groupConfig.allowMemberPowerCommands) {
|
|
184
|
-
return null;
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
}
|
|
176
|
+
if (isPowerCommand && config2.allowMemberPowerCommands) {
|
|
177
|
+
return null;
|
|
188
178
|
}
|
|
189
179
|
const memberInfo = session.event?.member?.roles;
|
|
190
180
|
if (!memberInfo || !memberInfo.some((role) => role.name === "admin" || role.name === "owner" || role.id === "admin" || role.id === "owner")) {
|
|
@@ -253,7 +243,7 @@ function apply(ctx, config) {
|
|
|
253
243
|
return message;
|
|
254
244
|
}
|
|
255
245
|
__name(formatDetailedStatus, "formatDetailedStatus");
|
|
256
|
-
ctx.command("mc/查服 [target:text]", "查询Minecraft服务器状态").action(async ({ session }, target) => {
|
|
246
|
+
ctx.guild().command("mc/查服 [target:text]", "查询Minecraft服务器状态").action(async ({ session }, target) => {
|
|
257
247
|
const servers = await ctx.database.get("minecraft_server", {});
|
|
258
248
|
if (target === void 0) {
|
|
259
249
|
if (servers.length === 0) {
|
|
@@ -585,22 +575,6 @@ ${parts.join("\n")}`;
|
|
|
585
575
|
await ctx.database.set("minecraft_server", { id }, { minekuaiInstanceId: instanceId });
|
|
586
576
|
return `✅ ${server.name} 的麦块实例ID已设置为: ${instanceId}`;
|
|
587
577
|
});
|
|
588
|
-
ctx.guild().command("mc/权限设置 <enabled:boolean>", "开启/关闭普通群成员使用开服、重启和强制重启指令").action(async ({ session }, enabled) => {
|
|
589
|
-
const permissionError = await checkPermission(session, config);
|
|
590
|
-
if (permissionError) {
|
|
591
|
-
return permissionError;
|
|
592
|
-
}
|
|
593
|
-
if (!config.allowMemberPowerCommands) {
|
|
594
|
-
return "❌ 请先在插件配置中开启「允许普通成员使用开服、重启、强制重启指令」选项";
|
|
595
|
-
}
|
|
596
|
-
const groupId = session.guildId;
|
|
597
|
-
const apiKeys = await ctx.database.get("minecraft_api_key", { groupId });
|
|
598
|
-
if (!apiKeys || apiKeys.length === 0) {
|
|
599
|
-
return "❌ 本群未配置麦块API密钥,请先使用 绑定密钥 指令";
|
|
600
|
-
}
|
|
601
|
-
await ctx.database.set("minecraft_api_key", { groupId }, { allowMemberPowerCommands: enabled });
|
|
602
|
-
return `✅ 已${enabled ? "开启" : "关闭"}普通群成员使用开服、重启和强制重启指令的权限`;
|
|
603
|
-
});
|
|
604
578
|
}
|
|
605
579
|
__name(apply, "apply");
|
|
606
580
|
// Annotate the CommonJS export names for ESM import in node:
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -54,8 +54,8 @@ npm install koishi-plugin-minecraft-search
|
|
|
54
54
|
{
|
|
55
55
|
"minekuaiApiUrl": "https://minekuai.com/api/client", // 麦块API地址
|
|
56
56
|
"showIpInDetail": true, // 是否在详细状态中显示IP地址
|
|
57
|
-
"enablePermissionCheck":
|
|
58
|
-
"allowMemberPowerCommands":
|
|
57
|
+
"enablePermissionCheck": false, // 启用管理员权限检查
|
|
58
|
+
"allowMemberPowerCommands": true // 允许普通成员使用开服、重启、强制重启指令
|
|
59
59
|
}
|
|
60
60
|
```
|
|
61
61
|
|
|
@@ -69,7 +69,6 @@ mc/修改 <id> [-n <name>] [-t <timeout>] [-i <instance>] # 修改服务器
|
|
|
69
69
|
mc/服务器列表 # 查看已绑定的服务器列表
|
|
70
70
|
mc/设置实例 <id> <instanceId> # 设置服务器的麦块实例ID
|
|
71
71
|
mc/绑定API密钥 <apiKey> # 绑定麦块API密钥
|
|
72
|
-
mc/权限设置 <enabled> # 开启/关闭普通群成员使用开服、重启和强制重启指令
|
|
73
72
|
```
|
|
74
73
|
|
|
75
74
|
### 查询服务器状态
|
|
@@ -141,7 +140,6 @@ mc/资源 1 # 查看ID为1的麦块服务器资源使用情况
|
|
|
141
140
|
- **`mc/修改 <id> [-n <name>] [-t <timeout>] [-i <instance>]`**:修改服务器名称、超时时间或麦块实例ID
|
|
142
141
|
- **`mc/设置实例 <id> <instanceId>`**:为服务器设置麦块实例ID,用于电源控制
|
|
143
142
|
- **`mc/服务器列表`**:查看当前群组已绑定的所有服务器
|
|
144
|
-
- **`mc/权限设置 <enabled>`**:开启/关闭普通群成员使用开服、重启和强制重启指令,需要先在插件配置中开启 `allowMemberPowerCommands` 选项
|
|
145
143
|
|
|
146
144
|
### 服务器控制指令
|
|
147
145
|
- **`mc/开服 <id>`**:启动指定服务器
|
|
@@ -157,7 +155,7 @@ mc/资源 1 # 查看ID为1的麦块服务器资源使用情况
|
|
|
157
155
|
- ⚡ **高性能查询**:支持并行查询多个服务器
|
|
158
156
|
- 🛡️ **错误处理**:完善的错误处理和用户提示
|
|
159
157
|
- 🗄️ **数据库存储**:使用数据库存储服务器配置,支持多群组管理
|
|
160
|
-
- 🔒
|
|
158
|
+
- 🔒 **权限控制**:支持全局权限管理,每个群组只能管理自己绑定的服务器,默认允许普通成员使用电源指令(可通过配置项调整)
|
|
161
159
|
- 🌐 **直接IP查询**:支持直接输入IP地址查询服务器状态
|
|
162
160
|
- 🔧 **实例ID管理**:支持在绑定和修改服务器时直接设置麦块实例ID
|
|
163
161
|
|
|
@@ -188,12 +186,19 @@ mc/资源 1 # 查看ID为1的麦块服务器资源使用情况
|
|
|
188
186
|
<details>
|
|
189
187
|
<summary>点我查看更新日志详情</summary>
|
|
190
188
|
|
|
189
|
+
### v2.0.5
|
|
190
|
+
- 调整权限检查配置项默认值:`enablePermissionCheck` 默认值改为 false,`allowMemberPowerCommands` 默认值改为 true
|
|
191
|
+
- 优化权限配置项的描述,明确权限配置仅适用于onebot机器人
|
|
192
|
+
|
|
193
|
+
### v2.0.4
|
|
194
|
+
- 简化权限检查功能,移除群组级别的权限设置
|
|
195
|
+
- 优化权限检查功能配置项描述,明确仅限onebot机器人使用
|
|
196
|
+
|
|
191
197
|
### v2.0.3
|
|
192
198
|
- 新增权限检查功能,支持全局权限控制
|
|
193
199
|
- 新增配置项 `enablePermissionCheck` 控制是否启用权限检查
|
|
194
200
|
- 新增配置项 `allowMemberPowerCommands` 控制是否允许普通成员使用电源指令
|
|
195
|
-
-
|
|
196
|
-
- 优化权限检查逻辑,支持群组级别的权限设置
|
|
201
|
+
- 优化权限检查逻辑
|
|
197
202
|
|
|
198
203
|
### v2.0.1
|
|
199
204
|
- 新增绑定服务器时支持 -i 选项直接设置麦块实例ID
|