mioki 0.9.3 → 0.10.0
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/dist/cli.cjs +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/index.cjs +10 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -3
- package/dist/index.d.mts +5 -3
- package/dist/index.mjs +12 -9
- package/dist/index.mjs.map +1 -1
- package/dist/{package-BDo4MHDy.cjs → package-C9ZLKmlF.cjs} +2 -2
- package/dist/package-C9ZLKmlF.cjs.map +1 -0
- package/dist/package-HADFnNFP.mjs +6 -0
- package/dist/package-HADFnNFP.mjs.map +1 -0
- package/package.json +2 -2
- package/dist/package-BDo4MHDy.cjs.map +0 -1
- package/dist/package-LmjT9AeF.mjs +0 -6
- package/dist/package-LmjT9AeF.mjs.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -583,9 +583,11 @@ interface MiokiStatus {
|
|
|
583
583
|
//#region src/builtins/core/index.d.ts
|
|
584
584
|
interface MiokiCoreServiceContrib {
|
|
585
585
|
/** 获取框架和系统的实时状态 */
|
|
586
|
-
|
|
587
|
-
/**
|
|
588
|
-
|
|
586
|
+
getMiokiStatus(): Promise<MiokiStatus>;
|
|
587
|
+
/** 格式化框架状态字符串 */
|
|
588
|
+
formatMiokiStatus(status: MiokiStatus): Promise<string>;
|
|
589
|
+
/** 自定义框架状态格式化函数 */
|
|
590
|
+
customFormatMiokiStatus(formatter: (status: MiokiStatus) => string | Promise<string>): void;
|
|
589
591
|
}
|
|
590
592
|
declare namespace services_d_exports {
|
|
591
593
|
export { MiokiServices, addService, services };
|
package/dist/index.d.mts
CHANGED
|
@@ -581,9 +581,11 @@ interface MiokiStatus {
|
|
|
581
581
|
//#region src/builtins/core/index.d.ts
|
|
582
582
|
interface MiokiCoreServiceContrib {
|
|
583
583
|
/** 获取框架和系统的实时状态 */
|
|
584
|
-
|
|
585
|
-
/**
|
|
586
|
-
|
|
584
|
+
getMiokiStatus(): Promise<MiokiStatus>;
|
|
585
|
+
/** 格式化框架状态字符串 */
|
|
586
|
+
formatMiokiStatus(status: MiokiStatus): Promise<string>;
|
|
587
|
+
/** 自定义框架状态格式化函数 */
|
|
588
|
+
customFormatMiokiStatus(formatter: (status: MiokiStatus) => string | Promise<string>): void;
|
|
587
589
|
}
|
|
588
590
|
declare namespace services_d_exports {
|
|
589
591
|
export { MiokiServices, addService, services };
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __export } from "./chunk-DYZpOiH0.mjs";
|
|
2
|
-
import { t as version } from "./package-
|
|
2
|
+
import { t as version } from "./package-HADFnNFP.mjs";
|
|
3
3
|
import fs, { default as fs$1 } from "node:fs";
|
|
4
4
|
import util from "node:util";
|
|
5
5
|
import path, { default as path$1 } from "node:path";
|
|
@@ -11,7 +11,7 @@ import { createJiti } from "jiti";
|
|
|
11
11
|
import { string2argv, string2argv as string2argv$1 } from "string2argv";
|
|
12
12
|
import { fileURLToPath } from "node:url";
|
|
13
13
|
import { NapCat, segment } from "napcat-sdk";
|
|
14
|
-
import
|
|
14
|
+
import prettyMs from "pretty-ms";
|
|
15
15
|
import { filesize } from "filesize";
|
|
16
16
|
import dayjs from "dayjs";
|
|
17
17
|
import dedent from "dedent";
|
|
@@ -1392,8 +1392,8 @@ async function getMiokiStatus(bot) {
|
|
|
1392
1392
|
}
|
|
1393
1393
|
};
|
|
1394
1394
|
}
|
|
1395
|
-
async function
|
|
1396
|
-
const { bot, plugins, stats, system, disk, cpu, memory, versions } =
|
|
1395
|
+
async function formatMiokiStatus(status) {
|
|
1396
|
+
const { bot, plugins, stats, system, disk, cpu, memory, versions } = status;
|
|
1397
1397
|
const diskValid = disk.total > 0 && disk.free >= 0;
|
|
1398
1398
|
const diskDesc = `${disk.percent}%-${filesize(disk.used, { round: 1 })}/${filesize(disk.total, { round: 1 })}`;
|
|
1399
1399
|
return `
|
|
@@ -1403,7 +1403,7 @@ async function getMiokiStatusStr(client) {
|
|
|
1403
1403
|
🧩 启用了 ${localNum(plugins.enabled)} 个插件,共 ${localNum(plugins.total)} 个
|
|
1404
1404
|
📮 收 ${localNum(stats.receive)} 条,发 ${localNum(stats.send)} 条
|
|
1405
1405
|
🚀 ${filesize(memory.rss.used, { round: 1 })}/${memory.percent}%
|
|
1406
|
-
⏳ 已运行 ${
|
|
1406
|
+
⏳ 已运行 ${prettyMs(stats.uptime, {
|
|
1407
1407
|
hideYear: true,
|
|
1408
1408
|
secondsDecimalDigits: 0
|
|
1409
1409
|
})}
|
|
@@ -1484,15 +1484,18 @@ const core = definePlugin({
|
|
|
1484
1484
|
const cmdPrefix = /* @__PURE__ */ new RegExp(`^${prefix}`);
|
|
1485
1485
|
const displayPrefix = prefix.replace(/\\\\/g, "\\");
|
|
1486
1486
|
const statusAdminOnly = ctx.botConfig.status_permission === "admin-only";
|
|
1487
|
-
|
|
1488
|
-
ctx.addService("
|
|
1489
|
-
ctx.addService("
|
|
1487
|
+
let statusFormatter = (status) => formatMiokiStatus(status);
|
|
1488
|
+
ctx.addService("getMiokiStatus", () => getMiokiStatus(ctx.bot));
|
|
1489
|
+
ctx.addService("formatMiokiStatus", formatMiokiStatus);
|
|
1490
|
+
ctx.addService("customFormatMiokiStatus", (formatter) => {
|
|
1491
|
+
statusFormatter = formatter;
|
|
1492
|
+
});
|
|
1490
1493
|
ctx.handle("message", (e) => ctx.runWithErrorHandler(async () => {
|
|
1491
1494
|
const text$1 = ctx.text(e);
|
|
1492
1495
|
if (!cmdPrefix.test(text$1)) return;
|
|
1493
1496
|
if (statusAdminOnly && !ctx.hasRight(e)) return;
|
|
1494
1497
|
if (text$1.replace(cmdPrefix, "") === "状态") {
|
|
1495
|
-
const status = await
|
|
1498
|
+
const status = await statusFormatter(await getMiokiStatus(ctx.bot));
|
|
1496
1499
|
await e.reply(`〓 🟢 mioki 状态 〓\n${status}`.trim());
|
|
1497
1500
|
return;
|
|
1498
1501
|
}
|