koishi-plugin-minecraft-search 1.3.8 → 1.3.9
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 +1 -0
- package/lib/index.js +16 -7
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -57,7 +57,10 @@ var Config = import_koishi.Schema.intersect([
|
|
|
57
57
|
apiUrl: import_koishi.Schema.string().description("麦块API地址").default("https://minekuai.com/api/client"),
|
|
58
58
|
apiKey: import_koishi.Schema.string().description("麦块API密钥")
|
|
59
59
|
})
|
|
60
|
-
}).description("麦块联机配置(可选)")
|
|
60
|
+
}).description("麦块联机配置(可选)"),
|
|
61
|
+
import_koishi.Schema.object({
|
|
62
|
+
showIpInDetail: import_koishi.Schema.boolean().default(true).description("在查询详细状态时显示服务器IP地址")
|
|
63
|
+
}).description("显示配置")
|
|
61
64
|
]);
|
|
62
65
|
function apply(ctx, config) {
|
|
63
66
|
function parseServerAddress(hostString, defaultPort) {
|
|
@@ -151,9 +154,13 @@ function apply(ctx, config) {
|
|
|
151
154
|
return `🟢 ${server.name} - 在线 | 玩家: ${players} | 版本: ${version}`;
|
|
152
155
|
}
|
|
153
156
|
__name(formatShortStatus, "formatShortStatus");
|
|
154
|
-
function formatDetailedStatus(result, server) {
|
|
157
|
+
function formatDetailedStatus(result, server, showIp) {
|
|
155
158
|
if (!result.online) {
|
|
156
|
-
|
|
159
|
+
if (showIp) {
|
|
160
|
+
return `🔴 服务器 ${server.name} (${server.host}) 当前离线`;
|
|
161
|
+
} else {
|
|
162
|
+
return `🔴 服务器 ${server.name} 当前离线`;
|
|
163
|
+
}
|
|
157
164
|
}
|
|
158
165
|
let motdText = "暂无描述";
|
|
159
166
|
if (result.description) {
|
|
@@ -172,12 +179,14 @@ function apply(ctx, config) {
|
|
|
172
179
|
descriptionStr = descriptionStr.replace(/§[0-9a-fk-or]/gi, "");
|
|
173
180
|
motdText = descriptionStr.replace(/\n/g, " ").replace(/\s+/g, " ").trim();
|
|
174
181
|
}
|
|
175
|
-
const defaultPort = server.serverType === "bedrock" ? 19132 : 25565;
|
|
176
|
-
const { host, port } = parseServerAddress(server.host, defaultPort);
|
|
177
182
|
let message = `🟢 ${server.name} 状态信息
|
|
178
183
|
`;
|
|
179
|
-
|
|
184
|
+
if (showIp) {
|
|
185
|
+
const defaultPort = server.serverType === "bedrock" ? 19132 : 25565;
|
|
186
|
+
const { host, port } = parseServerAddress(server.host, defaultPort);
|
|
187
|
+
message += `📡 地址: ${host}:${port}
|
|
180
188
|
`;
|
|
189
|
+
}
|
|
181
190
|
message += `🎮 类型: ${server.serverType || "Java"}
|
|
182
191
|
`;
|
|
183
192
|
if (result.version) {
|
|
@@ -233,7 +242,7 @@ function apply(ctx, config) {
|
|
|
233
242
|
if (!result.success) {
|
|
234
243
|
return `🔴 服务器 ${server.name} - 离线 | 原因:${result.error}`;
|
|
235
244
|
}
|
|
236
|
-
return formatDetailedStatus(result.data, server);
|
|
245
|
+
return formatDetailedStatus(result.data, server, config.showIpInDetail);
|
|
237
246
|
});
|
|
238
247
|
ctx.command("mc/开服 <id:number>", "启动麦块服务器").action(async ({ session }, id) => {
|
|
239
248
|
if (!id) return "请提供服务器ID,例如:开服 1";
|