llonebot-dist 8.0.0 → 8.0.1
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 +24 -120
- package/llbot.js.map +1 -1
- package/package.json +1 -1
- package/webui/assets/{index-DW9CNxRt.js → index-DpTdGecM.js} +1 -1
- package/webui/index.html +1 -1
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
|
|
6260
|
-
|
|
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}`;
|
|
@@ -18857,7 +18857,7 @@ var OB11HeartbeatEvent = class extends OB11BaseMetaEvent {
|
|
|
18857
18857
|
};
|
|
18858
18858
|
//#endregion
|
|
18859
18859
|
//#region src/version.ts
|
|
18860
|
-
var version$3 = "8.0.
|
|
18860
|
+
var version$3 = "8.0.1";
|
|
18861
18861
|
//#endregion
|
|
18862
18862
|
//#region node_modules/sift/es5m/index.js
|
|
18863
18863
|
/******************************************************************************
|
|
@@ -31822,7 +31822,7 @@ var SendPB = class extends BaseAction {
|
|
|
31822
31822
|
});
|
|
31823
31823
|
async _handle(payload) {
|
|
31824
31824
|
try {
|
|
31825
|
-
const result = await this.ctx.qqProtocol.
|
|
31825
|
+
const result = await this.ctx.qqProtocol.sendPB(payload.cmd, payload.hex);
|
|
31826
31826
|
return {
|
|
31827
31827
|
cmd: result.cmd,
|
|
31828
31828
|
hex: result.pb,
|
|
@@ -55518,7 +55518,7 @@ var NTFriendApi = class extends Service {
|
|
|
55518
55518
|
uid: friend.uid,
|
|
55519
55519
|
uin: friend.uin,
|
|
55520
55520
|
categoryId: friend.categoryId,
|
|
55521
|
-
categoryName: categories.get(friend.categoryId)
|
|
55521
|
+
categoryName: categories.get(friend.categoryId)?.categoryName ?? "",
|
|
55522
55522
|
nick: biz.data.get(20002)?.toString() ?? "",
|
|
55523
55523
|
bio: biz.data.get(102)?.toString() ?? "",
|
|
55524
55524
|
remark: biz.data.get(103)?.toString() ?? "",
|
|
@@ -55527,7 +55527,8 @@ var NTFriendApi = class extends Service {
|
|
|
55527
55527
|
gender: biz.numData.get(20009) ?? 0,
|
|
55528
55528
|
birthdayYear: biz.data.has(20031) ? biz.data.get(20031)[0] << 8 | biz.data.get(20031)[1] : 0,
|
|
55529
55529
|
birthdayMonth: biz.data.get(20031)?.[2] ?? 0,
|
|
55530
|
-
birthdayDay: biz.data.get(20031)?.[3] ?? 0
|
|
55530
|
+
birthdayDay: biz.data.get(20031)?.[3] ?? 0,
|
|
55531
|
+
isSelf: friend.uin === res.selfUin
|
|
55531
55532
|
});
|
|
55532
55533
|
}
|
|
55533
55534
|
cookie = res.cookie;
|
|
@@ -56136,7 +56137,8 @@ var MessageBuilding = class MessageBuilding {
|
|
|
56136
56137
|
c2c: isGroup ? void 0 : { name: node.senderName },
|
|
56137
56138
|
group: isGroup ? {
|
|
56138
56139
|
groupCode: 284840486,
|
|
56139
|
-
groupCard: node.senderName
|
|
56140
|
+
groupCard: node.senderName,
|
|
56141
|
+
groupCardType: 2
|
|
56140
56142
|
} : void 0
|
|
56141
56143
|
},
|
|
56142
56144
|
contentHead: {
|
|
@@ -56269,7 +56271,7 @@ var NTMsgApi = class extends Service {
|
|
|
56269
56271
|
else chatType = ChatType.C2C;
|
|
56270
56272
|
}
|
|
56271
56273
|
const random = randomBytes(4).readUInt32BE(0);
|
|
56272
|
-
const echoP = peer.chatType === ChatType.Group ? this.waitForSelfEcho(peer, random,
|
|
56274
|
+
const echoP = peer.chatType === ChatType.Group ? this.waitForSelfEcho(peer, random, 7e3) : null;
|
|
56273
56275
|
const ret = await this.ctx.qqProtocol.sendMessage({
|
|
56274
56276
|
chatType,
|
|
56275
56277
|
groupCode,
|
|
@@ -73261,6 +73263,7 @@ var DirectProtocolClient = class extends EventEmitter {
|
|
|
73261
73263
|
const uin = this.session?.uin ? Number(this.session.uin) : void 0;
|
|
73262
73264
|
await this.ensureSignTokenFresh(uin);
|
|
73263
73265
|
signResult = await requestSign(cmd, payload, seq, this.guid, AppInfo.qua, uin, this.session?.signToken12B);
|
|
73266
|
+
if (signResult?.token.length === 0) signResult.token = Buffer.from(this.session?.signToken12B ?? "");
|
|
73264
73267
|
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
73268
|
if (!signResult) throw new Error(`sign failed for ${cmd}; see [Sign] log above`);
|
|
73266
73269
|
}
|
|
@@ -74369,7 +74372,6 @@ var QQProtocolBase = class extends Service {
|
|
|
74369
74372
|
msgPBMap = /* @__PURE__ */ new Map();
|
|
74370
74373
|
logger;
|
|
74371
74374
|
pmhqProbeToken = 0;
|
|
74372
|
-
pmhqProbeListenerId = "";
|
|
74373
74375
|
onlineEmitted = false;
|
|
74374
74376
|
directClient = null;
|
|
74375
74377
|
directQrResult = null;
|
|
@@ -74390,9 +74392,6 @@ var QQProtocolBase = class extends Service {
|
|
|
74390
74392
|
if (!selfInfo.uid && !selfInfo.uin) return;
|
|
74391
74393
|
this.onlineEmitted = true;
|
|
74392
74394
|
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
74395
|
}
|
|
74397
74396
|
/**
|
|
74398
74397
|
* PMHQ 模式下 LLBot 是寄生在 QQ NT 上的,QQ NT 早就登录过了,开机时的 InfoSyncPush 也早处理完。
|
|
@@ -74411,10 +74410,6 @@ var QQProtocolBase = class extends Service {
|
|
|
74411
74410
|
selfInfo.uid = "";
|
|
74412
74411
|
selfInfo.uin = "";
|
|
74413
74412
|
selfInfo.nick = "";
|
|
74414
|
-
if (this.pmhqProbeListenerId) {
|
|
74415
|
-
this.removeResListener(this.pmhqProbeListenerId);
|
|
74416
|
-
this.pmhqProbeListenerId = "";
|
|
74417
|
-
}
|
|
74418
74413
|
this.pmhqProbeToken++;
|
|
74419
74414
|
this.onlineEmitted = false;
|
|
74420
74415
|
if (wasOnline) this.ctx.parallel("protocol/disconnect");
|
|
@@ -74426,70 +74421,29 @@ var QQProtocolBase = class extends Service {
|
|
|
74426
74421
|
startPmhqLoginProbe() {
|
|
74427
74422
|
this.resetPmhqState();
|
|
74428
74423
|
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
74424
|
let warnedNotLoggedIn = false;
|
|
74464
74425
|
const probe = async () => {
|
|
74465
74426
|
if (this.pmhqProbeToken !== myToken) return;
|
|
74466
|
-
|
|
74467
|
-
|
|
74468
|
-
await
|
|
74427
|
+
const ntFriendApi = this.ctx.get("ntFriendApi");
|
|
74428
|
+
if (ntFriendApi) try {
|
|
74429
|
+
const info = (await ntFriendApi.getFriends(true)).friends.find((e) => e.isSelf);
|
|
74469
74430
|
if (this.pmhqProbeToken !== myToken) return;
|
|
74431
|
+
selfInfo.uid = info.uid;
|
|
74432
|
+
selfInfo.uin = info.uin.toString();
|
|
74433
|
+
selfInfo.nick = info.nick;
|
|
74470
74434
|
if (!selfInfo.online) this.logger.info("QQ 登录成功");
|
|
74471
74435
|
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
74436
|
this.maybeEmitOnline();
|
|
74479
|
-
} catch {
|
|
74437
|
+
} catch (e) {
|
|
74480
74438
|
if (this.pmhqProbeToken !== myToken) return;
|
|
74481
|
-
if (
|
|
74482
|
-
detach();
|
|
74483
|
-
return;
|
|
74484
|
-
}
|
|
74485
|
-
if (!warnedNotLoggedIn) {
|
|
74439
|
+
if (!warnedNotLoggedIn && !e.message.includes("(QQ DLL not connected)")) {
|
|
74486
74440
|
this.logger.info("QQ 未登录,等待登录中...");
|
|
74487
74441
|
warnedNotLoggedIn = true;
|
|
74488
74442
|
}
|
|
74489
74443
|
}
|
|
74490
74444
|
if (this.pmhqProbeToken !== myToken) return;
|
|
74491
74445
|
if (selfInfo.online) return;
|
|
74492
|
-
setTimeout(probe,
|
|
74446
|
+
setTimeout(probe, 600);
|
|
74493
74447
|
};
|
|
74494
74448
|
probe();
|
|
74495
74449
|
}
|
|
@@ -74673,13 +74627,13 @@ var QQProtocolBase = class extends Service {
|
|
|
74673
74627
|
}
|
|
74674
74628
|
async sendPB(cmd, pb, timeout = 15e3) {
|
|
74675
74629
|
if (this.directClient?.isLoggedIn) {
|
|
74676
|
-
const buf = Buffer.from(pb);
|
|
74630
|
+
const buf = Buffer.isBuffer(pb) ? pb : Buffer.from(pb, "hex");
|
|
74677
74631
|
return {
|
|
74678
74632
|
cmd,
|
|
74679
74633
|
pb: (await this.directClient.sendCommand(cmd, buf, void 0, timeout)).payload.toString("hex")
|
|
74680
74634
|
};
|
|
74681
74635
|
}
|
|
74682
|
-
const hex = Buffer.
|
|
74636
|
+
const hex = Buffer.isBuffer(pb) ? pb.toString("hex") : pb;
|
|
74683
74637
|
if (this.ws?.readyState === WebSocket.OPEN) return this.unwrapPmhqRes(await this.wsSend({
|
|
74684
74638
|
type: "send",
|
|
74685
74639
|
data: {
|
|
@@ -74695,29 +74649,6 @@ var QQProtocolBase = class extends Service {
|
|
|
74695
74649
|
}
|
|
74696
74650
|
}), cmd);
|
|
74697
74651
|
}
|
|
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
74652
|
/**
|
|
74722
74653
|
* 发送 OIDB 命令,自动 encode Oidb.Base、发送、decode 响应。
|
|
74723
74654
|
*/
|
|
@@ -77752,23 +77683,6 @@ async function onLoad() {
|
|
|
77752
77683
|
setTimeout(directLoginLoop, 1e3);
|
|
77753
77684
|
}
|
|
77754
77685
|
};
|
|
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
77686
|
ctx.inject(["qqProtocol", "config"], (ctx) => {
|
|
77773
77687
|
ctx.logger.info(`LLBot ${version$3}`);
|
|
77774
77688
|
ctx.logger.info(process.argv);
|
|
@@ -77789,7 +77703,7 @@ async function onLoad() {
|
|
|
77789
77703
|
uin: selfInfo.uin,
|
|
77790
77704
|
nickname: selfInfo.nick
|
|
77791
77705
|
});
|
|
77792
|
-
if (useDirectProtocol && !selfInfo.nick
|
|
77706
|
+
if (useDirectProtocol && !selfInfo.nick) ctx.inject(["ntUserApi"], async (userCtx) => {
|
|
77793
77707
|
try {
|
|
77794
77708
|
const nick = await userCtx.ntUserApi.getSelfNick(true);
|
|
77795
77709
|
if (nick) {
|
|
@@ -77810,17 +77724,7 @@ async function onLoad() {
|
|
|
77810
77724
|
loadPluginAfterLogin();
|
|
77811
77725
|
};
|
|
77812
77726
|
ctx.on("qq/online", handleOnline);
|
|
77813
|
-
if (selfInfo.online &&
|
|
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
|
-
});
|
|
77727
|
+
if (selfInfo.online && selfInfo.uid) handleOnline();
|
|
77824
77728
|
ctx.on("protocol/disconnect", () => {
|
|
77825
77729
|
ctx.logger.info("协议层断开,等待重连…");
|
|
77826
77730
|
});
|