mioku 1.0.9 → 1.0.11
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/index.cjs +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/{exec-C3QTbHLt.js → exec-CqUKSOV5.js} +2 -2
- package/dist/{exec-BUUBQy_V.cjs.map → exec-CqUKSOV5.js.map} +1 -1
- package/dist/{exec-BUUBQy_V.cjs → exec-nby5LOiI.cjs} +2 -2
- package/dist/exec-nby5LOiI.cjs.map +1 -0
- package/dist/index.cjs +23 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +77 -26
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +77 -26
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +23 -18
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/exec-C3QTbHLt.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { buildSpawnPlan, commandExists, resolveCommand, runCommand, runCommandInherit, version } from "./exec-
|
|
1
|
+
import { buildSpawnPlan, commandExists, resolveCommand, runCommand, runCommandInherit, version } from "./exec-CqUKSOV5.js";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import * as fs$5 from "node:fs";
|
|
4
4
|
import * as fs$4 from "node:fs";
|
|
@@ -4107,17 +4107,19 @@ function triggerRestart(marker) {
|
|
|
4107
4107
|
function formatUptime(ms) {
|
|
4108
4108
|
return formatDuration(ms);
|
|
4109
4109
|
}
|
|
4110
|
-
async function waitForBot(timeoutMs = 6e4) {
|
|
4110
|
+
async function waitForBot(timeoutMs = 6e4, adapter, botId) {
|
|
4111
4111
|
const deadline = Date.now() + timeoutMs;
|
|
4112
4112
|
while (Date.now() < deadline) {
|
|
4113
4113
|
const bots = Array.from(connectedBots.values());
|
|
4114
|
-
|
|
4114
|
+
const matched = bots.find((bot) => (adapter ? bot.adapter === adapter : true) && (botId ? String(bot.bot_id) === botId : true));
|
|
4115
|
+
if (matched) return matched;
|
|
4116
|
+
if (!adapter && !botId && bots.length > 0) return bots[0];
|
|
4115
4117
|
await new Promise((resolve) => setTimeout(resolve, 2e3));
|
|
4116
4118
|
}
|
|
4117
4119
|
return null;
|
|
4118
4120
|
}
|
|
4119
4121
|
async function notifyRestartComplete(ctx, marker) {
|
|
4120
|
-
const bot = await waitForBot();
|
|
4122
|
+
const bot = await waitForBot(6e4, marker.adapter, marker.selfId);
|
|
4121
4123
|
if (!bot) {
|
|
4122
4124
|
rootLogger.warn("[core] 重启完成但未等到 bot 上线,跳过通知");
|
|
4123
4125
|
return;
|
|
@@ -4150,9 +4152,10 @@ function getPendingMap() {
|
|
|
4150
4152
|
return state[RUNTIME_KEY];
|
|
4151
4153
|
}
|
|
4152
4154
|
function conversationKey(event) {
|
|
4153
|
-
const selfId =
|
|
4154
|
-
|
|
4155
|
-
return `${selfId}:
|
|
4155
|
+
const selfId = String(event?.self_id ?? "");
|
|
4156
|
+
const adapter = String(event?.bot?.adapter ?? "");
|
|
4157
|
+
if (event?.message_type === "group" && event?.group_id) return `${adapter}:${selfId}:g:${String(event.group_id)}`;
|
|
4158
|
+
return `${adapter}:${selfId}:p:${String(event?.user_id ?? "")}`;
|
|
4156
4159
|
}
|
|
4157
4160
|
function typeLabel$1(type) {
|
|
4158
4161
|
if (type === "plugin") return "plugin";
|
|
@@ -4213,14 +4216,15 @@ async function performUpdateAndReport(ctx, event, names) {
|
|
|
4213
4216
|
if (unchanged.length > 0) parts.push("", `另有 ${unchanged.length} 个包已是最新`);
|
|
4214
4217
|
parts.push("", "即将重启...");
|
|
4215
4218
|
await replyText(event, parts.join("\n"));
|
|
4216
|
-
const selfId =
|
|
4217
|
-
const groupId = event?.message_type === "group" && event?.group_id ?
|
|
4218
|
-
const userId =
|
|
4219
|
+
const selfId = String(event?.self_id ?? "");
|
|
4220
|
+
const groupId = event?.message_type === "group" && event?.group_id ? String(event.group_id) : null;
|
|
4221
|
+
const userId = String(event?.user_id ?? "");
|
|
4219
4222
|
const marker = {
|
|
4220
4223
|
initiatedAt: Date.now(),
|
|
4221
4224
|
selfId,
|
|
4222
4225
|
groupId,
|
|
4223
|
-
userId
|
|
4226
|
+
userId,
|
|
4227
|
+
adapter: event?.bot?.adapter
|
|
4224
4228
|
};
|
|
4225
4229
|
triggerRestart(marker);
|
|
4226
4230
|
}
|
|
@@ -4477,16 +4481,17 @@ function registerRestartCommand(ctx) {
|
|
|
4477
4481
|
priority: -1e3,
|
|
4478
4482
|
description: "重启机器人进程",
|
|
4479
4483
|
handler: async ({ event }) => {
|
|
4480
|
-
if (event?.user_id === event?.self_id) return;
|
|
4484
|
+
if (String(event?.user_id ?? "") === String(event?.self_id ?? "")) return;
|
|
4481
4485
|
const uptimeMs = process.uptime() * 1e3;
|
|
4482
|
-
const selfId =
|
|
4483
|
-
const groupId = event?.message_type === "group" && event?.group_id ?
|
|
4484
|
-
const userId =
|
|
4486
|
+
const selfId = String(event?.self_id ?? "");
|
|
4487
|
+
const groupId = event?.message_type === "group" && event?.group_id ? String(event.group_id) : null;
|
|
4488
|
+
const userId = String(event?.user_id ?? "");
|
|
4485
4489
|
const marker = {
|
|
4486
4490
|
initiatedAt: Date.now(),
|
|
4487
4491
|
selfId,
|
|
4488
4492
|
groupId,
|
|
4489
|
-
userId
|
|
4493
|
+
userId,
|
|
4494
|
+
adapter: event?.bot?.adapter
|
|
4490
4495
|
};
|
|
4491
4496
|
try {
|
|
4492
4497
|
await replyText(event, `Bot已运行${formatUptime(uptimeMs)},正在重启...`);
|
|
@@ -4661,9 +4666,9 @@ function startAutoUpdateScheduler(enabled, time, frequency) {
|
|
|
4661
4666
|
rootLogger.info("[core] 自动更新成功,准备重启...");
|
|
4662
4667
|
const marker = {
|
|
4663
4668
|
initiatedAt: Date.now(),
|
|
4664
|
-
selfId:
|
|
4669
|
+
selfId: "",
|
|
4665
4670
|
groupId: null,
|
|
4666
|
-
userId:
|
|
4671
|
+
userId: ""
|
|
4667
4672
|
};
|
|
4668
4673
|
triggerRestart(marker);
|
|
4669
4674
|
} catch (error) {
|