koishi-plugin-minecraft-search 2.0.3 → 2.0.4

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 CHANGED
@@ -16,7 +16,6 @@ export interface ApiKeyConfig {
16
16
  userId: string;
17
17
  groupId: string;
18
18
  apiKey: string;
19
- allowMemberPowerCommands: boolean;
20
19
  }
21
20
  export interface Config {
22
21
  minekuaiApiUrl: string;
package/lib/index.js CHANGED
@@ -50,8 +50,8 @@ 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(true).description("启用权限检查"),
54
- allowMemberPowerCommands: import_koishi.Schema.boolean().default(false).description("允许普通成员使用开服、重启、强制重启指令")
53
+ enablePermissionCheck: import_koishi.Schema.boolean().default(true).description("启用管理员权限检查(仅限onebot机器人使用)"),
54
+ allowMemberPowerCommands: import_koishi.Schema.boolean().default(false).description("允许普通成员使用开服、重启、强制重启指令(仅限onebot机器人使用)")
55
55
  }).description("权限配置")
56
56
  ]);
57
57
  var inject = {
@@ -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
- if (config2.allowMemberPowerCommands) {
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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-minecraft-search",
3
3
  "description": "使用API查询基础的mc服务器信息",
4
- "version": "2.0.3",
4
+ "version": "2.0.4",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [
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": true, // 启用权限检查
58
- "allowMemberPowerCommands": false // 允许普通成员使用开服、重启、强制重启指令
57
+ "enablePermissionCheck": true, // 启用管理员权限检查(仅限onebot机器人使用)
58
+ "allowMemberPowerCommands": false // 允许普通成员使用开服、重启、强制重启指令(仅限onebot机器人使用)
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,15 @@ mc/资源 1 # 查看ID为1的麦块服务器资源使用情况
188
186
  <details>
189
187
  <summary>点我查看更新日志详情</summary>
190
188
 
189
+ ### v2.0.4
190
+ - 简化权限检查功能,移除群组级别的权限设置
191
+ - 优化权限检查功能配置项描述,明确仅限onebot机器人使用
192
+
191
193
  ### v2.0.3
192
194
  - 新增权限检查功能,支持全局权限控制
193
195
  - 新增配置项 `enablePermissionCheck` 控制是否启用权限检查
194
196
  - 新增配置项 `allowMemberPowerCommands` 控制是否允许普通成员使用电源指令
195
- - 新增 `mc/权限设置` 指令,用于每个群组独立控制普通成员权限
196
- - 优化权限检查逻辑,支持群组级别的权限设置
197
+ - 优化权限检查逻辑
197
198
 
198
199
  ### v2.0.1
199
200
  - 新增绑定服务器时支持 -i 选项直接设置麦块实例ID