koishi-plugin-ggcevo 1.0.2 → 1.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 +1 -0
- package/lib/index.js +56 -2
- package/package.json +1 -1
- package/readme.md +16 -0
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -34,7 +34,8 @@ var name = "ggcevo";
|
|
|
34
34
|
var Config = import_koishi.Schema.object({
|
|
35
35
|
mapMonitorEnabled: import_koishi.Schema.boolean().description("是否启用地图检测定时任务").default(false),
|
|
36
36
|
mapMonitorGroups: import_koishi.Schema.array(import_koishi.Schema.string()).description("地图检测广播的群组ID列表").default([]),
|
|
37
|
-
mapMonitorMapIds: import_koishi.Schema.array(import_koishi.Schema.number()).description("需要检测的地图ID列表").default([])
|
|
37
|
+
mapMonitorMapIds: import_koishi.Schema.array(import_koishi.Schema.number()).description("需要检测的地图ID列表").default([]),
|
|
38
|
+
mapMonitorApiUrl: import_koishi.Schema.string().description("地图检测API地址").default("https://server.dreamprotocol.info:13085/mapmonitor/maps")
|
|
38
39
|
});
|
|
39
40
|
var inject = {
|
|
40
41
|
required: ["database"]
|
|
@@ -185,7 +186,7 @@ function apply(ctx, config) {
|
|
|
185
186
|
if (config.mapMonitorEnabled && config.mapMonitorGroups.length > 0 && config.mapMonitorMapIds.length > 0) {
|
|
186
187
|
ctx.setInterval(async () => {
|
|
187
188
|
try {
|
|
188
|
-
const response = await ctx.http.get(
|
|
189
|
+
const response = await ctx.http.get(config.mapMonitorApiUrl);
|
|
189
190
|
const maps = response.maps || [];
|
|
190
191
|
for (const mapId of config.mapMonitorMapIds) {
|
|
191
192
|
const mapData = maps.find((m) => m.mapId === mapId);
|
|
@@ -435,6 +436,59 @@ ${message}
|
|
|
435
436
|
return "⚠️ 服务器繁忙, 请稍后尝试。";
|
|
436
437
|
}
|
|
437
438
|
});
|
|
439
|
+
ctx.command("sc2arcade/地图检测", "查询已配置的地图详细信息").action(async (argv) => {
|
|
440
|
+
if (!config.mapMonitorEnabled || config.mapMonitorMapIds.length === 0) {
|
|
441
|
+
return `<quote id="${argv.session.messageId}"/>⚠️ 地图检测功能未开启或未配置地图ID。`;
|
|
442
|
+
}
|
|
443
|
+
try {
|
|
444
|
+
const response = await ctx.http.get(config.mapMonitorApiUrl);
|
|
445
|
+
const maps = response.maps || [];
|
|
446
|
+
const targetMaps = maps.filter((m) => config.mapMonitorMapIds.includes(m.mapId));
|
|
447
|
+
if (targetMaps.length === 0) {
|
|
448
|
+
return `<quote id="${argv.session.messageId}"/>📭 未找到已配置的地图信息。`;
|
|
449
|
+
}
|
|
450
|
+
const fieldLabels = {
|
|
451
|
+
mapName: "地图名称",
|
|
452
|
+
isOnline: "在线状态",
|
|
453
|
+
lastStatusChangeTime: "最后状态变更时间",
|
|
454
|
+
offlineCountLast24h: "24h内离线次数",
|
|
455
|
+
offlineCountLast30d: "30d内离线次数",
|
|
456
|
+
recentEvents: "近期事件"
|
|
457
|
+
};
|
|
458
|
+
const timeFields = ["lastStatusChangeTime"];
|
|
459
|
+
const messages = targetMaps.map((mapData) => {
|
|
460
|
+
const lines = [];
|
|
461
|
+
lines.push("━━━━━━━━━━━━━━━━");
|
|
462
|
+
lines.push(`📋 ${mapData.mapName || "未知地图"} (ID: ${mapData.mapId})`);
|
|
463
|
+
for (const key of Object.keys(mapData)) {
|
|
464
|
+
if (key === "mapId" || key === "mapName") continue;
|
|
465
|
+
if (key === "lastCheckTime" || key === "firstSeenTime" || key === "popularityRank") continue;
|
|
466
|
+
const value = mapData[key];
|
|
467
|
+
if (value !== null && value !== void 0 && value !== "") {
|
|
468
|
+
const label = fieldLabels[key] || key;
|
|
469
|
+
let displayValue;
|
|
470
|
+
if (key === "isOnline") {
|
|
471
|
+
displayValue = value ? "🟢 在线" : "🔴 离线";
|
|
472
|
+
} else if (key === "recentEvents") {
|
|
473
|
+
displayValue = formatRecentEvents(value);
|
|
474
|
+
} else if (timeFields.includes(key)) {
|
|
475
|
+
displayValue = toBeijingTime(value);
|
|
476
|
+
} else if (typeof value === "object") {
|
|
477
|
+
displayValue = JSON.stringify(value);
|
|
478
|
+
} else {
|
|
479
|
+
displayValue = String(value);
|
|
480
|
+
}
|
|
481
|
+
lines.push(` ${label}: ${displayValue}`);
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
return lines.join("\n");
|
|
485
|
+
});
|
|
486
|
+
return `<quote id="${argv.session.messageId}"/>${messages.join("\n")}`;
|
|
487
|
+
} catch (error) {
|
|
488
|
+
console.error("查询地图检测信息失败:", error);
|
|
489
|
+
return "⚠️ 服务器繁忙, 请稍后尝试。";
|
|
490
|
+
}
|
|
491
|
+
});
|
|
438
492
|
ctx.command("ggcevo/签到").action(async (argv) => {
|
|
439
493
|
const session = argv.session;
|
|
440
494
|
const handle = await getHandle(session);
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -24,6 +24,7 @@ npm install koishi-plugin-ggcevo
|
|
|
24
24
|
| `mapMonitorEnabled` | `boolean` | `false` | 是否启用地图检测定时任务 |
|
|
25
25
|
| `mapMonitorGroups` | `string[]` | `[]` | 地图检测广播的群组 ID 列表 |
|
|
26
26
|
| `mapMonitorMapIds` | `number[]` | `[]` | 需要检测的地图 ID 列表 |
|
|
27
|
+
| `mapMonitorApiUrl` | `string` | `https://server.dreamprotocol.info:13085/mapmonitor/maps` | 地图检测 API 地址 |
|
|
27
28
|
|
|
28
29
|
## 指令列表
|
|
29
30
|
|
|
@@ -36,6 +37,7 @@ npm install koishi-plugin-ggcevo
|
|
|
36
37
|
| `切换 [index]` | — | 切换正在使用的游戏句柄 |
|
|
37
38
|
| `查询 [handle]` | — | 查询某游戏句柄是否已被绑定 |
|
|
38
39
|
| `解绑 [index]` | 解绑句柄 | 解除绑定某个游戏句柄 |
|
|
40
|
+
| `地图检测` | — | 查询已配置地图(`mapMonitorMapIds`)的检测状态:在线状态、最后状态变更时间、24h/30d离线次数、近期事件。需开启 `mapMonitorEnabled` 且配置地图ID |
|
|
39
41
|
|
|
40
42
|
### 签到与虚拟物品(ggcevo)
|
|
41
43
|
|
|
@@ -94,6 +96,20 @@ npm install koishi-plugin-ggcevo
|
|
|
94
96
|
|
|
95
97
|
## 更新日志
|
|
96
98
|
|
|
99
|
+
### v1.0.4
|
|
100
|
+
|
|
101
|
+
- 新增配置项 `mapMonitorApiUrl`,可将地图检测的 API 地址通过配置项填写,默认值为 `https://server.dreamprotocol.info:13085/mapmonitor/maps`。
|
|
102
|
+
- 移除定时任务与「地图检测」指令中硬编码的 API 地址,改为读取 `mapMonitorApiUrl` 配置。
|
|
103
|
+
|
|
104
|
+
### v1.0.3
|
|
105
|
+
|
|
106
|
+
- 复原「地图检测」指令(命名空间 `sc2arcade/地图检测`),查询已配置地图的检测状态(在线状态、最后状态变更时间、24h/30d 离线次数、近期事件)。原被删除的是「地图检测调试」指令,本次仅复原正常地图检测指令。
|
|
107
|
+
- 清理未使用的工具函数:`profilesMatches`、`profilesMostPlayed`、`mapsplayerbase`、`lobbiesActive`、`lobbiesHistory`、`convertDateTimeFormat`、`makeHttpRequest`。
|
|
108
|
+
|
|
109
|
+
### v1.0.2
|
|
110
|
+
|
|
111
|
+
- 移除未使用的 `sc2arcade_map` 数据库模型及相关代码(该表无任何调用)。
|
|
112
|
+
|
|
97
113
|
### v1.0.1
|
|
98
114
|
|
|
99
115
|
- 移除绑定句柄时的在线检测判定(不再调用 `api.sc2arcade.com` 校验句柄是否存在),仅保留本地重复绑定校验。
|