llonebot-dist 8.0.1 → 8.0.3

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
@@ -10933,16 +10933,35 @@ var Msg;
10933
10933
  buf: ProtoField(11, "bytes", "optional")
10934
10934
  }, "optional"),
10935
10935
  notOnlineImage: ProtoField(4, {
10936
- filePath: ProtoField(1, "string", "optional"),
10937
- fileLen: ProtoField(2, "uint32", "optional"),
10938
- downloadPath: ProtoField(3, "string", "optional"),
10939
- picMd5: ProtoField(7, "bytes", "optional"),
10940
- picHeight: ProtoField(8, "uint32", "optional"),
10941
- picWidth: ProtoField(9, "uint32", "optional"),
10942
- resId: ProtoField(10, "string", "optional"),
10943
- thumbUrl: ProtoField(12, "string", "optional"),
10944
- bigUrl: ProtoField(14, "string", "optional"),
10945
- origUrl: ProtoField(15, "string", "optional")
10936
+ filePath: ProtoField(1, "string"),
10937
+ fileLen: ProtoField(2, "uint32"),
10938
+ downloadPath: ProtoField(3, "bytes"),
10939
+ oldVerSendFile: ProtoField(4, "bytes"),
10940
+ imgType: ProtoField(5, "uint32"),
10941
+ previewsImage: ProtoField(6, "bytes"),
10942
+ picMd5: ProtoField(7, "bytes"),
10943
+ picHeight: ProtoField(8, "uint32"),
10944
+ picWidth: ProtoField(9, "uint32"),
10945
+ resId: ProtoField(10, "string"),
10946
+ flag: ProtoField(11, "bytes"),
10947
+ thumbUrl: ProtoField(12, "string"),
10948
+ original: ProtoField(13, "uint32"),
10949
+ bigUrl: ProtoField(14, "string"),
10950
+ origUrl: ProtoField(15, "string"),
10951
+ bizType: ProtoField(16, "uint32"),
10952
+ result: ProtoField(17, "uint32"),
10953
+ index: ProtoField(18, "uint32"),
10954
+ opFaceBuf: ProtoField(19, "bytes"),
10955
+ oldPicMd5: ProtoField(20, "bool"),
10956
+ thumbWidth: ProtoField(21, "uint32"),
10957
+ thumbHeight: ProtoField(22, "uint32"),
10958
+ fileId: ProtoField(23, "uint32"),
10959
+ showLen: ProtoField(24, "uint32"),
10960
+ downloadLen: ProtoField(25, "uint32"),
10961
+ url400: ProtoField(26, "string"),
10962
+ width400: ProtoField(27, "uint32"),
10963
+ height400: ProtoField(28, "uint32"),
10964
+ pbReserve: ProtoField(29, "bytes")
10946
10965
  }, "optional"),
10947
10966
  transElemInfo: ProtoField(5, {
10948
10967
  elemType: ProtoField(1, "uint32"),
@@ -10960,15 +10979,55 @@ var Msg;
10960
10979
  height: ProtoField(11, "uint32", "optional")
10961
10980
  }, "optional"),
10962
10981
  customFace: ProtoField(8, {
10963
- filePath: ProtoField(2, "string", "optional"),
10964
- fileId: ProtoField(7, "uint32", "optional"),
10965
- md5: ProtoField(13, "bytes", "optional"),
10966
- thumbUrl: ProtoField(14, "string", "optional"),
10967
- bigUrl: ProtoField(15, "string", "optional"),
10968
- origUrl: ProtoField(16, "string", "optional"),
10969
- width: ProtoField(22, "uint32", "optional"),
10970
- height: ProtoField(23, "uint32", "optional"),
10971
- size: ProtoField(25, "uint32", "optional")
10982
+ guid: ProtoField(1, "bytes"),
10983
+ filePath: ProtoField(2, "string"),
10984
+ shortcut: ProtoField(3, "string"),
10985
+ buffer: ProtoField(4, "bytes"),
10986
+ flag: ProtoField(5, "bytes"),
10987
+ oldData: ProtoField(6, "bytes", "optional"),
10988
+ fileId: ProtoField(7, "uint32"),
10989
+ serverIp: ProtoField(8, "int32", "optional"),
10990
+ serverPort: ProtoField(9, "int32", "optional"),
10991
+ fileType: ProtoField(10, "int32"),
10992
+ signature: ProtoField(11, "bytes"),
10993
+ useful: ProtoField(12, "int32"),
10994
+ md5: ProtoField(13, "bytes"),
10995
+ thumbUrl: ProtoField(14, "string"),
10996
+ bigUrl: ProtoField(15, "string"),
10997
+ origUrl: ProtoField(16, "string"),
10998
+ bizType: ProtoField(17, "int32"),
10999
+ repeatIndex: ProtoField(18, "int32"),
11000
+ repeatImage: ProtoField(19, "int32"),
11001
+ imageType: ProtoField(20, "int32"),
11002
+ index: ProtoField(21, "int32"),
11003
+ width: ProtoField(22, "int32"),
11004
+ height: ProtoField(23, "int32"),
11005
+ source: ProtoField(24, "int32"),
11006
+ size: ProtoField(25, "uint32"),
11007
+ origin: ProtoField(26, "int32"),
11008
+ thumbWidth: ProtoField(27, "int32", "optional"),
11009
+ thumbHeight: ProtoField(28, "int32", "optional"),
11010
+ showLen: ProtoField(29, "int32"),
11011
+ downloadLen: ProtoField(30, "int32"),
11012
+ x400Url: ProtoField(31, "string", "optional"),
11013
+ x400Width: ProtoField(32, "int32"),
11014
+ x400Height: ProtoField(33, "int32"),
11015
+ pbReserve: ProtoField(34, {
11016
+ subType: ProtoField(1, "int32"),
11017
+ field3: ProtoField(3, "int32"),
11018
+ field4: ProtoField(4, "int32"),
11019
+ summary: ProtoField(9, "string"),
11020
+ field10: ProtoField(10, "int32"),
11021
+ field21: ProtoField(21, {
11022
+ field1: ProtoField(1, "int32"),
11023
+ field2: ProtoField(2, "string"),
11024
+ field3: ProtoField(3, "int32"),
11025
+ field4: ProtoField(4, "int32"),
11026
+ field5: ProtoField(5, "int32"),
11027
+ md5Str: ProtoField(7, "string")
11028
+ }),
11029
+ field31: ProtoField(31, "string")
11030
+ }, "optional")
10972
11031
  }, "optional"),
10973
11032
  richMsg: ProtoField(12, {
10974
11033
  template: ProtoField(1, "bytes"),
@@ -11208,7 +11267,7 @@ var Msg;
11208
11267
  toUid: ProtoField(4, "string")
11209
11268
  }, "optional"),
11210
11269
  trans0X211: ProtoField(15, {
11211
- toUin: ProtoField(1, "uint64", "optional"),
11270
+ toUin: ProtoField(1, "uint32", "optional"),
11212
11271
  ccCmd: ProtoField(2, "uint32", "optional"),
11213
11272
  uid: ProtoField(8, "string", "optional")
11214
11273
  }, "optional")
@@ -12933,7 +12992,7 @@ var Oidb;
12933
12992
  clientWording: ProtoField(3, "string")
12934
12993
  });
12935
12994
  _Oidb.FetchProfileLikeReq = ProtoMessage.of({
12936
- targetUid: ProtoField(1, "string"),
12995
+ selfUid: ProtoField(1, "string"),
12937
12996
  field2: ProtoField(2, "uint32"),
12938
12997
  direction: ProtoField(3, "uint32"),
12939
12998
  field4: ProtoField(4, "uint32"),
@@ -12944,11 +13003,24 @@ var Oidb;
12944
13003
  _Oidb.FetchProfileLikeResp = ProtoMessage.of({ body: ProtoField(1, {
12945
13004
  targetUid: ProtoField(1, "string"),
12946
13005
  field2: ProtoField(2, "uint32"),
12947
- detail: ProtoField(3, {
12948
- field1: ProtoField(1, "uint32"),
12949
- field2: ProtoField(2, "uint32"),
12950
- nextStart: ProtoField(3, "uint32"),
12951
- users: ProtoField(4, {
13006
+ favoriteInfo: ProtoField(3, { users: ProtoField(4, {
13007
+ uid: ProtoField(1, "string"),
13008
+ src: ProtoField(2, "uint32"),
13009
+ latestTime: ProtoField(3, "uint32"),
13010
+ count: ProtoField(4, "uint32"),
13011
+ giftCount: ProtoField(5, "uint32"),
13012
+ customId: ProtoField(6, "uint32"),
13013
+ lastCharged: ProtoField(8, "uint32"),
13014
+ bTodayVotedCnt: ProtoField(22, "uint32"),
13015
+ nick: ProtoField(101, "string"),
13016
+ gender: ProtoField(102, "uint32"),
13017
+ age: ProtoField(103, "uint32"),
13018
+ isvip: ProtoField(105, "bool"),
13019
+ isSvip: ProtoField(106, "bool")
13020
+ }, "repeated") }),
13021
+ voteInfo: ProtoField(4, {
13022
+ totalCount: ProtoField(1, "uint32"),
13023
+ users: ProtoField(5, {
12952
13024
  uid: ProtoField(1, "string"),
12953
13025
  src: ProtoField(2, "uint32"),
12954
13026
  latestTime: ProtoField(3, "uint32"),
@@ -12963,8 +13035,10 @@ var Oidb;
12963
13035
  isvip: ProtoField(105, "bool"),
12964
13036
  isSvip: ProtoField(106, "bool")
12965
13037
  }, "repeated")
12966
- }, "optional")
13038
+ })
12967
13039
  }) });
13040
+ _Oidb.FetchProfileLikeCountReq = ProtoMessage.of({ uid: ProtoField(1, "string") });
13041
+ _Oidb.FetchProfileLikeCountResp = ProtoMessage.of({ body: ProtoField(1, { voteInfo: ProtoField(4, { totalCount: ProtoField(1, "uint32") }) }) });
12968
13042
  _Oidb.RenameGroupFileReq = ProtoMessage.of({ rename: ProtoField(5, {
12969
13043
  groupCode: ProtoField(1, "uint32"),
12970
13044
  busId: ProtoField(3, "uint32"),
@@ -17248,6 +17322,46 @@ function parseElements(elems) {
17248
17322
  });
17249
17323
  continue;
17250
17324
  }
17325
+ if (elem.notOnlineImage) {
17326
+ const img = elem.notOnlineImage;
17327
+ result.push({
17328
+ elementType: ElementType.Pic,
17329
+ picElement: {
17330
+ fileName: img.filePath,
17331
+ fileSize: img.fileLen,
17332
+ picWidth: img.picWidth,
17333
+ picHeight: img.picHeight,
17334
+ md5HexStr: img.picMd5.toString("hex"),
17335
+ sourcePath: "",
17336
+ picType: img.imgType,
17337
+ picSubType: img.bizType,
17338
+ fileUuid: img.resId.split("-")[1],
17339
+ originImageUrl: img.origUrl,
17340
+ summary: ""
17341
+ }
17342
+ });
17343
+ continue;
17344
+ }
17345
+ if (elem.customFace) {
17346
+ const cf = elem.customFace;
17347
+ result.push({
17348
+ elementType: ElementType.Pic,
17349
+ picElement: {
17350
+ fileName: cf.filePath,
17351
+ fileSize: cf.size,
17352
+ picWidth: cf.width,
17353
+ picHeight: cf.height,
17354
+ md5HexStr: cf.md5.toString("hex"),
17355
+ sourcePath: "",
17356
+ picSubType: cf.bizType,
17357
+ fileUuid: cf.fileId.toString(),
17358
+ originImageUrl: cf.origUrl,
17359
+ picType: cf.imageType,
17360
+ summary: ""
17361
+ }
17362
+ });
17363
+ continue;
17364
+ }
17251
17365
  if (elem.marketFace) {
17252
17366
  const mf = elem.marketFace;
17253
17367
  result.push({
@@ -17333,6 +17447,7 @@ function parseElements(elems) {
17333
17447
  replyMsgSeq: elem.srcMsg.attr.ntMsgSeq ?? elem.srcMsg.origSeqs[0],
17334
17448
  replyMsgTime: elem.srcMsg.time,
17335
17449
  senderUin: elem.srcMsg.senderUin,
17450
+ senderUid: elem.srcMsg.attr.senderUid,
17336
17451
  replyMsgClientSeq: elem.srcMsg.attr.ntMsgSeq ? elem.srcMsg.origSeqs[0] : 0
17337
17452
  }
17338
17453
  });
@@ -18857,7 +18972,7 @@ var OB11HeartbeatEvent = class extends OB11BaseMetaEvent {
18857
18972
  };
18858
18973
  //#endregion
18859
18974
  //#region src/version.ts
18860
- var version$3 = "8.0.1";
18975
+ var version$3 = "8.0.3";
18861
18976
  //#endregion
18862
18977
  //#region node_modules/sift/es5m/index.js
18863
18978
  /******************************************************************************
@@ -21449,12 +21564,13 @@ var SendElement;
21449
21564
  };
21450
21565
  }
21451
21566
  _SendElement.at = at;
21452
- function reply(msgSeq, senderUin, msgTime, clientSeq, srcMsg) {
21567
+ function reply(msgSeq, senderUin, senderUid, msgTime, clientSeq, srcMsg) {
21453
21568
  return {
21454
21569
  elementType: ElementType.Reply,
21455
21570
  replyElement: {
21456
21571
  replyMsgSeq: msgSeq,
21457
21572
  senderUin,
21573
+ senderUid,
21458
21574
  replyMsgTime: msgTime,
21459
21575
  replyMsgClientSeq: clientSeq,
21460
21576
  srcMsg
@@ -21631,6 +21747,19 @@ var SendElement;
21631
21747
  };
21632
21748
  }
21633
21749
  _SendElement.forward = forward;
21750
+ async function file(ctx, filePath, fileName) {
21751
+ const fileSize = (await stat(filePath)).size;
21752
+ if (fileSize === 0) throw new Error("文件异常,大小为 0");
21753
+ return {
21754
+ elementType: ElementType.File,
21755
+ fileElement: {
21756
+ fileName,
21757
+ filePath,
21758
+ fileSize
21759
+ }
21760
+ };
21761
+ }
21762
+ _SendElement.file = file;
21634
21763
  })(SendElement || (SendElement = {}));
21635
21764
  //#endregion
21636
21765
  //#region src/common/utils/misc.ts
@@ -21816,7 +21945,7 @@ async function transformOutgoingSegments(ctx, messageData, peer, isInsideForward
21816
21945
  const { msgByteList } = await ctx.ntMsgApi.getSingleMsg(info.peer, info.msgSeq);
21817
21946
  srcMsg = msgByteList[0];
21818
21947
  }
21819
- sendElements.push(SendElement.reply(msg.msgSeq, +msg.senderUin, +msg.msgTime, msg.clientSeq, srcMsg));
21948
+ sendElements.push(SendElement.reply(msg.msgSeq, msg.senderUin, msg.senderUid, msg.msgTime, msg.clientSeq, srcMsg));
21820
21949
  }
21821
21950
  }
21822
21951
  break;
@@ -21960,16 +22089,24 @@ async function transformOutgoingSegments(ctx, messageData, peer, isInsideForward
21960
22089
  sendElements.push(SendElement.ark(content));
21961
22090
  }
21962
22091
  break;
21963
- case OB11MessageDataType.Node: {
21964
- const inner = await transformOutgoingSegments(ctx, segment.data.content ? message2List(segment.data.content) : [], peer, true);
21965
- deleteAfterSentFiles.push(...inner.deleteAfterSentFiles);
21966
- nodes.push({
21967
- senderUin: Number(segment.data.uin ?? segment.data.user_id ?? selfInfo.uin),
21968
- senderName: segment.data.name ?? segment.data.nickname ?? selfInfo.nick,
21969
- elements: inner.sendElements,
21970
- msgTime: segment.data.time ? +segment.data.time : void 0
21971
- });
21972
- }
22092
+ case OB11MessageDataType.Node:
22093
+ {
22094
+ const inner = await transformOutgoingSegments(ctx, segment.data.content ? message2List(segment.data.content) : [], peer, true);
22095
+ deleteAfterSentFiles.push(...inner.deleteAfterSentFiles);
22096
+ nodes.push({
22097
+ senderUin: Number(segment.data.uin ?? segment.data.user_id ?? selfInfo.uin),
22098
+ senderName: segment.data.name ?? segment.data.nickname ?? selfInfo.nick,
22099
+ elements: inner.sendElements,
22100
+ msgTime: segment.data.time ? +segment.data.time : void 0
22101
+ });
22102
+ }
22103
+ break;
22104
+ case OB11MessageDataType.File:
22105
+ {
22106
+ const { path, fileName } = await handleOb11RichMedia(ctx, segment, deleteAfterSentFiles);
22107
+ sendElements.push(await SendElement.file(ctx, path, fileName));
22108
+ }
22109
+ break;
21973
22110
  }
21974
22111
  if (nodes.length > 0) sendElements.push(SendElement.forward(nodes));
21975
22112
  return {
@@ -26016,6 +26153,7 @@ var ActionName = /* @__PURE__ */ function(ActionName) {
26016
26153
  ActionName["SetInputStatus"] = "set_input_status";
26017
26154
  ActionName["GetGroupAlbumMediaList"] = "get_group_album_media_list";
26018
26155
  ActionName["GetGroupSignedList"] = "get_group_signed_list";
26156
+ ActionName["GetProfileLikeCount"] = "get_profile_like_count";
26019
26157
  ActionName["SendLike"] = "send_like";
26020
26158
  ActionName["GetLoginInfo"] = "get_login_info";
26021
26159
  ActionName["GetFriendList"] = "get_friend_list";
@@ -26455,6 +26593,7 @@ var GetStrangerInfo = class extends BaseAction {
26455
26593
  birthday_day: info.birthdayDay,
26456
26594
  labels: info.labels,
26457
26595
  is_vip: info.isVip,
26596
+ is_svip: info.isSvip,
26458
26597
  is_years_vip: info.isYearsVip,
26459
26598
  vip_level: info.vipLevel,
26460
26599
  remark: info.remark
@@ -31168,12 +31307,14 @@ var GetProfileLikeMe = class extends BaseAction {
31168
31307
  count: lib_default$1.union([Number, String]).default(20)
31169
31308
  });
31170
31309
  async _handle(payload) {
31171
- const ret = await this.ctx.ntUserApi.getProfileLikeMe(selfInfo.uid, +payload.count);
31172
- const users = ret.body.detail?.users ?? [];
31173
- for (const item of users) Object.assign(item, { uin: await this.ctx.ntUserApi.getUinByUid(item.uid) });
31310
+ const users = (await this.ctx.ntUserApi.getProfileLikeMe(selfInfo.uid, +payload.count)).body.voteInfo.users ?? [];
31311
+ for (const item of users) Object.assign(item, {
31312
+ uin: await this.ctx.ntUserApi.getUinByUid(item.uid),
31313
+ isFriend: await this.ctx.ntFriendApi.isFriend(item.uid)
31314
+ });
31174
31315
  return {
31175
31316
  users,
31176
- nextStart: ret.body.detail?.nextStart ?? 0
31317
+ nextStart: 0
31177
31318
  };
31178
31319
  }
31179
31320
  };
@@ -31685,12 +31826,14 @@ var GetProfileLike = class extends BaseAction {
31685
31826
  count: lib_default$1.union([Number, String]).default(20)
31686
31827
  });
31687
31828
  async _handle(payload) {
31688
- const ret = await this.ctx.ntUserApi.getProfileLike(selfInfo.uid, +payload.count);
31689
- const users = ret.body.detail?.users ?? [];
31690
- for (const item of users) Object.assign(item, { uin: await this.ctx.ntUserApi.getUinByUid(item.uid) });
31829
+ const users = (await this.ctx.ntUserApi.getProfileLike(selfInfo.uid, +payload.count)).body.favoriteInfo.users ?? [];
31830
+ for (const item of users) Object.assign(item, {
31831
+ uin: await this.ctx.ntUserApi.getUinByUid(item.uid),
31832
+ isFriend: await this.ctx.ntFriendApi.isFriend(item.uid)
31833
+ });
31691
31834
  return {
31692
31835
  users,
31693
- nextStart: ret.body.detail?.nextStart ?? 0
31836
+ nextStart: 0
31694
31837
  };
31695
31838
  }
31696
31839
  };
@@ -32519,6 +32662,17 @@ var GetGroupSignedList = class extends BaseAction {
32519
32662
  }
32520
32663
  };
32521
32664
  //#endregion
32665
+ //#region src/onebot11/action/llbot/user/GetProfileLikeCount.ts
32666
+ var GetProfileLikeCount = class extends BaseAction {
32667
+ actionName = ActionName.GetProfileLikeCount;
32668
+ payloadSchema = lib_default$1.object({ user_id: lib_default$1.union([Number, String]).required() });
32669
+ async _handle(payload) {
32670
+ const uid = await this.ctx.ntUserApi.getUidByUin(+payload.user_id);
32671
+ if (!uid) throw new Error("无法获取用户信息");
32672
+ return { count: (await this.ctx.ntUserApi.getProfileLikeCount(uid)).body.voteInfo.totalCount };
32673
+ }
32674
+ };
32675
+ //#endregion
32522
32676
  //#region src/onebot11/action/index.ts
32523
32677
  function initActionMap(adapter) {
32524
32678
  const actionHandlers = [
@@ -32576,6 +32730,7 @@ function initActionMap(adapter) {
32576
32730
  new SetInputStatus(adapter),
32577
32731
  new GetGroupAlbumMediaList(adapter),
32578
32732
  new GetGroupSignedList(adapter),
32733
+ new GetProfileLikeCount(adapter),
32579
32734
  new SendLike(adapter),
32580
32735
  new GetMsg(adapter),
32581
32736
  new GetLoginInfo$1(adapter),
@@ -34342,7 +34497,7 @@ var MessageEncoder = class {
34342
34497
  const { msgList } = await this.ctx.ntMsgApi.getSingleMsg(this.peer, msgSeq);
34343
34498
  source = msgList[0];
34344
34499
  }
34345
- if (source) this.elements.push(SendElement.reply(source.msgSeq, source.senderUin, source.msgTime, source.clientSeq));
34500
+ if (source) this.elements.push(SendElement.reply(source.msgSeq, source.senderUin, source.senderUid, source.msgTime, source.clientSeq));
34346
34501
  } else if (type === "face") this.elements.push(SendElement.face(+attrs.id, +attrs.type));
34347
34502
  else if (type === "author") Object.assign(this.stack[0].author, attrs);
34348
34503
  else if (type === "llonebot:market-face") this.elements.push(SendElement.mface(+attrs.emojiPackageId, attrs.emojiId, attrs.key, attrs.summary));
@@ -49951,7 +50106,7 @@ async function transformOutgoingMessage(ctx, segments, peerUid, isGroup, isInsid
49951
50106
  const { msgByteList } = await ctx.ntMsgApi.getSingleMsg(peer, segment.data.message_seq);
49952
50107
  srcMsg = msgByteList[0];
49953
50108
  }
49954
- elements.push(SendElement.reply(segment.data.message_seq, +msg.senderUin, +msg.msgTime, msg.clientSeq, srcMsg));
50109
+ elements.push(SendElement.reply(segment.data.message_seq, msg.senderUin, msg.senderUid, msg.msgTime, msg.clientSeq, srcMsg));
49955
50110
  } else if (segment.type === "image") {
49956
50111
  const imageBuffer = await resolveMilkyUri(segment.data.uri);
49957
50112
  const tempPath = path.join(TEMP_DIR, `image-${randomUUID()}`);
@@ -55330,6 +55485,7 @@ var NTFileApi = class extends Service {
55330
55485
  }
55331
55486
  return {
55332
55487
  fileId: result.fileId,
55488
+ fileSize: result.fileSize,
55333
55489
  fileMd5: result.md5.toString("hex")
55334
55490
  };
55335
55491
  }
@@ -55944,6 +56100,7 @@ var MessageBuilding = class MessageBuilding {
55944
56100
  chatType;
55945
56101
  peerUid;
55946
56102
  nestedForwardTrace;
56103
+ content;
55947
56104
  constructor(ctx, elements, chatType, peerUid, nestedForwardTrace = /* @__PURE__ */ new Map()) {
55948
56105
  this.ctx = ctx;
55949
56106
  this.inputElems = elements;
@@ -55974,16 +56131,16 @@ var MessageBuilding = class MessageBuilding {
55974
56131
  attr6Buf: attr6
55975
56132
  } });
55976
56133
  } else if (textElement.atType === 2) {
55977
- const attr6 = Buffer.alloc(20);
55978
- attr6.writeUInt16BE(1, 0);
55979
- attr6.writeUInt16BE(0, 2);
55980
- attr6.writeUInt16BE(textElement.content.length, 4);
55981
- attr6.writeUInt8(0, 6);
55982
- attr6.writeUInt32BE(textElement.atUin, 7);
55983
- attr6.writeUInt16BE(0, 11);
56134
+ const attr6Buf = Buffer.alloc(20);
56135
+ attr6Buf.writeUInt16BE(1, 0);
56136
+ attr6Buf.writeUInt16BE(0, 2);
56137
+ attr6Buf.writeUInt16BE(textElement.content.length, 4);
56138
+ attr6Buf.writeUInt8(0, 6);
56139
+ attr6Buf.writeUInt32BE(textElement.atUin, 7);
56140
+ attr6Buf.writeUInt16BE(0, 11);
55984
56141
  this.outputElems.push({ text: {
55985
56142
  str: textElement.content,
55986
- attr6Buf: attr6
56143
+ attr6Buf
55987
56144
  } });
55988
56145
  } else this.outputElems.push({ text: { str: textElement.content } });
55989
56146
  }
@@ -56068,9 +56225,31 @@ var MessageBuilding = class MessageBuilding {
56068
56225
  origSeqs: [replyElement.replyMsgClientSeq || replyElement.replyMsgSeq],
56069
56226
  senderUin: replyElement.senderUin,
56070
56227
  time: replyElement.replyMsgTime,
56071
- attr: { ntMsgSeq: replyElement.replyMsgClientSeq ? replyElement.replyMsgSeq : void 0 },
56228
+ attr: {
56229
+ senderUid: replyElement.senderUid,
56230
+ ntMsgSeq: replyElement.replyMsgClientSeq ? replyElement.replyMsgSeq : void 0
56231
+ },
56072
56232
  srcMsg: replyElement.srcMsg
56073
56233
  } });
56234
+ if (this.chatType === ChatType.Group) {
56235
+ const attr6Buf = Buffer.alloc(20);
56236
+ attr6Buf.writeUInt16BE(1, 0);
56237
+ attr6Buf.writeUInt16BE(0, 2);
56238
+ attr6Buf.writeUInt16BE(1, 4);
56239
+ attr6Buf.writeUInt8(0, 6);
56240
+ attr6Buf.writeUInt32BE(replyElement.senderUin, 7);
56241
+ attr6Buf.writeUInt16BE(0, 11);
56242
+ const pbReserve = Msg.TextResvAttr.encode({
56243
+ atType: 2,
56244
+ atMemberUin: 0,
56245
+ atMemberUid: replyElement.senderUid
56246
+ });
56247
+ this.outputElems.push({ text: {
56248
+ str: "@",
56249
+ attr6Buf,
56250
+ pbReserve
56251
+ } }, { text: { str: " " } });
56252
+ }
56074
56253
  }
56075
56254
  async [ElementType.Pic](data) {
56076
56255
  const { picElement: p } = data;
@@ -56130,7 +56309,7 @@ var MessageBuilding = class MessageBuilding {
56130
56309
  }, "");
56131
56310
  preview.push(`${node.senderName}: ${content}`);
56132
56311
  }
56133
- const elems = await new MessageBuilding(this.ctx, node.elements, this.chatType, this.peerUid, this.nestedForwardTrace).build();
56312
+ const { elems, content } = await new MessageBuilding(this.ctx, node.elements, this.chatType, this.peerUid, this.nestedForwardTrace).build();
56134
56313
  messages.push({
56135
56314
  routingHead: {
56136
56315
  fromUin: node.senderUin,
@@ -56157,7 +56336,10 @@ var MessageBuilding = class MessageBuilding {
56157
56336
  avatar: ""
56158
56337
  }
56159
56338
  },
56160
- body: { richText: { elems } }
56339
+ body: {
56340
+ richText: { elems },
56341
+ msgContent: content
56342
+ }
56161
56343
  });
56162
56344
  seq++;
56163
56345
  }
@@ -56200,9 +56382,53 @@ var MessageBuilding = class MessageBuilding {
56200
56382
  });
56201
56383
  this.outputElems.push({ lightApp: { data: Buffer.concat([Buffer.from([1]), deflateSync(Buffer.from(content, "utf-8"))]) } });
56202
56384
  }
56385
+ async [ElementType.File](data) {
56386
+ const fileName = data.fileElement.fileName;
56387
+ if (this.chatType === ChatType.Group) {
56388
+ const uploaded = await this.ctx.ntFileApi.uploadGroupFile(+this.peerUid, data.fileElement.filePath, fileName);
56389
+ const extra = Msg.GroupFileExtra.encode({
56390
+ field1: 6,
56391
+ fileName,
56392
+ inner: { info: {
56393
+ busId: 102,
56394
+ fileId: uploaded.fileId,
56395
+ fileSize: uploaded.fileSize,
56396
+ fileName,
56397
+ fileMd5: uploaded.fileMd5
56398
+ } }
56399
+ });
56400
+ const lenBuf = Buffer.alloc(2);
56401
+ lenBuf.writeUInt16BE(extra.length);
56402
+ this.outputElems.push({ transElemInfo: {
56403
+ elemType: 24,
56404
+ elemValue: Buffer.concat([
56405
+ Buffer.from([1]),
56406
+ lenBuf,
56407
+ extra
56408
+ ])
56409
+ } });
56410
+ } else {
56411
+ const uploaded = await this.ctx.ntFileApi.uploadPrivateFile(this.peerUid, data.fileElement.filePath, fileName);
56412
+ const extra = Msg.FileExtra.encode({ file: {
56413
+ fileType: 0,
56414
+ fileUuid: uploaded.fileId,
56415
+ fileMd5: uploaded.file10MMd5,
56416
+ fileName,
56417
+ fileSize: uploaded.fileSize,
56418
+ subCmd: 1,
56419
+ dangerLevel: 0,
56420
+ expireTime: Math.floor(Date.now() / 1e3 + 10080 * 60),
56421
+ fileIdCrcMedia: uploaded.crcMedia
56422
+ } });
56423
+ this.content = extra;
56424
+ }
56425
+ }
56203
56426
  async build() {
56204
56427
  for (const element of this.inputElems) await this[element.elementType].call(this, element);
56205
- return this.outputElems;
56428
+ return {
56429
+ elems: this.outputElems,
56430
+ content: this.content
56431
+ };
56206
56432
  }
56207
56433
  };
56208
56434
  //#endregion
@@ -56261,7 +56487,7 @@ var NTMsgApi = class extends Service {
56261
56487
  * 加重试是因为 server 入库 c2c 历史流稍滞后(~50-200ms)。
56262
56488
  */
56263
56489
  async sendMsg(peer, msgElements) {
56264
- const elems = await new MessageBuilding(this.ctx, msgElements, peer.chatType, peer.peerUid).build();
56490
+ const { elems, content } = await new MessageBuilding(this.ctx, msgElements, peer.chatType, peer.peerUid).build();
56265
56491
  let chatType = peer.chatType;
56266
56492
  let groupCode;
56267
56493
  if (peer.chatType === ChatType.Group) groupCode = +peer.peerUid;
@@ -56272,12 +56498,22 @@ var NTMsgApi = class extends Service {
56272
56498
  }
56273
56499
  const random = randomBytes(4).readUInt32BE(0);
56274
56500
  const echoP = peer.chatType === ChatType.Group ? this.waitForSelfEcho(peer, random, 7e3) : null;
56501
+ echoP?.catch(() => {});
56502
+ const fileElem = elems.find((e) => e.transElemInfo?.elemType === 24);
56503
+ if (fileElem) {
56504
+ const buf = fileElem.transElemInfo.elemValue.subarray(3);
56505
+ const extra = Msg.GroupFileExtra.decode(buf);
56506
+ const ret = await this.ctx.qqProtocol.feedGroupFile(groupCode, extra.inner.info.fileId, random);
56507
+ if (ret.feedsInfoRsp.retCode !== 0n) throw new Error(`发送文件失败 (code=${ret.feedsInfoRsp.retCode}): ${ret.feedsInfoRsp.clientWording}`);
56508
+ return await echoP;
56509
+ }
56275
56510
  const ret = await this.ctx.qqProtocol.sendMessage({
56276
56511
  chatType,
56277
56512
  groupCode,
56278
56513
  toUid: peer.chatType !== ChatType.Group ? peer.peerUid : void 0,
56279
56514
  elems,
56280
- random
56515
+ random,
56516
+ content
56281
56517
  });
56282
56518
  if (ret.resultCode !== 0) throw new Error(`发送消息失败 (code=${ret.resultCode}): ${ret.errMsg}`);
56283
56519
  return (echoP ? await echoP : void 0) ?? {
@@ -56630,6 +56866,7 @@ var NTUserApi = class extends Service {
56630
56866
  school: bytes.get(20021)?.toString() ?? "",
56631
56867
  remark: bytes.get(103)?.toString() ?? "",
56632
56868
  isVip: !!vipInfo,
56869
+ isSvip: !!vipInfo?.isPro,
56633
56870
  isYearsVip: !!vipInfo?.isYear,
56634
56871
  vipLevel: vipInfo?.level ?? 0
56635
56872
  };
@@ -56657,6 +56894,7 @@ var NTUserApi = class extends Service {
56657
56894
  school: bytes.get(20021)?.toString() ?? "",
56658
56895
  remark: bytes.get(103)?.toString() ?? "",
56659
56896
  isVip: !!vipInfo,
56897
+ isSvip: !!vipInfo?.isPro,
56660
56898
  isYearsVip: !!vipInfo?.isYear,
56661
56899
  vipLevel: vipInfo?.level ?? 0
56662
56900
  };
@@ -56696,6 +56934,9 @@ var NTUserApi = class extends Service {
56696
56934
  async getProfileLikeMe(uid, limit = 20) {
56697
56935
  return await this.ctx.qqProtocol.fetchProfileLikes(uid, 1, limit);
56698
56936
  }
56937
+ async getProfileLikeCount(uid) {
56938
+ return await this.ctx.qqProtocol.fetchProfileLikeCount(uid);
56939
+ }
56699
56940
  async modifySelfProfile(profile) {
56700
56941
  return await this.ctx.qqProtocol.modifySelfProfile({
56701
56942
  nick: profile.nick,
@@ -59391,6 +59632,7 @@ function createMessagesRoutes(ctx, createPicElement) {
59391
59632
  replyMsgSeq: Number(item.msgSeq),
59392
59633
  replyMsgTime: 0,
59393
59634
  senderUin: Number(item.uin ?? 0),
59635
+ senderUid: item.uid ?? "",
59394
59636
  replyMsgClientSeq: 0
59395
59637
  }
59396
59638
  });
@@ -60003,6 +60245,24 @@ function createProxyRoutes(ctx) {
60003
60245
  }, 500);
60004
60246
  }
60005
60247
  });
60248
+ router.get("/rkey", async (c) => {
60249
+ try {
60250
+ const rkeyData = await ctx.ntFileApi.rkeyManager.getRkey();
60251
+ return c.json({
60252
+ success: true,
60253
+ data: {
60254
+ private_rkey: rkeyData.private_rkey || "",
60255
+ group_rkey: rkeyData.group_rkey || ""
60256
+ }
60257
+ });
60258
+ } catch (e) {
60259
+ ctx.logger.warn("获取 rkey 失败:", e);
60260
+ return c.json({
60261
+ success: false,
60262
+ message: "获取 rkey 失败"
60263
+ }, 500);
60264
+ }
60265
+ });
60006
60266
  router.get("/audio-proxy", async (c) => {
60007
60267
  try {
60008
60268
  const fileUuid = c.req.query("fileUuid");
@@ -73252,7 +73512,34 @@ var DirectProtocolClient = class extends EventEmitter {
73252
73512
  "trpc.o3.ecdh_access.EcdhAccess.SsoEstablishShareKey",
73253
73513
  "trpc.o3.ecdh_access.EcdhAccess.SsoSecureAccess",
73254
73514
  "MessageSvc.PbSendMsg",
73255
- "OidbSvcTrpcTcp.0x6d9_4"
73515
+ "OidbSvcTrpcTcp.0x6d9_4",
73516
+ "OidbSvcTrpcTcp.0x929b_0",
73517
+ "OidbSvcTrpcTcp.0xfe1_2",
73518
+ "OidbSvcTrpcTcp.0xfe1_8",
73519
+ "OidbSvcTrpcTcp.0x102a_1",
73520
+ "OidbSvcTrpcTcp.0x102a_0",
73521
+ "OidbSvcTrpcTcp.0xfd4_1",
73522
+ "OidbSvcTrpcTcp.0xfe5_2",
73523
+ "OidbSvcTrpcTcp.0x5cf_11",
73524
+ "OidbSvcTrpcTcp.0x10c0_1",
73525
+ "OidbSvcTrpcTcp.0x10c0_2",
73526
+ "OidbSvcTrpcTcp.0x10c8_1",
73527
+ "OidbSvcTrpcTcp.0x972_6",
73528
+ "OidbSvcTrpcTcp.0x8fc_3",
73529
+ "OidbSvcTrpcTcp.0x6d6_2",
73530
+ "OidbSvcTrpcTcp.0x6d6_3",
73531
+ "OidbSvcTrpcTcp.0xe37_1700",
73532
+ "OidbSvcTrpcTcp.0xe37_1200",
73533
+ "OidbSvcTrpcTcp.0x11c5_100",
73534
+ "OidbSvcTrpcTcp.0x11c5_200",
73535
+ "OidbSvcTrpcTcp.0x11c4_100",
73536
+ "OidbSvcTrpcTcp.0x11c4_200",
73537
+ "OidbSvcTrpcTcp.0x11e9_100",
73538
+ "OidbSvcTrpcTcp.0x11e9_200",
73539
+ "OidbSvcTrpcTcp.0x126d_200",
73540
+ "OidbSvcTrpcTcp.0x126e_200",
73541
+ "trpc.group.long_msg_interface.MsgService.SsoRecvLongMsg",
73542
+ "OidbSvcTrpcTcp.0x88d_0"
73256
73543
  ]);
73257
73544
  async sendCommand(cmd, payload, encryptType, timeout = 15e3) {
73258
73545
  const seq = this.nextSeq();
@@ -73338,17 +73625,22 @@ var DirectProtocolClient = class extends EventEmitter {
73338
73625
  await this.ensureSignTokenFresh(uin);
73339
73626
  }
73340
73627
  /**
73341
- * sendCommand 前调. 刷新机制暂时禁用 -> 只首拉一次, 拉到后整个进程生命周期不再刷:
73628
+ * sendCommand 前调. 按服务端下发的 TTL 续期:
73342
73629
  * 1. 没 session / 没 uin -> noop
73343
- * 2. 从没拉过 (expiresAt undefined) -> 拉一次
73344
- * 3. 已拉到过 (有 expiresAt, 含 403 软降级的空 token) -> 不刷
73630
+ * 2. 从没拉过 (expiresAt undefined) -> 首拉一次
73631
+ * 3. 有非空 token 且未过期 -> 复用不刷
73632
+ * 4. 有非空 token 但已过期 -> 重新 acquire 续期 (续期失败按 lastFetchAt 限最小重试间隔)
73633
+ * 5. 空 token (403 软降级) -> 不刷, 免得 403 情况每次发包都去重试 acquire
73345
73634
  * signToken12B/expiresAt 不落盘 (见 session.ts), 每次启动/恢复都从 undefined 起,
73346
73635
  * 故登录后 tryAcquireSignToken 必首拉一次。in-flight lock 防并发雪崩。
73347
- * 代价: 12B token 服务端有 TTL, 过期后本地不续 -> sign 失败, 需重启 bot 重新登录。
73348
73636
  */
73349
73637
  async ensureSignTokenFresh(uin) {
73350
73638
  if (!this.session || !uin || !this.config.authToken) return;
73351
- if (this.session.signTokenExpiresAt) return;
73639
+ if (this.session.signTokenExpiresAt) {
73640
+ const expired = Date.now() >= this.session.signTokenExpiresAt;
73641
+ if (!this.session.signToken12B || !expired) return;
73642
+ if (Date.now() - this.signTokenLastFetchAt < 3e4) return;
73643
+ }
73352
73644
  if (this.signTokenRefreshInflight) return;
73353
73645
  this.signTokenRefreshInflight = (async () => {
73354
73646
  try {
@@ -74348,14 +74640,6 @@ function handleLine(socket, line) {
74348
74640
  }
74349
74641
  //#endregion
74350
74642
  //#region src/main/qqProtocol/base.ts
74351
- var requireForVersion = createRequire(import.meta.url);
74352
- function readBotVersion() {
74353
- try {
74354
- return requireForVersion("../../../../package.json").version ?? "unknown";
74355
- } catch {
74356
- return "unknown";
74357
- }
74358
- }
74359
74643
  var QQProtocolBase = class extends Service {
74360
74644
  ctx;
74361
74645
  static inject = ["config"];
@@ -74700,7 +74984,7 @@ var QQProtocolBase = class extends Service {
74700
74984
  const uinForInit = persisted ? Number(persisted.uin) : void 0;
74701
74985
  this.directClient = new DirectProtocolClient({
74702
74986
  authToken,
74703
- botVersion: readBotVersion(),
74987
+ botVersion: `LLBot_${version$3}`,
74704
74988
  uin: Number.isFinite(uinForInit) && uinForInit > 0 ? uinForInit : void 0
74705
74989
  });
74706
74990
  this.directClient.on("error", (err) => {
@@ -77034,7 +77318,11 @@ function MessageMixin(Base) {
77034
77318
  const random = opts.random ?? randomBytes(4).readUInt32BE(0);
77035
77319
  const clientSequence = 1e4 + Math.floor(Math.random() * 9e4);
77036
77320
  const data = Msg.PbSendMsg.encode({
77037
- routingHead: {
77321
+ routingHead: opts.content ? { trans0X211: {
77322
+ toUin: opts.toUin,
77323
+ ccCmd: 4,
77324
+ uid: opts.toUid
77325
+ } } : {
77038
77326
  1: { c2c: {
77039
77327
  toUin: opts.toUin,
77040
77328
  toUid: opts.toUid
@@ -77051,7 +77339,10 @@ function MessageMixin(Base) {
77051
77339
  divSeq: 0,
77052
77340
  autoReply: 0
77053
77341
  },
77054
- body: { richText: { elems: opts.elems } },
77342
+ body: {
77343
+ richText: { elems: opts.elems },
77344
+ msgContent: opts.content
77345
+ },
77055
77346
  clientSequence,
77056
77347
  random
77057
77348
  });
@@ -77085,7 +77376,7 @@ function MessageMixin(Base) {
77085
77376
  } });
77086
77377
  const data = Msg.PbSendMsg.encode({
77087
77378
  routingHead: { trans0X211: {
77088
- toUin: BigInt(opts.toUin),
77379
+ toUin: opts.toUin,
77089
77380
  ccCmd: 4,
77090
77381
  uid: opts.toUid
77091
77382
  } },
@@ -77218,8 +77509,7 @@ function UserMixin(Base) {
77218
77509
  const data = Oidb.Base.encode({
77219
77510
  command: 4065,
77220
77511
  subCommand: 2,
77221
- body,
77222
- ...process.env.QQ_USE_PMHQ ? { isReserved: 1 } : {}
77512
+ body
77223
77513
  });
77224
77514
  const res = await this.sendPB("OidbSvcTrpcTcp.0xfe1_2", data);
77225
77515
  const decoded = Oidb.Base.decode(Buffer.from(res.pb, "hex"));
@@ -77286,9 +77576,9 @@ function UserMixin(Base) {
77286
77576
  return Oidb.FetchCookiesResp.decode(decoded.body);
77287
77577
  }
77288
77578
  /** 获取赞过我或我赞过的列表。direction: 0=我赞过的, 1=赞过我的。OidbSvcTrpcTcp.0x7ed_13 */
77289
- async fetchProfileLikes(targetUid, direction, count) {
77579
+ async fetchProfileLikes(selfUid, direction, count) {
77290
77580
  const body = Oidb.FetchProfileLikeReq.encode({
77291
- targetUid,
77581
+ selfUid,
77292
77582
  field2: 1,
77293
77583
  direction,
77294
77584
  field4: direction === 0 ? 1 : 0,
@@ -77305,6 +77595,17 @@ function UserMixin(Base) {
77305
77595
  const decoded = Oidb.Base.decode(Buffer.from(res.pb, "hex"));
77306
77596
  return Oidb.FetchProfileLikeResp.decode(decoded.body);
77307
77597
  }
77598
+ async fetchProfileLikeCount(uid) {
77599
+ const body = Oidb.FetchProfileLikeCountReq.encode({ uid });
77600
+ const data = Oidb.Base.encode({
77601
+ command: 2029,
77602
+ subCommand: 12,
77603
+ body
77604
+ });
77605
+ const res = await this.sendPB("OidbSvcTrpcTcp.0x7ed_12", data);
77606
+ const decoded = Oidb.Base.decode(Buffer.from(res.pb, "hex"));
77607
+ return Oidb.FetchProfileLikeCountResp.decode(decoded.body);
77608
+ }
77308
77609
  /** 修改自己的资料 (OidbSvcTrpcTcp.0x112a_2) */
77309
77610
  async modifySelfProfile(profile) {
77310
77611
  const bytesProperties = [];
@@ -77738,6 +78039,12 @@ async function onLoad() {
77738
78039
  else ctx.qqProtocol.startHook();
77739
78040
  });
77740
78041
  }
78042
+ process.on("unhandledRejection", (reason) => {
78043
+ console.error("[unhandledRejection]", reason);
78044
+ });
78045
+ process.on("uncaughtException", (err) => {
78046
+ console.error("[uncaughtException]", err);
78047
+ });
77741
78048
  onLoad().catch((e) => console.error(e));
77742
78049
  //#endregion
77743
78050
  export {};