llonebot-dist 7.12.9 → 7.12.10

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 fsPromise, { access, copyFile, mkdir, readFile, stat, unlink, writeFile } from "node:fs/promises";
4
+ import fsp, { 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$1, { stat as stat$2, unlink as unlink$1 } from "fs/promises";
24
+ import fsPromise, { 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";
@@ -11385,7 +11385,7 @@ var OB11HeartbeatEvent = class extends OB11BaseMetaEvent {
11385
11385
  };
11386
11386
  //#endregion
11387
11387
  //#region src/version.ts
11388
- var version$2 = "7.12.9";
11388
+ var version$2 = "7.12.10";
11389
11389
  //#endregion
11390
11390
  //#region node_modules/sift/es5m/index.js
11391
11391
  /******************************************************************************
@@ -17148,12 +17148,12 @@ async function uri2local(ctx, uri, needExt) {
17148
17148
  const res = await fetchFile(uri);
17149
17149
  let fileName = randomUUID();
17150
17150
  let filePath = path.join(TEMP_DIR, fileName);
17151
- await fsPromise.writeFile(filePath, res.data);
17151
+ await fsp.writeFile(filePath, res.data);
17152
17152
  if (needExt) {
17153
17153
  const ext = (await ctx.ntFileApi.getFileType(filePath)).ext;
17154
17154
  fileName += `.${ext}`;
17155
17155
  const newPath = `${filePath}.${ext}`;
17156
- await fsPromise.rename(filePath, newPath);
17156
+ await fsp.rename(filePath, newPath);
17157
17157
  filePath = newPath;
17158
17158
  }
17159
17159
  return {
@@ -17176,11 +17176,11 @@ async function uri2local(ctx, uri, needExt) {
17176
17176
  let filename = randomUUID();
17177
17177
  let filePath = path.join(TEMP_DIR, filename);
17178
17178
  const base64 = uri.replace(/^base64:\/\//, "");
17179
- await fsPromise.writeFile(filePath, base64, "base64");
17179
+ await fsp.writeFile(filePath, base64, "base64");
17180
17180
  if (needExt) {
17181
17181
  const ext = (await ctx.ntFileApi.getFileType(filePath)).ext;
17182
17182
  filename += `.${ext}`;
17183
- await fsPromise.rename(filePath, `${filePath}.${ext}`);
17183
+ await fsp.rename(filePath, `${filePath}.${ext}`);
17184
17184
  filePath = `${filePath}.${ext}`;
17185
17185
  }
17186
17186
  return {
@@ -17197,11 +17197,11 @@ async function uri2local(ctx, uri, needExt) {
17197
17197
  let filename = randomUUID();
17198
17198
  const [, _type, base64] = capture;
17199
17199
  let filePath = path.join(TEMP_DIR, filename);
17200
- await fsPromise.writeFile(filePath, base64, "base64");
17200
+ await fsp.writeFile(filePath, base64, "base64");
17201
17201
  if (needExt) {
17202
17202
  const ext = (await ctx.ntFileApi.getFileType(filePath)).ext;
17203
17203
  filename += `.${ext}`;
17204
- await fsPromise.rename(filePath, `${filePath}.${ext}`);
17204
+ await fsp.rename(filePath, `${filePath}.${ext}`);
17205
17205
  filePath = `${filePath}.${ext}`;
17206
17206
  }
17207
17207
  return {
@@ -17547,7 +17547,7 @@ async function calculateSha1StreamBytes(filePath) {
17547
17547
  }
17548
17548
  async function readAndHash10M(filePath) {
17549
17549
  const maxSize = 10002432;
17550
- const fd = await fsPromise.open(filePath, "r");
17550
+ const fd = await fsp.open(filePath, "r");
17551
17551
  const buffer = Buffer.allocUnsafe(maxSize);
17552
17552
  const { bytesRead } = await fd.read(buffer, 0, maxSize, 0);
17553
17553
  await fd.close();
@@ -17672,7 +17672,7 @@ function convert(ctx, input, options, outputPath) {
17672
17672
  });
17673
17673
  }
17674
17674
  async function encodeSilk(ctx, filePath) {
17675
- const file = await fsPromise.readFile(filePath);
17675
+ const file = await fsp.readFile(filePath);
17676
17676
  if (!isSilk(file)) {
17677
17677
  ctx.logger.info(`语音文件${filePath}需要转换成silk`);
17678
17678
  let result;
@@ -17691,7 +17691,7 @@ async function encodeSilk(ctx, filePath) {
17691
17691
  "-f s16le"
17692
17692
  ] }), 24e3);
17693
17693
  const pttPath = path.join(TEMP_DIR, randomUUID());
17694
- await fsPromise.writeFile(pttPath, result.data);
17694
+ await fsp.writeFile(pttPath, result.data);
17695
17695
  ctx.logger.info(`语音文件${filePath}转换成功!`, pttPath, `时长:`, result.duration);
17696
17696
  return {
17697
17697
  converted: true,
@@ -17714,11 +17714,11 @@ async function encodeSilk(ctx, filePath) {
17714
17714
  }
17715
17715
  }
17716
17716
  async function decodeSilk(ctx, inputFilePath, outFormat) {
17717
- const { data } = await decode(await fsPromise.readFile(inputFilePath), 24e3);
17717
+ const { data } = await decode(await fsp.readFile(inputFilePath), 24e3);
17718
17718
  const tmpPath = path.join(TEMP_DIR, path.basename(inputFilePath));
17719
17719
  const outFilePath = tmpPath + `.${outFormat}`;
17720
17720
  const pcmFilePath = tmpPath + ".pcm";
17721
- await fsPromise.writeFile(pcmFilePath, data);
17721
+ await fsp.writeFile(pcmFilePath, data);
17722
17722
  return convert(ctx, pcmFilePath, { input: [
17723
17723
  "-f s16le",
17724
17724
  "-ar 24000",
@@ -18112,8 +18112,12 @@ async function createSendElements(ctx, messageData, peer, ignoreTypes = []) {
18112
18112
  if (isAdmin && remainAtAllCount > 0) sendElements.push(SendElement.at(atQQ, atQQ, AtType.All, "@全体成员"));
18113
18113
  } else if (peer.chatType === ChatType.Group) {
18114
18114
  const uid = await ctx.ntUserApi.getUidByUin(atQQ, peer.peerUid);
18115
- let display = "";
18115
+ let display;
18116
18116
  if (segment.data.name) display = `@${segment.data.name}`;
18117
+ else {
18118
+ const info = await ctx.ntGroupApi.getGroupMember(peer.peerUid, uid);
18119
+ display = `@${info.cardName || info.nick}`;
18120
+ }
18117
18121
  sendElements.push(SendElement.at(atQQ, uid, AtType.One, display));
18118
18122
  }
18119
18123
  }
@@ -24901,17 +24905,17 @@ var DownloadFile = class extends BaseAction {
24901
24905
  const isRandomName = !payload.name;
24902
24906
  const name = payload.name ? path.basename(payload.name) : randomUUID();
24903
24907
  const filePath = path.join(TEMP_DIR, name);
24904
- if (payload.base64) await fsPromise$1.writeFile(filePath, payload.base64, "base64");
24908
+ if (payload.base64) await fsPromise.writeFile(filePath, payload.base64, "base64");
24905
24909
  else if (payload.url) {
24906
24910
  const headers = this.getHeaders(payload.headers);
24907
24911
  const res = await fetchFile(payload.url, headers);
24908
- await fsPromise$1.writeFile(filePath, res.data);
24912
+ await fsPromise.writeFile(filePath, res.data);
24909
24913
  } else throw new Error("不存在任何文件, 无法下载");
24910
24914
  if (fs.existsSync(filePath)) {
24911
24915
  if (isRandomName) {
24912
24916
  const md5 = await getMd5HexFromFile(filePath);
24913
24917
  const newPath = path.join(TEMP_DIR, md5);
24914
- await fsPromise$1.rename(filePath, newPath);
24918
+ await fsPromise.rename(filePath, newPath);
24915
24919
  return { file: newPath };
24916
24920
  }
24917
24921
  return { file: filePath };
@@ -28540,7 +28544,12 @@ var MessageEncoder = class {
28540
28544
  if (attrs.type === "all") this.elements.push(SendElement.at("", "", AtType.All, "@全体成员"));
28541
28545
  else {
28542
28546
  const uid = await this.ctx.ntUserApi.getUidByUin(attrs.id, this.peer.peerUid);
28543
- const display = attrs.name ? "@" + attrs.name : "";
28547
+ let display;
28548
+ if (attrs.name) display = `@${attrs.name}`;
28549
+ else {
28550
+ const info = await this.ctx.ntGroupApi.getGroupMember(this.peer.peerUid, uid);
28551
+ display = `@${info.cardName || info.nick}`;
28552
+ }
28544
28553
  this.elements.push(SendElement.at(attrs.id, uid, AtType.One, display));
28545
28554
  }
28546
28555
  } else if (type === "a") {
@@ -43450,7 +43459,7 @@ async function download(url, headers) {
43450
43459
  return Buffer.from(bytes);
43451
43460
  }
43452
43461
  async function resolveMilkyUri(uri) {
43453
- if (uri.startsWith("file://")) return await fsPromise.readFile(fileURLToPath(uri));
43462
+ if (uri.startsWith("file://")) return await fsp.readFile(fileURLToPath(uri));
43454
43463
  if (uri.startsWith("http://") || uri.startsWith("https://")) return await download(uri);
43455
43464
  if (uri.startsWith("base64://")) return Buffer.from(uri.slice(9), "base64");
43456
43465
  throw new Error(`Unsupported URI scheme: ${uri}`);
@@ -43687,7 +43696,8 @@ async function transformOutgoingMessage(ctx, segments, peerUid, isGroup = false)
43687
43696
  else if (segment.type === "mention" && isGroup) {
43688
43697
  const memberUin = segment.data.user_id.toString();
43689
43698
  const memberUid = await ctx.ntUserApi.getUidByUin(memberUin, peerUid);
43690
- elements.push(SendElement.at(memberUin, memberUid, AtType.One, ""));
43699
+ const info = await ctx.ntGroupApi.getGroupMember(peerUid, memberUid);
43700
+ elements.push(SendElement.at(memberUin, memberUid, AtType.One, `@${info.cardName || info.nick}`));
43691
43701
  } else if (segment.type === "mention_all" && isGroup) elements.push(SendElement.at("", "", AtType.All, "@全体成员"));
43692
43702
  else if (segment.type === "face") elements.push(SendElement.face(+segment.data.face_id, segment.data.is_large ? 3 : void 0));
43693
43703
  else if (segment.type === "reply") {
@@ -53760,7 +53770,7 @@ var NTQQMsgApi = class extends Service {
53760
53770
  chatInfo: peer,
53761
53771
  filterMsgType: [],
53762
53772
  filterSendersUid,
53763
- filterMsgToTime: filterMsgTime,
53773
+ filterMsgToTime: String(filterMsgTime + 1),
53764
53774
  filterMsgFromTime: filterMsgTime,
53765
53775
  isReverseOrder: true,
53766
53776
  isIncludeCurrent: true,
@@ -54040,7 +54050,7 @@ var NTQQUserApi = class extends Service {
54040
54050
  const funcs = [async () => {
54041
54051
  return (await this.ctx.pmhq.invoke("nodeIKernelUixConvertService/getUin", [[uid]])).uinInfo.get(uid);
54042
54052
  }, async () => {
54043
- return (await this.fetchUserDetailInfo(uid)).detail.get(uid)?.uin;
54053
+ return (await this.getUserSimpleInfo(uid)).uin;
54044
54054
  }];
54045
54055
  for (const f of funcs) try {
54046
54056
  const result = await f();
@@ -54050,6 +54060,7 @@ var NTQQUserApi = class extends Service {
54050
54060
  }
54051
54061
  return "";
54052
54062
  }
54063
+ /** 始终会从服务器拉取 */
54053
54064
  async fetchUserDetailInfo(uid) {
54054
54065
  return await this.ctx.pmhq.invoke("nodeIKernelProfileService/fetchUserDetailInfo", [
54055
54066
  "BuddyProfileStore",
@@ -54064,12 +54075,14 @@ var NTQQUserApi = class extends Service {
54064
54075
  resultCb: (payload) => payload.simpleInfo.uid === uid
54065
54076
  });
54066
54077
  }
54078
+ /** 无缓存时会从服务器拉取 */
54067
54079
  async getUserSimpleInfo(uid, force = true) {
54068
54080
  return (await this.ctx.pmhq.invoke("nodeIKernelProfileService/getUserSimpleInfo", [force, [uid]], {
54069
54081
  resultCmd: ReceiveCmdS.USER_INFO,
54070
54082
  resultCb: (payload) => payload.has(uid)
54071
54083
  })).get(uid);
54072
54084
  }
54085
+ /** 无缓存时会获取不到用户信息 */
54073
54086
  async getCoreAndBaseInfo(uids) {
54074
54087
  return await this.ctx.pmhq.invoke("nodeIKernelProfileService/getCoreAndBaseInfo", ["nodeStore", uids]);
54075
54088
  }
@@ -54313,7 +54326,7 @@ var NTQQWebApi = class extends Service {
54313
54326
  const iBatchID = Math.floor(Date.now() / 1e3);
54314
54327
  for (let i = 0; i < filePathList.length; i++) {
54315
54328
  const filePath = filePathList[i];
54316
- const fileBuffer = await fsPromise.readFile(filePath);
54329
+ const fileBuffer = await fsp.readFile(filePath);
54317
54330
  const fileSize = fileBuffer.length;
54318
54331
  const fileType = await fileTypeFromBuffer(fileBuffer);
54319
54332
  const timestamp = Math.floor(Date.now() / 1e3);
@@ -54498,7 +54511,7 @@ var NTQQWebApi = class extends Service {
54498
54511
  }
54499
54512
  if (sVid) {
54500
54513
  const filePath = await createThumb(this.ctx, filePathList[i]);
54501
- const fileBuffer = await fsPromise.readFile(filePath);
54514
+ const fileBuffer = await fsp.readFile(filePath);
54502
54515
  const fileSize = fileBuffer.length;
54503
54516
  const timestamp = Math.floor(Date.now() / 1e3);
54504
54517
  const checksum = getMd5HexFromBuffer(fileBuffer);
@@ -70377,7 +70390,7 @@ function UserMixin(Base) {
70377
70390
  const info = Oidb.FetchUserInfoResp.decode(oidbRespBody);
70378
70391
  const numbers = Object.fromEntries(info.body.properties.numberProperties.map((p) => [p.key, p.value]));
70379
70392
  const bytes = Object.fromEntries(info.body.properties.bytesProperties.map((p) => [p.key, p.value]));
70380
- const business = bytes[107] ? Misc.UserInfoBusiness.decode(bytes[107]) : void 0;
70393
+ const vipInfo = (bytes[107] ? Misc.UserInfoBusiness.decode(bytes[107]) : void 0)?.body.lists.find((e) => e.type === 1);
70381
70394
  return {
70382
70395
  uin: info.body.uin,
70383
70396
  nick: bytes[20002]?.toString() ?? "",
@@ -70395,9 +70408,9 @@ function UserMixin(Base) {
70395
70408
  labels: bytes[104] ? Misc.UserInfoLabel.decode(bytes[104]).labels.map((e) => e.content) : [],
70396
70409
  school: bytes[20021]?.toString() ?? "",
70397
70410
  remark: bytes[103]?.toString() ?? "",
70398
- isVip: !!business?.body.lists[0],
70399
- isYearsVip: !!business?.body.lists[0]?.isYear,
70400
- vipLevel: business?.body.lists[0]?.level ?? 0
70411
+ isVip: !!vipInfo,
70412
+ isYearsVip: !!vipInfo?.isYear,
70413
+ vipLevel: vipInfo?.level ?? 0
70401
70414
  };
70402
70415
  }
70403
70416
  async fetchUserLoginDays(uin) {