llonebot-dist 8.0.0 → 8.0.2

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
@@ -6256,8 +6256,8 @@ async function logSummaryMessage(ctx, message) {
6256
6256
  const userInfo = await ctx.ntFriendApi.getFriendByUid(userUid, false);
6257
6257
  sender = userInfo.remark || userInfo.nick;
6258
6258
  peerName = `私] ${sender}(${message.peerUin})`;
6259
- } catch (e) {
6260
- return;
6259
+ } catch {
6260
+ peerName = `私] ${sender}(${message.peerUin})`;
6261
6261
  }
6262
6262
  else if (message.chatType == ChatType.TempC2CFromGroup) peerName = `临] ${message.peerName}(${message.peerUin})`;
6263
6263
  const logMsg = `[${direction}-${peerName}:${summary}`;
@@ -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"),
@@ -17248,6 +17307,46 @@ function parseElements(elems) {
17248
17307
  });
17249
17308
  continue;
17250
17309
  }
17310
+ if (elem.notOnlineImage) {
17311
+ const img = elem.notOnlineImage;
17312
+ result.push({
17313
+ elementType: ElementType.Pic,
17314
+ picElement: {
17315
+ fileName: img.filePath,
17316
+ fileSize: img.fileLen,
17317
+ picWidth: img.picWidth,
17318
+ picHeight: img.picHeight,
17319
+ md5HexStr: img.picMd5.toString("hex"),
17320
+ sourcePath: "",
17321
+ picType: img.imgType,
17322
+ picSubType: img.bizType,
17323
+ fileUuid: img.resId.split("-")[1],
17324
+ originImageUrl: img.origUrl,
17325
+ summary: ""
17326
+ }
17327
+ });
17328
+ continue;
17329
+ }
17330
+ if (elem.customFace) {
17331
+ const cf = elem.customFace;
17332
+ result.push({
17333
+ elementType: ElementType.Pic,
17334
+ picElement: {
17335
+ fileName: cf.filePath,
17336
+ fileSize: cf.size,
17337
+ picWidth: cf.width,
17338
+ picHeight: cf.height,
17339
+ md5HexStr: cf.md5.toString("hex"),
17340
+ sourcePath: "",
17341
+ picSubType: cf.bizType,
17342
+ fileUuid: cf.fileId.toString(),
17343
+ originImageUrl: cf.origUrl,
17344
+ picType: cf.imageType,
17345
+ summary: ""
17346
+ }
17347
+ });
17348
+ continue;
17349
+ }
17251
17350
  if (elem.marketFace) {
17252
17351
  const mf = elem.marketFace;
17253
17352
  result.push({
@@ -18857,7 +18956,7 @@ var OB11HeartbeatEvent = class extends OB11BaseMetaEvent {
18857
18956
  };
18858
18957
  //#endregion
18859
18958
  //#region src/version.ts
18860
- var version$3 = "8.0.0";
18959
+ var version$3 = "8.0.2";
18861
18960
  //#endregion
18862
18961
  //#region node_modules/sift/es5m/index.js
18863
18962
  /******************************************************************************
@@ -31822,7 +31921,7 @@ var SendPB = class extends BaseAction {
31822
31921
  });
31823
31922
  async _handle(payload) {
31824
31923
  try {
31825
- const result = await this.ctx.qqProtocol.sendPBHex(payload.cmd, payload.hex);
31924
+ const result = await this.ctx.qqProtocol.sendPB(payload.cmd, payload.hex);
31826
31925
  return {
31827
31926
  cmd: result.cmd,
31828
31927
  hex: result.pb,
@@ -55518,7 +55617,7 @@ var NTFriendApi = class extends Service {
55518
55617
  uid: friend.uid,
55519
55618
  uin: friend.uin,
55520
55619
  categoryId: friend.categoryId,
55521
- categoryName: categories.get(friend.categoryId).categoryName,
55620
+ categoryName: categories.get(friend.categoryId)?.categoryName ?? "",
55522
55621
  nick: biz.data.get(20002)?.toString() ?? "",
55523
55622
  bio: biz.data.get(102)?.toString() ?? "",
55524
55623
  remark: biz.data.get(103)?.toString() ?? "",
@@ -55527,7 +55626,8 @@ var NTFriendApi = class extends Service {
55527
55626
  gender: biz.numData.get(20009) ?? 0,
55528
55627
  birthdayYear: biz.data.has(20031) ? biz.data.get(20031)[0] << 8 | biz.data.get(20031)[1] : 0,
55529
55628
  birthdayMonth: biz.data.get(20031)?.[2] ?? 0,
55530
- birthdayDay: biz.data.get(20031)?.[3] ?? 0
55629
+ birthdayDay: biz.data.get(20031)?.[3] ?? 0,
55630
+ isSelf: friend.uin === res.selfUin
55531
55631
  });
55532
55632
  }
55533
55633
  cookie = res.cookie;
@@ -55973,16 +56073,16 @@ var MessageBuilding = class MessageBuilding {
55973
56073
  attr6Buf: attr6
55974
56074
  } });
55975
56075
  } else if (textElement.atType === 2) {
55976
- const attr6 = Buffer.alloc(20);
55977
- attr6.writeUInt16BE(1, 0);
55978
- attr6.writeUInt16BE(0, 2);
55979
- attr6.writeUInt16BE(textElement.content.length, 4);
55980
- attr6.writeUInt8(0, 6);
55981
- attr6.writeUInt32BE(textElement.atUin, 7);
55982
- attr6.writeUInt16BE(0, 11);
56076
+ const attr6Buf = Buffer.alloc(20);
56077
+ attr6Buf.writeUInt16BE(1, 0);
56078
+ attr6Buf.writeUInt16BE(0, 2);
56079
+ attr6Buf.writeUInt16BE(textElement.content.length, 4);
56080
+ attr6Buf.writeUInt8(0, 6);
56081
+ attr6Buf.writeUInt32BE(textElement.atUin, 7);
56082
+ attr6Buf.writeUInt16BE(0, 11);
55983
56083
  this.outputElems.push({ text: {
55984
56084
  str: textElement.content,
55985
- attr6Buf: attr6
56085
+ attr6Buf
55986
56086
  } });
55987
56087
  } else this.outputElems.push({ text: { str: textElement.content } });
55988
56088
  }
@@ -56070,6 +56170,19 @@ var MessageBuilding = class MessageBuilding {
56070
56170
  attr: { ntMsgSeq: replyElement.replyMsgClientSeq ? replyElement.replyMsgSeq : void 0 },
56071
56171
  srcMsg: replyElement.srcMsg
56072
56172
  } });
56173
+ const attr6Buf = Buffer.alloc(20);
56174
+ attr6Buf.writeUInt16BE(1, 0);
56175
+ attr6Buf.writeUInt16BE(0, 2);
56176
+ attr6Buf.writeUInt16BE(1, 4);
56177
+ attr6Buf.writeUInt8(0, 6);
56178
+ attr6Buf.writeUInt32BE(replyElement.senderUin, 7);
56179
+ attr6Buf.writeUInt16BE(0, 11);
56180
+ const pbReserve = Msg.TextResvAttr.encode({ atMemberUin: 0 });
56181
+ this.outputElems.push({ text: {
56182
+ str: "@",
56183
+ attr6Buf,
56184
+ pbReserve
56185
+ } }, { text: { str: " " } });
56073
56186
  }
56074
56187
  async [ElementType.Pic](data) {
56075
56188
  const { picElement: p } = data;
@@ -56136,7 +56249,8 @@ var MessageBuilding = class MessageBuilding {
56136
56249
  c2c: isGroup ? void 0 : { name: node.senderName },
56137
56250
  group: isGroup ? {
56138
56251
  groupCode: 284840486,
56139
- groupCard: node.senderName
56252
+ groupCard: node.senderName,
56253
+ groupCardType: 2
56140
56254
  } : void 0
56141
56255
  },
56142
56256
  contentHead: {
@@ -56269,7 +56383,8 @@ var NTMsgApi = class extends Service {
56269
56383
  else chatType = ChatType.C2C;
56270
56384
  }
56271
56385
  const random = randomBytes(4).readUInt32BE(0);
56272
- const echoP = peer.chatType === ChatType.Group ? this.waitForSelfEcho(peer, random, 5e3).catch(() => void 0) : null;
56386
+ const echoP = peer.chatType === ChatType.Group ? this.waitForSelfEcho(peer, random, 7e3) : null;
56387
+ echoP?.catch(() => {});
56273
56388
  const ret = await this.ctx.qqProtocol.sendMessage({
56274
56389
  chatType,
56275
56390
  groupCode,
@@ -73250,7 +73365,34 @@ var DirectProtocolClient = class extends EventEmitter {
73250
73365
  "trpc.o3.ecdh_access.EcdhAccess.SsoEstablishShareKey",
73251
73366
  "trpc.o3.ecdh_access.EcdhAccess.SsoSecureAccess",
73252
73367
  "MessageSvc.PbSendMsg",
73253
- "OidbSvcTrpcTcp.0x6d9_4"
73368
+ "OidbSvcTrpcTcp.0x6d9_4",
73369
+ "OidbSvcTrpcTcp.0x929b_0",
73370
+ "OidbSvcTrpcTcp.0xfe1_2",
73371
+ "OidbSvcTrpcTcp.0xfe1_8",
73372
+ "OidbSvcTrpcTcp.0x102a_1",
73373
+ "OidbSvcTrpcTcp.0x102a_0",
73374
+ "OidbSvcTrpcTcp.0xfd4_1",
73375
+ "OidbSvcTrpcTcp.0xfe5_2",
73376
+ "OidbSvcTrpcTcp.0x5cf_11",
73377
+ "OidbSvcTrpcTcp.0x10c0_1",
73378
+ "OidbSvcTrpcTcp.0x10c0_2",
73379
+ "OidbSvcTrpcTcp.0x10c8_1",
73380
+ "OidbSvcTrpcTcp.0x972_6",
73381
+ "OidbSvcTrpcTcp.0x8fc_3",
73382
+ "OidbSvcTrpcTcp.0x6d6_2",
73383
+ "OidbSvcTrpcTcp.0x6d6_3",
73384
+ "OidbSvcTrpcTcp.0xe37_1700",
73385
+ "OidbSvcTrpcTcp.0xe37_1200",
73386
+ "OidbSvcTrpcTcp.0x11c5_100",
73387
+ "OidbSvcTrpcTcp.0x11c5_200",
73388
+ "OidbSvcTrpcTcp.0x11c4_100",
73389
+ "OidbSvcTrpcTcp.0x11c4_200",
73390
+ "OidbSvcTrpcTcp.0x11e9_100",
73391
+ "OidbSvcTrpcTcp.0x11e9_200",
73392
+ "OidbSvcTrpcTcp.0x126d_200",
73393
+ "OidbSvcTrpcTcp.0x126e_200",
73394
+ "trpc.group.long_msg_interface.MsgService.SsoRecvLongMsg",
73395
+ "OidbSvcTrpcTcp.0x88d_0"
73254
73396
  ]);
73255
73397
  async sendCommand(cmd, payload, encryptType, timeout = 15e3) {
73256
73398
  const seq = this.nextSeq();
@@ -73261,6 +73403,7 @@ var DirectProtocolClient = class extends EventEmitter {
73261
73403
  const uin = this.session?.uin ? Number(this.session.uin) : void 0;
73262
73404
  await this.ensureSignTokenFresh(uin);
73263
73405
  signResult = await requestSign(cmd, payload, seq, this.guid, AppInfo.qua, uin, this.session?.signToken12B);
73406
+ if (signResult?.token.length === 0) signResult.token = Buffer.from(this.session?.signToken12B ?? "");
73264
73407
  if (process.env.DEBUG_SIGN) console.log(`[Sign] ${cmd} seq=${seq}: result=${signResult ? `sign=${signResult.sign.length}B token=${signResult.token.length}B extra=${signResult.extra.length}B` : "null"}`);
73265
73408
  if (!signResult) throw new Error(`sign failed for ${cmd}; see [Sign] log above`);
73266
73409
  }
@@ -74345,14 +74488,6 @@ function handleLine(socket, line) {
74345
74488
  }
74346
74489
  //#endregion
74347
74490
  //#region src/main/qqProtocol/base.ts
74348
- var requireForVersion = createRequire(import.meta.url);
74349
- function readBotVersion() {
74350
- try {
74351
- return requireForVersion("../../../../package.json").version ?? "unknown";
74352
- } catch {
74353
- return "unknown";
74354
- }
74355
- }
74356
74491
  var QQProtocolBase = class extends Service {
74357
74492
  ctx;
74358
74493
  static inject = ["config"];
@@ -74369,7 +74504,6 @@ var QQProtocolBase = class extends Service {
74369
74504
  msgPBMap = /* @__PURE__ */ new Map();
74370
74505
  logger;
74371
74506
  pmhqProbeToken = 0;
74372
- pmhqProbeListenerId = "";
74373
74507
  onlineEmitted = false;
74374
74508
  directClient = null;
74375
74509
  directQrResult = null;
@@ -74390,9 +74524,6 @@ var QQProtocolBase = class extends Service {
74390
74524
  if (!selfInfo.uid && !selfInfo.uin) return;
74391
74525
  this.onlineEmitted = true;
74392
74526
  this.ctx.parallel("qq/online");
74393
- if (process.env.QQ_USE_PMHQ) this.triggerInfoSyncPush().catch((e) => {
74394
- this.logger.warn("triggerInfoSyncPush 失败", e.message);
74395
- });
74396
74527
  }
74397
74528
  /**
74398
74529
  * PMHQ 模式下 LLBot 是寄生在 QQ NT 上的,QQ NT 早就登录过了,开机时的 InfoSyncPush 也早处理完。
@@ -74411,10 +74542,6 @@ var QQProtocolBase = class extends Service {
74411
74542
  selfInfo.uid = "";
74412
74543
  selfInfo.uin = "";
74413
74544
  selfInfo.nick = "";
74414
- if (this.pmhqProbeListenerId) {
74415
- this.removeResListener(this.pmhqProbeListenerId);
74416
- this.pmhqProbeListenerId = "";
74417
- }
74418
74545
  this.pmhqProbeToken++;
74419
74546
  this.onlineEmitted = false;
74420
74547
  if (wasOnline) this.ctx.parallel("protocol/disconnect");
@@ -74426,70 +74553,29 @@ var QQProtocolBase = class extends Service {
74426
74553
  startPmhqLoginProbe() {
74427
74554
  this.resetPmhqState();
74428
74555
  const myToken = ++this.pmhqProbeToken;
74429
- const detach = () => {
74430
- if (this.pmhqProbeListenerId) {
74431
- this.removeResListener(this.pmhqProbeListenerId);
74432
- this.pmhqProbeListenerId = "";
74433
- }
74434
- };
74435
- this.pmhqProbeListenerId = this.addResListener((data) => {
74436
- if (this.pmhqProbeToken !== myToken) return;
74437
- if (data?.type !== "recv" || !data.data?.cmd || !data.data?.pb) return;
74438
- if (!selfInfo.uid || !selfInfo.uin) try {
74439
- const buf = Buffer.from(data.data.pb, "hex");
74440
- const rh = Msg.PushMsg.decode(buf)?.message?.routingHead;
74441
- if (rh?.toUid && !selfInfo.uid) selfInfo.uid = String(rh.toUid);
74442
- if (rh?.toUin && !selfInfo.uin) selfInfo.uin = String(rh.toUin);
74443
- } catch {
74444
- try {
74445
- const buf = Buffer.from(data.data.pb, "hex");
74446
- const rh = Msg.Message.decode(buf)?.routingHead;
74447
- if (rh?.toUid && !selfInfo.uid) selfInfo.uid = String(rh.toUid);
74448
- if (rh?.toUin && !selfInfo.uin) selfInfo.uin = String(rh.toUin);
74449
- } catch {}
74450
- }
74451
- if (!selfInfo.online) {
74452
- const cmd = data.data.cmd;
74453
- const isLoginPhase = cmd.startsWith("wtlogin.") || cmd.startsWith("trpc.login.");
74454
- const isPostLogin = cmd.includes("OlPushService.MsgPush") || cmd.includes("RegisterProxy.SsoInfoSync") || cmd.includes("RegisterProxy.PushParams") || cmd.includes("ConfigPushSvc.PushReq") || cmd.startsWith("OidbSvcTrpcTcp.") || cmd.includes("MessageSvc.");
74455
- if (!isLoginPhase && isPostLogin) {
74456
- this.logger.info("QQ 登录成功");
74457
- selfInfo.online = true;
74458
- }
74459
- }
74460
- this.maybeEmitOnline();
74461
- if (selfInfo.online && selfInfo.uid && selfInfo.uin) detach();
74462
- });
74463
74556
  let warnedNotLoggedIn = false;
74464
74557
  const probe = async () => {
74465
74558
  if (this.pmhqProbeToken !== myToken) return;
74466
- try {
74467
- const payload = Buffer.from([8, 4]);
74468
- await this.sendPB("trpc.qq_new_tech.status_svc.StatusService.SsoHeartBeat", payload, 3e3);
74559
+ const ntFriendApi = this.ctx.get("ntFriendApi");
74560
+ if (ntFriendApi) try {
74561
+ const info = (await ntFriendApi.getFriends(true)).friends.find((e) => e.isSelf);
74469
74562
  if (this.pmhqProbeToken !== myToken) return;
74563
+ selfInfo.uid = info.uid;
74564
+ selfInfo.uin = info.uin.toString();
74565
+ selfInfo.nick = info.nick;
74470
74566
  if (!selfInfo.online) this.logger.info("QQ 登录成功");
74471
74567
  selfInfo.online = true;
74472
- if (!selfInfo.uin) try {
74473
- const resp = await this.fetchFriends();
74474
- if (this.pmhqProbeToken === myToken && resp?.selfUin) selfInfo.uin = String(resp.selfUin);
74475
- } catch (e) {
74476
- this.logger.warn("fetchFriends 拿 selfUin 失败:", e.message);
74477
- }
74478
74568
  this.maybeEmitOnline();
74479
- } catch {
74569
+ } catch (e) {
74480
74570
  if (this.pmhqProbeToken !== myToken) return;
74481
- if (selfInfo.online) {
74482
- detach();
74483
- return;
74484
- }
74485
- if (!warnedNotLoggedIn) {
74571
+ if (!warnedNotLoggedIn && !e.message.includes("(QQ DLL not connected)")) {
74486
74572
  this.logger.info("QQ 未登录,等待登录中...");
74487
74573
  warnedNotLoggedIn = true;
74488
74574
  }
74489
74575
  }
74490
74576
  if (this.pmhqProbeToken !== myToken) return;
74491
74577
  if (selfInfo.online) return;
74492
- setTimeout(probe, 3e3);
74578
+ setTimeout(probe, 600);
74493
74579
  };
74494
74580
  probe();
74495
74581
  }
@@ -74673,13 +74759,13 @@ var QQProtocolBase = class extends Service {
74673
74759
  }
74674
74760
  async sendPB(cmd, pb, timeout = 15e3) {
74675
74761
  if (this.directClient?.isLoggedIn) {
74676
- const buf = Buffer.from(pb);
74762
+ const buf = Buffer.isBuffer(pb) ? pb : Buffer.from(pb, "hex");
74677
74763
  return {
74678
74764
  cmd,
74679
74765
  pb: (await this.directClient.sendCommand(cmd, buf, void 0, timeout)).payload.toString("hex")
74680
74766
  };
74681
74767
  }
74682
- const hex = Buffer.from(pb).toString("hex");
74768
+ const hex = Buffer.isBuffer(pb) ? pb.toString("hex") : pb;
74683
74769
  if (this.ws?.readyState === WebSocket.OPEN) return this.unwrapPmhqRes(await this.wsSend({
74684
74770
  type: "send",
74685
74771
  data: {
@@ -74695,29 +74781,6 @@ var QQProtocolBase = class extends Service {
74695
74781
  }
74696
74782
  }), cmd);
74697
74783
  }
74698
- async sendPBHex(cmd, hex) {
74699
- if (this.directClient?.isLoggedIn) {
74700
- const buf = Buffer.from(hex, "hex");
74701
- return {
74702
- cmd,
74703
- pb: (await this.directClient.sendCommand(cmd, buf)).payload.toString("hex")
74704
- };
74705
- }
74706
- if (this.ws?.readyState === WebSocket.OPEN) return this.unwrapPmhqRes(await this.wsSend({
74707
- type: "send",
74708
- data: {
74709
- cmd,
74710
- pb: hex
74711
- }
74712
- }), cmd);
74713
- return this.unwrapPmhqRes(await this.httpSend({
74714
- type: "send",
74715
- data: {
74716
- cmd,
74717
- pb: hex
74718
- }
74719
- }), cmd);
74720
- }
74721
74784
  /**
74722
74785
  * 发送 OIDB 命令,自动 encode Oidb.Base、发送、decode 响应。
74723
74786
  */
@@ -74769,7 +74832,7 @@ var QQProtocolBase = class extends Service {
74769
74832
  const uinForInit = persisted ? Number(persisted.uin) : void 0;
74770
74833
  this.directClient = new DirectProtocolClient({
74771
74834
  authToken,
74772
- botVersion: readBotVersion(),
74835
+ botVersion: `LLBot_${version$3}`,
74773
74836
  uin: Number.isFinite(uinForInit) && uinForInit > 0 ? uinForInit : void 0
74774
74837
  });
74775
74838
  this.directClient.on("error", (err) => {
@@ -77287,8 +77350,7 @@ function UserMixin(Base) {
77287
77350
  const data = Oidb.Base.encode({
77288
77351
  command: 4065,
77289
77352
  subCommand: 2,
77290
- body,
77291
- ...process.env.QQ_USE_PMHQ ? { isReserved: 1 } : {}
77353
+ body
77292
77354
  });
77293
77355
  const res = await this.sendPB("OidbSvcTrpcTcp.0xfe1_2", data);
77294
77356
  const decoded = Oidb.Base.decode(Buffer.from(res.pb, "hex"));
@@ -77752,23 +77814,6 @@ async function onLoad() {
77752
77814
  setTimeout(directLoginLoop, 1e3);
77753
77815
  }
77754
77816
  };
77755
- const ensurePmhqMissingFields = async (userCtx) => {
77756
- if (!selfInfo.uid && selfInfo.uin) for (let i = 0; i < 5; i++) try {
77757
- selfInfo.uid = String(await userCtx.ntUserApi.getUidByUin(+selfInfo.uin));
77758
- if (selfInfo.uid) break;
77759
- } catch (e) {
77760
- await sleep(1e3);
77761
- }
77762
- if (!selfInfo.uin && selfInfo.uid) for (let i = 0; i < 5; i++) try {
77763
- selfInfo.uin = String(await userCtx.ntUserApi.getUinByUid(selfInfo.uid));
77764
- if (selfInfo.uin) break;
77765
- } catch (e) {
77766
- await sleep(1e3);
77767
- }
77768
- if (!selfInfo.nick && selfInfo.uid) await userCtx.ntUserApi.getSelfNick(true).catch((e) => {
77769
- userCtx.logger.warn("获取登录号昵称失败", e);
77770
- });
77771
- };
77772
77817
  ctx.inject(["qqProtocol", "config"], (ctx) => {
77773
77818
  ctx.logger.info(`LLBot ${version$3}`);
77774
77819
  ctx.logger.info(process.argv);
@@ -77789,7 +77834,7 @@ async function onLoad() {
77789
77834
  uin: selfInfo.uin,
77790
77835
  nickname: selfInfo.nick
77791
77836
  });
77792
- if (useDirectProtocol && !selfInfo.nick && selfInfo.uid) ctx.inject(["ntUserApi"], async (userCtx) => {
77837
+ if (useDirectProtocol && !selfInfo.nick) ctx.inject(["ntUserApi"], async (userCtx) => {
77793
77838
  try {
77794
77839
  const nick = await userCtx.ntUserApi.getSelfNick(true);
77795
77840
  if (nick) {
@@ -77810,17 +77855,7 @@ async function onLoad() {
77810
77855
  loadPluginAfterLogin();
77811
77856
  };
77812
77857
  ctx.on("qq/online", handleOnline);
77813
- if (selfInfo.online && (selfInfo.uid || selfInfo.uin)) handleOnline();
77814
- if (!useDirectProtocol) ctx.inject(["ntUserApi"], async (userCtx) => {
77815
- if (selfInfo.online) {
77816
- await ensurePmhqMissingFields(userCtx);
77817
- setLoginState({
77818
- state: "logged_in",
77819
- uin: selfInfo.uin,
77820
- nickname: selfInfo.nick
77821
- });
77822
- }
77823
- });
77858
+ if (selfInfo.online && selfInfo.uid) handleOnline();
77824
77859
  ctx.on("protocol/disconnect", () => {
77825
77860
  ctx.logger.info("协议层断开,等待重连…");
77826
77861
  });
@@ -77834,6 +77869,12 @@ async function onLoad() {
77834
77869
  else ctx.qqProtocol.startHook();
77835
77870
  });
77836
77871
  }
77872
+ process.on("unhandledRejection", (reason) => {
77873
+ console.error("[unhandledRejection]", reason);
77874
+ });
77875
+ process.on("uncaughtException", (err) => {
77876
+ console.error("[uncaughtException]", err);
77877
+ });
77837
77878
  onLoad().catch((e) => console.error(e));
77838
77879
  //#endregion
77839
77880
  export {};