llonebot-dist 7.12.10 → 7.12.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/llbot.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { createRequire } from "node:module";
2
2
  import * as path$4 from "node:path";
3
3
  import path, { dirname, join } from "node:path";
4
- import fsp, { access, copyFile, mkdir, readFile, stat, unlink, writeFile } from "node:fs/promises";
4
+ import fsPromise, { access, copyFile, mkdir, readFile, stat, unlink, writeFile } from "node:fs/promises";
5
5
  import fs, { existsSync } from "fs";
6
6
  import * as fs$5 from "node:fs";
7
7
  import fs$1, { appendFile, appendFileSync, createReadStream, existsSync as existsSync$1, mkdirSync, promises, stat as stat$1, statSync, watch } from "node:fs";
@@ -21,7 +21,7 @@ import http, { STATUS_CODES, createServer, request } from "node:http";
21
21
  import { Http2ServerRequest, constants as constants$1 } from "node:http2";
22
22
  import { Readable, Transform } from "node:stream";
23
23
  import { deflateSync, gunzipSync, gzipSync, inflateSync } from "node:zlib";
24
- import fsPromise, { stat as stat$2, unlink as unlink$1 } from "fs/promises";
24
+ import fsPromise$1, { stat as stat$2, unlink as unlink$1 } from "fs/promises";
25
25
  import { inspect, isDeepStrictEqual } from "node:util";
26
26
  import net, { connect } from "node:net";
27
27
  import https from "node:https";
@@ -11240,8 +11240,12 @@ var OB11Entities;
11240
11240
  let operatorUin;
11241
11241
  if (revokeElement.operatorUid === revokeElement.origMsgSenderUid) operatorUin = msg.senderUin;
11242
11242
  else operatorUin = await ctx.ntUserApi.getUinByUid(revokeElement.operatorUid);
11243
- if (msg.senderUin === "0" || !msg.senderUin) ctx.logger.warn(`发生异常 senderUin: ${msg.senderUin}`);
11244
- return new OB11GroupRecallNoticeEvent(Number(msg.peerUid), Number(msg.senderUin), Number(operatorUin), shortId);
11243
+ let senderUin = msg.senderUin;
11244
+ if (msg.senderUin === "0") {
11245
+ senderUin = await ctx.ntUserApi.getUinByUid(revokeElement.origMsgSenderUid);
11246
+ if (revokeElement.operatorUid === revokeElement.origMsgSenderUid) operatorUin = senderUin;
11247
+ }
11248
+ return new OB11GroupRecallNoticeEvent(Number(msg.peerUid), Number(senderUin), Number(operatorUin), shortId);
11245
11249
  } else return new OB11FriendRecallNoticeEvent(+msg.senderUin, shortId);
11246
11250
  }
11247
11251
  _OB11Entities.recallEvent = recallEvent;
@@ -11385,7 +11389,7 @@ var OB11HeartbeatEvent = class extends OB11BaseMetaEvent {
11385
11389
  };
11386
11390
  //#endregion
11387
11391
  //#region src/version.ts
11388
- var version$2 = "7.12.10";
11392
+ var version$2 = "7.12.11";
11389
11393
  //#endregion
11390
11394
  //#region node_modules/sift/es5m/index.js
11391
11395
  /******************************************************************************
@@ -17148,12 +17152,12 @@ async function uri2local(ctx, uri, needExt) {
17148
17152
  const res = await fetchFile(uri);
17149
17153
  let fileName = randomUUID();
17150
17154
  let filePath = path.join(TEMP_DIR, fileName);
17151
- await fsp.writeFile(filePath, res.data);
17155
+ await fsPromise.writeFile(filePath, res.data);
17152
17156
  if (needExt) {
17153
17157
  const ext = (await ctx.ntFileApi.getFileType(filePath)).ext;
17154
17158
  fileName += `.${ext}`;
17155
17159
  const newPath = `${filePath}.${ext}`;
17156
- await fsp.rename(filePath, newPath);
17160
+ await fsPromise.rename(filePath, newPath);
17157
17161
  filePath = newPath;
17158
17162
  }
17159
17163
  return {
@@ -17176,11 +17180,11 @@ async function uri2local(ctx, uri, needExt) {
17176
17180
  let filename = randomUUID();
17177
17181
  let filePath = path.join(TEMP_DIR, filename);
17178
17182
  const base64 = uri.replace(/^base64:\/\//, "");
17179
- await fsp.writeFile(filePath, base64, "base64");
17183
+ await fsPromise.writeFile(filePath, base64, "base64");
17180
17184
  if (needExt) {
17181
17185
  const ext = (await ctx.ntFileApi.getFileType(filePath)).ext;
17182
17186
  filename += `.${ext}`;
17183
- await fsp.rename(filePath, `${filePath}.${ext}`);
17187
+ await fsPromise.rename(filePath, `${filePath}.${ext}`);
17184
17188
  filePath = `${filePath}.${ext}`;
17185
17189
  }
17186
17190
  return {
@@ -17197,11 +17201,11 @@ async function uri2local(ctx, uri, needExt) {
17197
17201
  let filename = randomUUID();
17198
17202
  const [, _type, base64] = capture;
17199
17203
  let filePath = path.join(TEMP_DIR, filename);
17200
- await fsp.writeFile(filePath, base64, "base64");
17204
+ await fsPromise.writeFile(filePath, base64, "base64");
17201
17205
  if (needExt) {
17202
17206
  const ext = (await ctx.ntFileApi.getFileType(filePath)).ext;
17203
17207
  filename += `.${ext}`;
17204
- await fsp.rename(filePath, `${filePath}.${ext}`);
17208
+ await fsPromise.rename(filePath, `${filePath}.${ext}`);
17205
17209
  filePath = `${filePath}.${ext}`;
17206
17210
  }
17207
17211
  return {
@@ -17547,7 +17551,7 @@ async function calculateSha1StreamBytes(filePath) {
17547
17551
  }
17548
17552
  async function readAndHash10M(filePath) {
17549
17553
  const maxSize = 10002432;
17550
- const fd = await fsp.open(filePath, "r");
17554
+ const fd = await fsPromise.open(filePath, "r");
17551
17555
  const buffer = Buffer.allocUnsafe(maxSize);
17552
17556
  const { bytesRead } = await fd.read(buffer, 0, maxSize, 0);
17553
17557
  await fd.close();
@@ -17672,7 +17676,7 @@ function convert(ctx, input, options, outputPath) {
17672
17676
  });
17673
17677
  }
17674
17678
  async function encodeSilk(ctx, filePath) {
17675
- const file = await fsp.readFile(filePath);
17679
+ const file = await fsPromise.readFile(filePath);
17676
17680
  if (!isSilk(file)) {
17677
17681
  ctx.logger.info(`语音文件${filePath}需要转换成silk`);
17678
17682
  let result;
@@ -17691,7 +17695,7 @@ async function encodeSilk(ctx, filePath) {
17691
17695
  "-f s16le"
17692
17696
  ] }), 24e3);
17693
17697
  const pttPath = path.join(TEMP_DIR, randomUUID());
17694
- await fsp.writeFile(pttPath, result.data);
17698
+ await fsPromise.writeFile(pttPath, result.data);
17695
17699
  ctx.logger.info(`语音文件${filePath}转换成功!`, pttPath, `时长:`, result.duration);
17696
17700
  return {
17697
17701
  converted: true,
@@ -17714,11 +17718,11 @@ async function encodeSilk(ctx, filePath) {
17714
17718
  }
17715
17719
  }
17716
17720
  async function decodeSilk(ctx, inputFilePath, outFormat) {
17717
- const { data } = await decode(await fsp.readFile(inputFilePath), 24e3);
17721
+ const { data } = await decode(await fsPromise.readFile(inputFilePath), 24e3);
17718
17722
  const tmpPath = path.join(TEMP_DIR, path.basename(inputFilePath));
17719
17723
  const outFilePath = tmpPath + `.${outFormat}`;
17720
17724
  const pcmFilePath = tmpPath + ".pcm";
17721
- await fsp.writeFile(pcmFilePath, data);
17725
+ await fsPromise.writeFile(pcmFilePath, data);
17722
17726
  return convert(ctx, pcmFilePath, { input: [
17723
17727
  "-f s16le",
17724
17728
  "-ar 24000",
@@ -24905,17 +24909,17 @@ var DownloadFile = class extends BaseAction {
24905
24909
  const isRandomName = !payload.name;
24906
24910
  const name = payload.name ? path.basename(payload.name) : randomUUID();
24907
24911
  const filePath = path.join(TEMP_DIR, name);
24908
- if (payload.base64) await fsPromise.writeFile(filePath, payload.base64, "base64");
24912
+ if (payload.base64) await fsPromise$1.writeFile(filePath, payload.base64, "base64");
24909
24913
  else if (payload.url) {
24910
24914
  const headers = this.getHeaders(payload.headers);
24911
24915
  const res = await fetchFile(payload.url, headers);
24912
- await fsPromise.writeFile(filePath, res.data);
24916
+ await fsPromise$1.writeFile(filePath, res.data);
24913
24917
  } else throw new Error("不存在任何文件, 无法下载");
24914
24918
  if (fs.existsSync(filePath)) {
24915
24919
  if (isRandomName) {
24916
24920
  const md5 = await getMd5HexFromFile(filePath);
24917
24921
  const newPath = path.join(TEMP_DIR, md5);
24918
- await fsPromise.rename(filePath, newPath);
24922
+ await fsPromise$1.rename(filePath, newPath);
24919
24923
  return { file: newPath };
24920
24924
  }
24921
24925
  return { file: filePath };
@@ -26415,8 +26419,15 @@ var SendGroupAiRecord = class extends BaseAction {
26415
26419
  chat_type: lib_default$1.union([Number, String]).default(1)
26416
26420
  });
26417
26421
  async _handle(payload) {
26418
- await this.ctx.pmhq.getGroupGenerateAiRecord(+payload.group_id, payload.character, payload.text, +payload.chat_type);
26419
- return { message_id: 0 };
26422
+ const targetMsgRandom = (await this.ctx.pmhq.getGroupGenerateAiRecord(+payload.group_id, payload.character, payload.text, +payload.chat_type)).msgRandom.toString();
26423
+ const { promise, resolve } = Promise.withResolvers();
26424
+ const dispose = this.ctx.on("nt/message-created", (msg) => {
26425
+ if (msg.msgRandom === targetMsgRandom) {
26426
+ dispose();
26427
+ resolve({ message_id: this.ctx.store.createMsgShortId(msg) });
26428
+ }
26429
+ });
26430
+ return promise;
26420
26431
  }
26421
26432
  };
26422
26433
  //#endregion
@@ -43459,7 +43470,7 @@ async function download(url, headers) {
43459
43470
  return Buffer.from(bytes);
43460
43471
  }
43461
43472
  async function resolveMilkyUri(uri) {
43462
- if (uri.startsWith("file://")) return await fsp.readFile(fileURLToPath(uri));
43473
+ if (uri.startsWith("file://")) return await fsPromise.readFile(fileURLToPath(uri));
43463
43474
  if (uri.startsWith("http://") || uri.startsWith("https://")) return await download(uri);
43464
43475
  if (uri.startsWith("base64://")) return Buffer.from(uri.slice(9), "base64");
43465
43476
  throw new Error(`Unsupported URI scheme: ${uri}`);
@@ -54326,7 +54337,7 @@ var NTQQWebApi = class extends Service {
54326
54337
  const iBatchID = Math.floor(Date.now() / 1e3);
54327
54338
  for (let i = 0; i < filePathList.length; i++) {
54328
54339
  const filePath = filePathList[i];
54329
- const fileBuffer = await fsp.readFile(filePath);
54340
+ const fileBuffer = await fsPromise.readFile(filePath);
54330
54341
  const fileSize = fileBuffer.length;
54331
54342
  const fileType = await fileTypeFromBuffer(fileBuffer);
54332
54343
  const timestamp = Math.floor(Date.now() / 1e3);
@@ -54511,7 +54522,7 @@ var NTQQWebApi = class extends Service {
54511
54522
  }
54512
54523
  if (sVid) {
54513
54524
  const filePath = await createThumb(this.ctx, filePathList[i]);
54514
- const fileBuffer = await fsp.readFile(filePath);
54525
+ const fileBuffer = await fsPromise.readFile(filePath);
54515
54526
  const fileSize = fileBuffer.length;
54516
54527
  const timestamp = Math.floor(Date.now() / 1e3);
54517
54528
  const checksum = getMd5HexFromBuffer(fileBuffer);
@@ -70339,12 +70350,13 @@ function MessageMixin(Base) {
70339
70350
  return Oidb.FetchAiCharacterListResp.decode(oidbRespBody);
70340
70351
  }
70341
70352
  async getGroupGenerateAiRecord(groupId, character, text, chatType) {
70353
+ const msgRandom = randomBytes(4).readUInt32BE(0);
70342
70354
  const body = Oidb.GetGroupGenerateAiRecordReq.encode({
70343
70355
  groupId,
70344
70356
  voiceId: character,
70345
70357
  text,
70346
70358
  chatType,
70347
- clientMsgInfo: { msgRandom: randomBytes(4).readUInt32BE(0) }
70359
+ clientMsgInfo: { msgRandom }
70348
70360
  });
70349
70361
  const data = Oidb.Base.encode({
70350
70362
  command: 37531,
@@ -70352,6 +70364,7 @@ function MessageMixin(Base) {
70352
70364
  body
70353
70365
  });
70354
70366
  await this.httpSendPB("OidbSvcTrpcTcp.0x929b_0", data);
70367
+ return { msgRandom };
70355
70368
  }
70356
70369
  };
70357
70370
  }