mioku-plugin-help 3.0.1 → 3.0.3
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/package.json +1 -1
- package/status/data-collector.ts +59 -36
- package/status/html-generator.ts +4 -8
- package/status/types.ts +2 -0
package/package.json
CHANGED
package/status/data-collector.ts
CHANGED
|
@@ -200,8 +200,7 @@ async function collectBots(
|
|
|
200
200
|
}
|
|
201
201
|
// stdin 适配器恒排第一位(终端是本机主人通道,优先展示)
|
|
202
202
|
const sorted = [...bots].sort(
|
|
203
|
-
(a, b) =>
|
|
204
|
-
Number(b.adapter === "stdin") - Number(a.adapter === "stdin"),
|
|
203
|
+
(a, b) => Number(b.adapter === "stdin") - Number(a.adapter === "stdin"),
|
|
205
204
|
);
|
|
206
205
|
return collectBotStatuses(sorted, ctx, stdinAvatar);
|
|
207
206
|
}
|
|
@@ -226,11 +225,14 @@ async function collectBotStatuses(
|
|
|
226
225
|
version: adapter.version,
|
|
227
226
|
impl: adapter.impl,
|
|
228
227
|
}));
|
|
229
|
-
const report = await withTimeout(
|
|
230
|
-
(
|
|
231
|
-
);
|
|
228
|
+
const report = await withTimeout(
|
|
229
|
+
buildAdapterReport({ bots, adapters }),
|
|
230
|
+
).catch(() => null);
|
|
232
231
|
const instances = new Map<string, AdapterInstanceStatus>();
|
|
233
|
-
const implOf = new Map<
|
|
232
|
+
const implOf = new Map<
|
|
233
|
+
string,
|
|
234
|
+
{ name: string; version?: string } | undefined
|
|
235
|
+
>();
|
|
234
236
|
for (const entry of report?.adapters ?? []) {
|
|
235
237
|
implOf.set(entry.name, entry.impl);
|
|
236
238
|
for (const instance of entry.instances) {
|
|
@@ -238,37 +240,58 @@ async function collectBotStatuses(
|
|
|
238
240
|
}
|
|
239
241
|
}
|
|
240
242
|
|
|
241
|
-
return
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
243
|
+
return Promise.all(
|
|
244
|
+
bots.map(async (bot) => {
|
|
245
|
+
const uin = String(bot.bot_id);
|
|
246
|
+
const adapter = String(bot.adapter);
|
|
247
|
+
const isStdin = adapter === "stdin";
|
|
248
|
+
const instance = instances.get(`${adapter}:${uin}`);
|
|
249
|
+
const lib = implOf.get(adapter);
|
|
250
|
+
const framework = instance?.impl || lib?.name || adapter;
|
|
251
|
+
const appVersion = instance?.version || lib?.version || "";
|
|
252
|
+
const avatarFromBot =
|
|
253
|
+
typeof bot.getAvatar === "function"
|
|
254
|
+
? await bot.getAvatar().catch(() => null)
|
|
255
|
+
: null;
|
|
256
|
+
// 协议端版本文案:平台自报的用 impl/version(如 LLOneBot/7.12.4),
|
|
257
|
+
// 平台不自报的退回适配器元数据(如 ICQQ v1.12.3),与 .status 的展示约定一致
|
|
258
|
+
const implLabel = isStdin
|
|
259
|
+
? "stdin"
|
|
260
|
+
: instance?.impl
|
|
261
|
+
? instance.version
|
|
262
|
+
? `${instance.impl}/${instance.version}`
|
|
263
|
+
: String(instance.impl)
|
|
264
|
+
: lib?.name
|
|
265
|
+
? lib.version
|
|
266
|
+
? `${lib.name} v${lib.version}`
|
|
267
|
+
: lib.name
|
|
268
|
+
: "";
|
|
250
269
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
:
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
270
|
+
return {
|
|
271
|
+
uin,
|
|
272
|
+
nickname: String(bot.nickname || "Unknown Bot"),
|
|
273
|
+
avatarUrl: isStdin
|
|
274
|
+
? toImageSrc(stdinAvatar || "")
|
|
275
|
+
: avatarFromBot
|
|
276
|
+
? toImageSrc(avatarFromBot)
|
|
277
|
+
: `https://q1.qlogo.cn/g?b=qq&nk=${uin}&s=160`,
|
|
278
|
+
adapter,
|
|
279
|
+
implLabel,
|
|
280
|
+
framework: isStdin ? adapter : framework,
|
|
281
|
+
appVersion: isStdin
|
|
282
|
+
? String(ctx.getAdapter(adapter)?.version ?? "")
|
|
283
|
+
: appVersion,
|
|
284
|
+
protocolVersion: instance?.protocol ?? "",
|
|
285
|
+
platform: instance?.platform ?? "",
|
|
286
|
+
platformVersion: instance?.platformVersion ?? "",
|
|
287
|
+
online: bot.online,
|
|
288
|
+
groupCount: instance?.stats.groups ?? 0,
|
|
289
|
+
friendCount: instance?.stats.friends ?? 0,
|
|
290
|
+
send: instance?.stats.sent ?? 0,
|
|
291
|
+
receive: instance?.stats.received ?? 0,
|
|
292
|
+
};
|
|
293
|
+
}),
|
|
294
|
+
);
|
|
272
295
|
}
|
|
273
296
|
|
|
274
297
|
async function collectFramework(
|
package/status/html-generator.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { escapeHtml } from "../utils";
|
|
2
2
|
import { getHelpTheme, HELP_BACKGROUND_IMAGE_URL } from "../theme";
|
|
3
|
+
import { displayAdapterId } from "mioku";
|
|
3
4
|
import type {
|
|
4
5
|
AIUsageStatsLite,
|
|
5
6
|
BotAccountStatus,
|
|
@@ -139,25 +140,20 @@ function renderHero(
|
|
|
139
140
|
.map((bot) => {
|
|
140
141
|
const statusText = bot.online ? "在线" : "离线";
|
|
141
142
|
const statusColor = bot.online ? "#10b981" : "#ef4444";
|
|
142
|
-
const implText =
|
|
143
|
-
bot.adapter === "stdin"
|
|
144
|
-
? `${bot.adapter}@${bot.appVersion}`
|
|
145
|
-
: bot.appVersion
|
|
146
|
-
? `${bot.framework} ${bot.appVersion}${bot.protocolVersion ? ` · 协议 ${bot.protocolVersion}` : ""}`
|
|
147
|
-
: bot.framework;
|
|
143
|
+
const implText = bot.implLabel;
|
|
148
144
|
const platformText = bot.platform
|
|
149
145
|
? `${bot.platform}${bot.platformVersion ? ` v${bot.platformVersion}` : ""}`
|
|
150
146
|
: "";
|
|
151
147
|
// Nickname is rendered as a bold large heading above the avatar
|
|
152
148
|
// row (not as a chip). Chips below only carry the metadata.
|
|
153
149
|
const tags = [
|
|
154
|
-
{ text:
|
|
150
|
+
{ text: displayAdapterId(bot.uin) || "—", kind: "data" },
|
|
155
151
|
{ text: statusText, kind: bot.online ? "ok" : "danger" },
|
|
156
152
|
{ text: `好友 ${fmtNumber(bot.friendCount)}`, kind: "data" },
|
|
157
153
|
{ text: `群聊 ${fmtNumber(bot.groupCount)}`, kind: "data" },
|
|
158
154
|
{ text: `收 ${fmtNumber(bot.receive)}`, kind: "data" },
|
|
159
155
|
{ text: `发 ${fmtNumber(bot.send)}`, kind: "data" },
|
|
160
|
-
{ text: implText, kind: "data" },
|
|
156
|
+
...(implText ? [{ text: implText, kind: "data" }] : []),
|
|
161
157
|
...(platformText ? [{ text: platformText, kind: "data" }] : []),
|
|
162
158
|
];
|
|
163
159
|
const tagsHtml = tags
|
package/status/types.ts
CHANGED
|
@@ -13,6 +13,8 @@ export interface BotAccountStatus {
|
|
|
13
13
|
avatarUrl: string;
|
|
14
14
|
/** 适配器名,如 "stdin" / "onebotv11" / "icqq"。 */
|
|
15
15
|
adapter: string;
|
|
16
|
+
/** 协议端与版本的可展示文案,如 "ICQQ v1.12.3" / "LLOneBot/7.12.4",取不到时为空串 */
|
|
17
|
+
implLabel: string;
|
|
16
18
|
/** 实现端名称,如 "NapCat" / "LLOneBot" / "ICQQ",取不到时为空串 */
|
|
17
19
|
framework: string;
|
|
18
20
|
/** 实现端版本,如 "5.0.6"*/
|