llonebot-dist 8.0.4 → 8.0.5

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/llbot.js CHANGED
@@ -20669,7 +20669,7 @@ var OB11HeartbeatEvent = class extends OB11BaseMetaEvent {
20669
20669
  };
20670
20670
  //#endregion
20671
20671
  //#region src/version.ts
20672
- var version$3 = "8.0.4";
20672
+ var version$3 = "8.0.5";
20673
20673
  //#endregion
20674
20674
  //#region node_modules/sift/es5m/index.js
20675
20675
  /******************************************************************************
@@ -73522,7 +73522,6 @@ var DirectProtocolClient = class extends EventEmitter {
73522
73522
  await this.ensureSignSetup();
73523
73523
  if (!this.signPreflighted && this.config.authToken) {
73524
73524
  this.signPreflighted = true;
73525
- console.log("[Sign] preflightSign() 被调用 -- 只有 direct 模式 connect 会到这里, PMHQ 模式不该出现这行");
73526
73525
  const reason = await preflightSign();
73527
73526
  if (reason) throw new Error(`sign preflight failed: ${reason}`);
73528
73527
  }
@@ -74666,7 +74665,7 @@ function getCurrentLoginState() {
74666
74665
  }
74667
74666
  function startIpcServer() {
74668
74667
  const pipeName = process.env.LL_IPC_PIPE;
74669
- if (!pipeName || process.platform !== "win32") return;
74668
+ if (!pipeName) return;
74670
74669
  if (server) return;
74671
74670
  server = net.createServer((socket) => {
74672
74671
  socket.setEncoding("utf8");
@@ -74682,13 +74681,36 @@ function startIpcServer() {
74682
74681
  });
74683
74682
  socket.on("error", () => {});
74684
74683
  });
74685
- const pipePath = `\\\\.\\pipe\\${pipeName}`;
74686
- server.listen(pipePath, () => {
74687
- console.log(`[LL_IPC] listening on ${pipePath}`);
74684
+ let listenPath;
74685
+ if (process.platform === "win32") listenPath = `\\\\.\\pipe\\${pipeName}`;
74686
+ else {
74687
+ listenPath = pipeName;
74688
+ try {
74689
+ fs$2.unlinkSync(listenPath);
74690
+ } catch {}
74691
+ }
74692
+ server.listen(listenPath, () => {
74693
+ console.log(`[LL_IPC] listening on ${listenPath}`);
74688
74694
  });
74689
74695
  server.on("error", (e) => {
74690
74696
  console.warn(`[LL_IPC] server error: ${e.message}`);
74691
74697
  });
74698
+ if (process.platform !== "win32") {
74699
+ const cleanup = () => {
74700
+ try {
74701
+ fs$2.unlinkSync(listenPath);
74702
+ } catch {}
74703
+ };
74704
+ process.once("exit", cleanup);
74705
+ process.once("SIGINT", () => {
74706
+ cleanup();
74707
+ process.exit(0);
74708
+ });
74709
+ process.once("SIGTERM", () => {
74710
+ cleanup();
74711
+ process.exit(0);
74712
+ });
74713
+ }
74692
74714
  }
74693
74715
  function handleLine(socket, line) {
74694
74716
  let msg;
@@ -78105,17 +78127,12 @@ async function onLoad() {
78105
78127
  });
78106
78128
  startIpcServer();
78107
78129
  setLoginState({ state: "initializing" });
78108
- if (useDirectProtocol) {
78109
- console.log(`[mode] direct protocol -- QQ_USE_PMHQ=${JSON.stringify(process.env.QQ_USE_PMHQ)}`);
78110
- ctx.qqProtocol.initDirectClient().then(() => {
78111
- directLoginLoop();
78112
- }).catch((e) => {
78113
- ctx.logger.error("直连协议初始化失败 (initDirectClient):", e);
78114
- });
78115
- } else {
78116
- console.log("[mode] PMHQ hook mode -- 不会 init/preflight");
78117
- ctx.qqProtocol.startHook();
78118
- }
78130
+ if (useDirectProtocol) ctx.qqProtocol.initDirectClient().then(() => {
78131
+ directLoginLoop();
78132
+ }).catch((e) => {
78133
+ ctx.logger.error("直连协议初始化失败 (initDirectClient):", e);
78134
+ });
78135
+ else ctx.qqProtocol.startHook();
78119
78136
  });
78120
78137
  }
78121
78138
  process.on("unhandledRejection", (reason) => {