koishi-plugin-maichuni-scorehelper 0.0.9-test → 0.0.11-test
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.
|
@@ -116,11 +116,15 @@ class MaimaiStatus extends koishi_1.Service {
|
|
|
116
116
|
this.clientLogger.warn('Failed to fetch heartbeat data.');
|
|
117
117
|
return;
|
|
118
118
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
119
|
+
const list = heartbeatData.heartbeatList;
|
|
120
|
+
if (!list) {
|
|
121
|
+
this.clientLogger.warn('Heartbeat data format invalid: list missing', Object.keys(heartbeatData));
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
// 3. 补充未知服务 ID
|
|
125
|
+
this.syncUnknownGroups(list);
|
|
122
126
|
// 4. 分析状态并处理通知
|
|
123
|
-
await this.analyzeAndNotify(
|
|
127
|
+
await this.analyzeAndNotify(list);
|
|
124
128
|
}
|
|
125
129
|
catch (e) {
|
|
126
130
|
this.clientLogger.error('Error in check task:', e);
|
|
@@ -284,7 +288,16 @@ class MaimaiStatus extends koishi_1.Service {
|
|
|
284
288
|
*/
|
|
285
289
|
async fetchHeartbeats() {
|
|
286
290
|
try {
|
|
287
|
-
|
|
291
|
+
let data = await this.ctx.http.get(this.API_URL);
|
|
292
|
+
// 如果不是对象,尝试解析 JSON (因为 Object.keys 打印出了索引,说明是字符串)
|
|
293
|
+
if (typeof data === 'string') {
|
|
294
|
+
try {
|
|
295
|
+
data = JSON.parse(data);
|
|
296
|
+
}
|
|
297
|
+
catch {
|
|
298
|
+
return null;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
288
301
|
// 返回原始对象,包含 heartbeatList 和 uptimeList
|
|
289
302
|
return data || {};
|
|
290
303
|
}
|
package/package.json
CHANGED
|
@@ -161,13 +161,18 @@ export class MaimaiStatus extends Service {
|
|
|
161
161
|
this.clientLogger.warn('Failed to fetch heartbeat data.')
|
|
162
162
|
return
|
|
163
163
|
}
|
|
164
|
+
|
|
165
|
+
const list = heartbeatData.heartbeatList
|
|
166
|
+
if (!list) {
|
|
167
|
+
this.clientLogger.warn('Heartbeat data format invalid: list missing', Object.keys(heartbeatData))
|
|
168
|
+
return
|
|
169
|
+
}
|
|
164
170
|
|
|
165
|
-
// 3. 补充未知服务 ID
|
|
166
|
-
|
|
167
|
-
this.syncUnknownGroups(heartbeatData.heartbeatList)
|
|
171
|
+
// 3. 补充未知服务 ID
|
|
172
|
+
this.syncUnknownGroups(list)
|
|
168
173
|
|
|
169
174
|
// 4. 分析状态并处理通知
|
|
170
|
-
await this.analyzeAndNotify(
|
|
175
|
+
await this.analyzeAndNotify(list)
|
|
171
176
|
|
|
172
177
|
} catch (e) {
|
|
173
178
|
this.clientLogger.error('Error in check task:', e)
|
|
@@ -341,7 +346,17 @@ export class MaimaiStatus extends Service {
|
|
|
341
346
|
*/
|
|
342
347
|
private async fetchHeartbeats(): Promise<any> {
|
|
343
348
|
try {
|
|
344
|
-
|
|
349
|
+
let data = await this.ctx.http.get(this.API_URL)
|
|
350
|
+
|
|
351
|
+
// 如果不是对象,尝试解析 JSON (因为 Object.keys 打印出了索引,说明是字符串)
|
|
352
|
+
if (typeof data === 'string') {
|
|
353
|
+
try {
|
|
354
|
+
data = JSON.parse(data)
|
|
355
|
+
} catch {
|
|
356
|
+
return null
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
|
|
345
360
|
// 返回原始对象,包含 heartbeatList 和 uptimeList
|
|
346
361
|
return data || {}
|
|
347
362
|
} catch (e) {
|