llonebot-dist 7.12.4 → 7.12.6
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
|
@@ -15,6 +15,7 @@ import { WebSocket as WebSocket$1, WebSocketServer } from "ws";
|
|
|
15
15
|
import { constants } from "node:buffer";
|
|
16
16
|
import crypto$1, { createHash, randomBytes, randomInt, randomUUID } from "node:crypto";
|
|
17
17
|
import * as fileType from "file-type";
|
|
18
|
+
import { fileTypeFromBuffer } from "file-type";
|
|
18
19
|
import { decode, encode, getDuration, getWavFileInfo, isSilk, isWav } from "silk-wasm";
|
|
19
20
|
import http, { STATUS_CODES, createServer, request } from "node:http";
|
|
20
21
|
import { Http2ServerRequest, constants as constants$1 } from "node:http2";
|
|
@@ -11384,7 +11385,7 @@ var OB11HeartbeatEvent = class extends OB11BaseMetaEvent {
|
|
|
11384
11385
|
};
|
|
11385
11386
|
//#endregion
|
|
11386
11387
|
//#region src/version.ts
|
|
11387
|
-
var version$2 = "7.12.
|
|
11388
|
+
var version$2 = "7.12.6";
|
|
11388
11389
|
//#endregion
|
|
11389
11390
|
//#region node_modules/sift/es5m/index.js
|
|
11390
11391
|
/******************************************************************************
|
|
@@ -17256,6 +17257,12 @@ async function getFileType(filePath) {
|
|
|
17256
17257
|
async function getImageSize(path) {
|
|
17257
17258
|
return await imageSizeFromFile(path);
|
|
17258
17259
|
}
|
|
17260
|
+
function getMd5HexFromBuffer(buf) {
|
|
17261
|
+
return createHash("md5").update(buf).digest("hex");
|
|
17262
|
+
}
|
|
17263
|
+
function getSha1HexFromBuffer(buf) {
|
|
17264
|
+
return createHash("sha1").update(buf).digest("hex");
|
|
17265
|
+
}
|
|
17259
17266
|
async function getMd5HexFromFile(filePath) {
|
|
17260
17267
|
const hash = createHash("md5");
|
|
17261
17268
|
const stream = fs$1.createReadStream(filePath);
|
|
@@ -21202,7 +21209,7 @@ var getRequestListener = (fetchCallback, options = {}) => {
|
|
|
21202
21209
|
/**
|
|
21203
21210
|
* @link https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent
|
|
21204
21211
|
*/
|
|
21205
|
-
var CloseEvent
|
|
21212
|
+
var CloseEvent = globalThis.CloseEvent ?? class extends Event {
|
|
21206
21213
|
#eventInitDict;
|
|
21207
21214
|
constructor(type, eventInitDict = {}) {
|
|
21208
21215
|
super(type, eventInitDict);
|
|
@@ -21218,8 +21225,8 @@ var CloseEvent$1 = globalThis.CloseEvent ?? class extends Event {
|
|
|
21218
21225
|
return this.#eventInitDict.reason ?? "";
|
|
21219
21226
|
}
|
|
21220
21227
|
};
|
|
21221
|
-
var generateConnectionSymbol
|
|
21222
|
-
var CONNECTION_SYMBOL_KEY
|
|
21228
|
+
var generateConnectionSymbol = () => Symbol("connection");
|
|
21229
|
+
var CONNECTION_SYMBOL_KEY = Symbol("CONNECTION_SYMBOL_KEY");
|
|
21223
21230
|
var WAIT_FOR_WEBSOCKET_SYMBOL = Symbol("WAIT_FOR_WEBSOCKET_SYMBOL");
|
|
21224
21231
|
var rejectUpgradeRequest = (socket, status) => {
|
|
21225
21232
|
socket.end(`HTTP/1.1 ${status.toString()} ${STATUS_CODES[status] ?? ""}\r\nConnection: close\r
|
|
@@ -21273,7 +21280,7 @@ var setupWebSocket = (options) => {
|
|
|
21273
21280
|
return;
|
|
21274
21281
|
}
|
|
21275
21282
|
const waiter = waiterMap.get(request);
|
|
21276
|
-
if (!waiter || waiter.connectionSymbol !== env[CONNECTION_SYMBOL_KEY
|
|
21283
|
+
if (!waiter || waiter.connectionSymbol !== env[CONNECTION_SYMBOL_KEY]) {
|
|
21277
21284
|
waiterMap.delete(request);
|
|
21278
21285
|
if (server.listenerCount("upgrade") === 1) rejectUpgradeRequest(socket, status);
|
|
21279
21286
|
return;
|
|
@@ -21286,13 +21293,13 @@ var setupWebSocket = (options) => {
|
|
|
21286
21293
|
wss.close();
|
|
21287
21294
|
});
|
|
21288
21295
|
};
|
|
21289
|
-
defineWebSocketHelper(async (c, events, options) => {
|
|
21296
|
+
var upgradeWebSocket = defineWebSocketHelper(async (c, events, options) => {
|
|
21290
21297
|
if (c.req.header("upgrade")?.toLowerCase() !== "websocket") return;
|
|
21291
21298
|
const env = c.env;
|
|
21292
21299
|
const waitForWebSocket = env[WAIT_FOR_WEBSOCKET_SYMBOL];
|
|
21293
21300
|
if (!waitForWebSocket || !env.incoming) return new Response(null, { status: 500 });
|
|
21294
|
-
const connectionSymbol = generateConnectionSymbol
|
|
21295
|
-
env[CONNECTION_SYMBOL_KEY
|
|
21301
|
+
const connectionSymbol = generateConnectionSymbol();
|
|
21302
|
+
env[CONNECTION_SYMBOL_KEY] = connectionSymbol;
|
|
21296
21303
|
(async () => {
|
|
21297
21304
|
const ws = await waitForWebSocket(env.incoming, connectionSymbol);
|
|
21298
21305
|
const messagesReceivedInStarting = [];
|
|
@@ -21335,7 +21342,7 @@ defineWebSocketHelper(async (c, events, options) => {
|
|
|
21335
21342
|
});
|
|
21336
21343
|
ws.on("close", (code, reason) => {
|
|
21337
21344
|
try {
|
|
21338
|
-
events?.onClose?.(new CloseEvent
|
|
21345
|
+
events?.onClose?.(new CloseEvent("close", {
|
|
21339
21346
|
code,
|
|
21340
21347
|
reason: reason.toString()
|
|
21341
21348
|
}), ctx);
|
|
@@ -22283,18 +22290,18 @@ var ScalarDeserializerCompiler = {
|
|
|
22283
22290
|
sfixed32: (key, spec) => spec.repeated ? (draft, reader, wireType) => {
|
|
22284
22291
|
if (wireType === WireType$2.LengthDelimited) {
|
|
22285
22292
|
const count = reader.readVarint() / Fixed32Size;
|
|
22286
|
-
for (let i = 0; i < count; i++) draft[key].push(Converter.
|
|
22287
|
-
} else draft[key].push(Converter.
|
|
22293
|
+
for (let i = 0; i < count; i++) draft[key].push(Converter.toSigned32(reader.readFixed32()));
|
|
22294
|
+
} else draft[key].push(Converter.toSigned32(reader.readFixed32()));
|
|
22288
22295
|
} : (draft, reader) => {
|
|
22289
|
-
draft[key] = Converter.
|
|
22296
|
+
draft[key] = Converter.toSigned32(reader.readFixed32());
|
|
22290
22297
|
},
|
|
22291
22298
|
sfixed64: (key, spec) => spec.repeated ? (draft, reader, wireType) => {
|
|
22292
22299
|
if (wireType === WireType$2.LengthDelimited) {
|
|
22293
22300
|
const count = reader.readVarint() / Fixed64Size;
|
|
22294
|
-
for (let i = 0; i < count; i++) draft[key].push(Converter.
|
|
22295
|
-
} else draft[key].push(Converter.
|
|
22301
|
+
for (let i = 0; i < count; i++) draft[key].push(Converter.toSigned64(reader.readFixed64()));
|
|
22302
|
+
} else draft[key].push(Converter.toSigned64(reader.readFixed64()));
|
|
22296
22303
|
} : (draft, reader) => {
|
|
22297
|
-
draft[key] = Converter.
|
|
22304
|
+
draft[key] = Converter.toSigned64(reader.readFixed64());
|
|
22298
22305
|
},
|
|
22299
22306
|
sint32: (key, spec) => spec.repeated ? (draft, reader, wireType) => {
|
|
22300
22307
|
if (wireType === WireType$2.LengthDelimited) {
|
|
@@ -22473,29 +22480,29 @@ var ScalarSerializerCompiler = {
|
|
|
22473
22480
|
const length = data.length * Fixed32Size;
|
|
22474
22481
|
writer.writeVarint(spec[kTag]);
|
|
22475
22482
|
writer.writeVarint(length);
|
|
22476
|
-
for (const value of data) writer.writeFixed32(Converter.
|
|
22483
|
+
for (const value of data) writer.writeFixed32(Converter.toUnsigned32(value));
|
|
22477
22484
|
}) : defineSerializer((data, writer) => {
|
|
22478
22485
|
for (const value of data) {
|
|
22479
22486
|
writer.writeVarint(spec[kTag]);
|
|
22480
|
-
writer.writeFixed32(Converter.
|
|
22487
|
+
writer.writeFixed32(Converter.toUnsigned32(value));
|
|
22481
22488
|
}
|
|
22482
22489
|
}) : defineSerializer((data, writer) => {
|
|
22483
22490
|
writer.writeVarint(spec[kTag]);
|
|
22484
|
-
writer.writeFixed32(Converter.
|
|
22491
|
+
writer.writeFixed32(Converter.toUnsigned32(data));
|
|
22485
22492
|
}),
|
|
22486
22493
|
sfixed64: (spec) => spec.repeated ? spec.packed ? defineSerializer((data, writer) => {
|
|
22487
22494
|
const length = data.length * Fixed64Size;
|
|
22488
22495
|
writer.writeVarint(spec[kTag]);
|
|
22489
22496
|
writer.writeVarint(length);
|
|
22490
|
-
for (const value of data) writer.writeFixed64(Converter.
|
|
22497
|
+
for (const value of data) writer.writeFixed64(Converter.toUnsigned64(value));
|
|
22491
22498
|
}) : defineSerializer((data, writer) => {
|
|
22492
22499
|
for (const value of data) {
|
|
22493
22500
|
writer.writeVarint(spec[kTag]);
|
|
22494
|
-
writer.writeFixed64(Converter.
|
|
22501
|
+
writer.writeFixed64(Converter.toUnsigned64(value));
|
|
22495
22502
|
}
|
|
22496
22503
|
}) : defineSerializer((data, writer) => {
|
|
22497
22504
|
writer.writeVarint(spec[kTag]);
|
|
22498
|
-
writer.writeFixed64(Converter.
|
|
22505
|
+
writer.writeFixed64(Converter.toUnsigned64(data));
|
|
22499
22506
|
}),
|
|
22500
22507
|
sint32: (spec) => spec.repeated ? spec.packed ? defineSerializer((data, writer) => {
|
|
22501
22508
|
const length = data.length * Fixed32Size;
|
|
@@ -22526,23 +22533,6 @@ var ScalarSerializerCompiler = {
|
|
|
22526
22533
|
writer.writeBigVarint(Converter.zigzagEncode64(data));
|
|
22527
22534
|
})
|
|
22528
22535
|
};
|
|
22529
|
-
var ScalarTypeDefaultValue = {
|
|
22530
|
-
double: 0,
|
|
22531
|
-
float: 0,
|
|
22532
|
-
int64: BigInt(0),
|
|
22533
|
-
uint64: BigInt(0),
|
|
22534
|
-
int32: 0,
|
|
22535
|
-
fixed64: BigInt(0),
|
|
22536
|
-
fixed32: 0,
|
|
22537
|
-
bool: false,
|
|
22538
|
-
string: "",
|
|
22539
|
-
bytes: Buffer.alloc(0),
|
|
22540
|
-
uint32: 0,
|
|
22541
|
-
sfixed32: 0,
|
|
22542
|
-
sfixed64: BigInt(0),
|
|
22543
|
-
sint32: 0,
|
|
22544
|
-
sint64: BigInt(0)
|
|
22545
|
-
};
|
|
22546
22536
|
var VARINT32_BYTE_2 = 128;
|
|
22547
22537
|
var VARINT32_BYTE_3 = 16384;
|
|
22548
22538
|
var VARINT32_BYTE_4 = 2097152;
|
|
@@ -22673,6 +22663,23 @@ var ScalarSizeCalculatorCompiler = {
|
|
|
22673
22663
|
return spec[kTagLength] + SizeOf.varint32(bodySize) + bodySize;
|
|
22674
22664
|
} : (data) => sumVarint64Array(data, Converter.zigzagEncode64) + spec[kTagLength] * data.length : (data) => spec[kTagLength] + SizeOf.varint64(Converter.zigzagEncode64(data))
|
|
22675
22665
|
};
|
|
22666
|
+
var ScalarTypeDefaultValue = {
|
|
22667
|
+
double: 0,
|
|
22668
|
+
float: 0,
|
|
22669
|
+
int64: BigInt(0),
|
|
22670
|
+
uint64: BigInt(0),
|
|
22671
|
+
int32: 0,
|
|
22672
|
+
fixed64: BigInt(0),
|
|
22673
|
+
fixed32: 0,
|
|
22674
|
+
bool: false,
|
|
22675
|
+
string: "",
|
|
22676
|
+
bytes: Buffer.alloc(0),
|
|
22677
|
+
uint32: 0,
|
|
22678
|
+
sfixed32: 0,
|
|
22679
|
+
sfixed64: BigInt(0),
|
|
22680
|
+
sint32: 0,
|
|
22681
|
+
sint64: BigInt(0)
|
|
22682
|
+
};
|
|
22676
22683
|
function isMapFieldType(type) {
|
|
22677
22684
|
return Array.isArray(type);
|
|
22678
22685
|
}
|
|
@@ -22912,10 +22919,10 @@ var ProtoMessage = class ProtoMessage {
|
|
|
22912
22919
|
return draft;
|
|
22913
22920
|
}
|
|
22914
22921
|
static of(model) {
|
|
22915
|
-
let message =
|
|
22922
|
+
let message = ProtoMessage.compiledMessages.get(model);
|
|
22916
22923
|
if (message === void 0) {
|
|
22917
22924
|
message = new ProtoMessage(model);
|
|
22918
|
-
|
|
22925
|
+
ProtoMessage.compiledMessages.set(model, message);
|
|
22919
22926
|
}
|
|
22920
22927
|
return message;
|
|
22921
22928
|
}
|
|
@@ -25399,12 +25406,16 @@ var SendGroupNotice = class extends BaseAction {
|
|
|
25399
25406
|
content: lib_default$1.string().required(),
|
|
25400
25407
|
image: lib_default$1.string(),
|
|
25401
25408
|
pinned: lib_default$1.union([Boolean, lib_default$1.transform(String, parseBool)]).default(false),
|
|
25402
|
-
confirm_required: lib_default$1.union([Boolean, lib_default$1.transform(String, parseBool)]).default(true)
|
|
25409
|
+
confirm_required: lib_default$1.union([Boolean, lib_default$1.transform(String, parseBool)]).default(true),
|
|
25410
|
+
is_show_edit_card: lib_default$1.union([Boolean, lib_default$1.transform(String, parseBool)]).default(false),
|
|
25411
|
+
tip_window: lib_default$1.union([Boolean, lib_default$1.transform(String, parseBool)]).default(false)
|
|
25403
25412
|
});
|
|
25404
25413
|
async _handle(payload) {
|
|
25405
25414
|
const groupCode = payload.group_id.toString();
|
|
25406
25415
|
const pinned = +payload.pinned;
|
|
25407
25416
|
const confirmRequired = +payload.confirm_required;
|
|
25417
|
+
const isShowEditCard = +payload.is_show_edit_card;
|
|
25418
|
+
const tipWindowType = +!payload.tip_window;
|
|
25408
25419
|
let picInfo;
|
|
25409
25420
|
if (payload.image) {
|
|
25410
25421
|
const { path, isLocal, success, errMsg } = await uri2local(this.ctx, payload.image, true);
|
|
@@ -25414,14 +25425,8 @@ var SendGroupNotice = class extends BaseAction {
|
|
|
25414
25425
|
if (!isLocal) unlink$1(path).catch(noop);
|
|
25415
25426
|
picInfo = result.picInfo;
|
|
25416
25427
|
}
|
|
25417
|
-
const res = await this.ctx.
|
|
25418
|
-
|
|
25419
|
-
oldFeedsId: "",
|
|
25420
|
-
pinned,
|
|
25421
|
-
confirmRequired,
|
|
25422
|
-
picInfo
|
|
25423
|
-
});
|
|
25424
|
-
if (res.result !== 0) throw new Error(`设置群公告失败, 错误信息: ${res.errMsg}`);
|
|
25428
|
+
const res = await this.ctx.ntWebApi.publishGroupBulletin(groupCode, payload.content, pinned, 1, isShowEditCard, tipWindowType, confirmRequired, picInfo?.id, picInfo?.width, picInfo?.height);
|
|
25429
|
+
if (res.ec !== 0) throw new Error(`设置群公告失败, 错误信息: ${res.em}`);
|
|
25425
25430
|
return null;
|
|
25426
25431
|
}
|
|
25427
25432
|
};
|
|
@@ -25692,7 +25697,7 @@ var GetGroupNotice = class extends BaseAction {
|
|
|
25692
25697
|
async _handle(payload) {
|
|
25693
25698
|
const data = await this.ctx.ntGroupApi.getGroupBulletinList(payload.group_id.toString());
|
|
25694
25699
|
const result = [];
|
|
25695
|
-
for (const feed of data.feeds) result.push({
|
|
25700
|
+
for (const feed of [...data.feeds, ...data.inst]) result.push({
|
|
25696
25701
|
notice_id: feed.feedId,
|
|
25697
25702
|
sender_id: +feed.uin,
|
|
25698
25703
|
publish_time: +feed.publishTime,
|
|
@@ -25705,8 +25710,15 @@ var GetGroupNotice = class extends BaseAction {
|
|
|
25705
25710
|
id: image.id
|
|
25706
25711
|
};
|
|
25707
25712
|
})
|
|
25713
|
+
},
|
|
25714
|
+
settings: {
|
|
25715
|
+
is_show_edit_card: !!feed.settings.isShowEditCard,
|
|
25716
|
+
tip_window: !feed.settings.tipWindowType,
|
|
25717
|
+
confirm_required: !!feed.settings.confirmRequired,
|
|
25718
|
+
pinned: !!feed.pinned
|
|
25708
25719
|
}
|
|
25709
25720
|
});
|
|
25721
|
+
if (data.inst.length > 0) return result.sort((a, b) => b.publish_time - a.publish_time);
|
|
25710
25722
|
return result;
|
|
25711
25723
|
}
|
|
25712
25724
|
};
|
|
@@ -28892,149 +28904,6 @@ var handlers = {
|
|
|
28892
28904
|
deleteFriend
|
|
28893
28905
|
};
|
|
28894
28906
|
//#endregion
|
|
28895
|
-
//#region node_modules/@hono/node-ws/dist/index.js
|
|
28896
|
-
/**
|
|
28897
|
-
* @link https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent
|
|
28898
|
-
*/
|
|
28899
|
-
var CloseEvent = globalThis.CloseEvent ?? class extends Event {
|
|
28900
|
-
#eventInitDict;
|
|
28901
|
-
constructor(type, eventInitDict = {}) {
|
|
28902
|
-
super(type, eventInitDict);
|
|
28903
|
-
this.#eventInitDict = eventInitDict;
|
|
28904
|
-
}
|
|
28905
|
-
get wasClean() {
|
|
28906
|
-
return this.#eventInitDict.wasClean ?? false;
|
|
28907
|
-
}
|
|
28908
|
-
get code() {
|
|
28909
|
-
return this.#eventInitDict.code ?? 0;
|
|
28910
|
-
}
|
|
28911
|
-
get reason() {
|
|
28912
|
-
return this.#eventInitDict.reason ?? "";
|
|
28913
|
-
}
|
|
28914
|
-
};
|
|
28915
|
-
var generateConnectionSymbol = () => Symbol("connection");
|
|
28916
|
-
/** @example `c.env[CONNECTION_SYMBOL_KEY]` */
|
|
28917
|
-
var CONNECTION_SYMBOL_KEY = Symbol("CONNECTION_SYMBOL_KEY");
|
|
28918
|
-
/**
|
|
28919
|
-
* Create WebSockets for Node.js
|
|
28920
|
-
* @param init Options
|
|
28921
|
-
* @returns NodeWebSocket
|
|
28922
|
-
*/
|
|
28923
|
-
var createNodeWebSocket = (init) => {
|
|
28924
|
-
const wss = new WebSocketServer({ noServer: true });
|
|
28925
|
-
const waiterMap = /* @__PURE__ */ new Map();
|
|
28926
|
-
wss.on("connection", (ws, request) => {
|
|
28927
|
-
const waiter = waiterMap.get(request);
|
|
28928
|
-
if (waiter) {
|
|
28929
|
-
waiter.resolve(ws);
|
|
28930
|
-
waiterMap.delete(request);
|
|
28931
|
-
}
|
|
28932
|
-
});
|
|
28933
|
-
const nodeUpgradeWebSocket = (request, connectionSymbol) => {
|
|
28934
|
-
return new Promise((resolve) => {
|
|
28935
|
-
waiterMap.set(request, {
|
|
28936
|
-
resolve,
|
|
28937
|
-
connectionSymbol
|
|
28938
|
-
});
|
|
28939
|
-
});
|
|
28940
|
-
};
|
|
28941
|
-
return {
|
|
28942
|
-
wss,
|
|
28943
|
-
injectWebSocket(server) {
|
|
28944
|
-
server.on("upgrade", async (request, socket, head) => {
|
|
28945
|
-
const url = new URL(request.url ?? "/", init.baseUrl ?? "http://localhost");
|
|
28946
|
-
const headers = new Headers();
|
|
28947
|
-
for (const key in request.headers) {
|
|
28948
|
-
const value = request.headers[key];
|
|
28949
|
-
if (!value) continue;
|
|
28950
|
-
headers.append(key, Array.isArray(value) ? value[0] : value);
|
|
28951
|
-
}
|
|
28952
|
-
const env = {
|
|
28953
|
-
incoming: request,
|
|
28954
|
-
outgoing: void 0
|
|
28955
|
-
};
|
|
28956
|
-
const response = await init.app.request(url, { headers }, env);
|
|
28957
|
-
const waiter = waiterMap.get(request);
|
|
28958
|
-
if (!waiter || waiter.connectionSymbol !== env[CONNECTION_SYMBOL_KEY]) {
|
|
28959
|
-
socket.end(`HTTP/1.1 ${response.status.toString()} ${STATUS_CODES[response.status] ?? ""}\r\nConnection: close\r
|
|
28960
|
-
Content-Length: 0\r
|
|
28961
|
-
\r
|
|
28962
|
-
`);
|
|
28963
|
-
waiterMap.delete(request);
|
|
28964
|
-
return;
|
|
28965
|
-
}
|
|
28966
|
-
wss.handleUpgrade(request, socket, head, (ws) => {
|
|
28967
|
-
wss.emit("connection", ws, request);
|
|
28968
|
-
});
|
|
28969
|
-
});
|
|
28970
|
-
},
|
|
28971
|
-
upgradeWebSocket: defineWebSocketHelper(async (c, events, options) => {
|
|
28972
|
-
if (c.req.header("upgrade")?.toLowerCase() !== "websocket") return;
|
|
28973
|
-
const connectionSymbol = generateConnectionSymbol();
|
|
28974
|
-
c.env[CONNECTION_SYMBOL_KEY] = connectionSymbol;
|
|
28975
|
-
(async () => {
|
|
28976
|
-
const ws = await nodeUpgradeWebSocket(c.env.incoming, connectionSymbol);
|
|
28977
|
-
const messagesReceivedInStarting = [];
|
|
28978
|
-
const bufferMessage = (data, isBinary) => {
|
|
28979
|
-
messagesReceivedInStarting.push([data, isBinary]);
|
|
28980
|
-
};
|
|
28981
|
-
ws.on("message", bufferMessage);
|
|
28982
|
-
const ctx = {
|
|
28983
|
-
binaryType: "arraybuffer",
|
|
28984
|
-
close(code, reason) {
|
|
28985
|
-
ws.close(code, reason);
|
|
28986
|
-
},
|
|
28987
|
-
protocol: ws.protocol,
|
|
28988
|
-
raw: ws,
|
|
28989
|
-
get readyState() {
|
|
28990
|
-
return ws.readyState;
|
|
28991
|
-
},
|
|
28992
|
-
send(source, opts) {
|
|
28993
|
-
ws.send(source, { compress: opts?.compress });
|
|
28994
|
-
},
|
|
28995
|
-
url: new URL(c.req.url)
|
|
28996
|
-
};
|
|
28997
|
-
try {
|
|
28998
|
-
events?.onOpen?.(new Event("open"), ctx);
|
|
28999
|
-
} catch (e) {
|
|
29000
|
-
(options?.onError ?? console.error)(e);
|
|
29001
|
-
}
|
|
29002
|
-
const handleMessage = (data, isBinary) => {
|
|
29003
|
-
const datas = Array.isArray(data) ? data : [data];
|
|
29004
|
-
for (const data$1 of datas) try {
|
|
29005
|
-
events?.onMessage?.(new MessageEvent("message", { data: isBinary ? data$1 instanceof ArrayBuffer ? data$1 : data$1.buffer.slice(data$1.byteOffset, data$1.byteOffset + data$1.byteLength) : data$1.toString("utf-8") }), ctx);
|
|
29006
|
-
} catch (e) {
|
|
29007
|
-
(options?.onError ?? console.error)(e);
|
|
29008
|
-
}
|
|
29009
|
-
};
|
|
29010
|
-
ws.off("message", bufferMessage);
|
|
29011
|
-
for (const message of messagesReceivedInStarting) handleMessage(...message);
|
|
29012
|
-
ws.on("message", (data, isBinary) => {
|
|
29013
|
-
handleMessage(data, isBinary);
|
|
29014
|
-
});
|
|
29015
|
-
ws.on("close", (code, reason) => {
|
|
29016
|
-
try {
|
|
29017
|
-
events?.onClose?.(new CloseEvent("close", {
|
|
29018
|
-
code,
|
|
29019
|
-
reason: reason.toString()
|
|
29020
|
-
}), ctx);
|
|
29021
|
-
} catch (e) {
|
|
29022
|
-
(options?.onError ?? console.error)(e);
|
|
29023
|
-
}
|
|
29024
|
-
});
|
|
29025
|
-
ws.on("error", (error) => {
|
|
29026
|
-
try {
|
|
29027
|
-
events?.onError?.(new ErrorEvent("error", { error }), ctx);
|
|
29028
|
-
} catch (e) {
|
|
29029
|
-
(options?.onError ?? console.error)(e);
|
|
29030
|
-
}
|
|
29031
|
-
});
|
|
29032
|
-
})();
|
|
29033
|
-
return new Response();
|
|
29034
|
-
})
|
|
29035
|
-
};
|
|
29036
|
-
};
|
|
29037
|
-
//#endregion
|
|
29038
28907
|
//#region src/satori/server.ts
|
|
29039
28908
|
var SatoriServer = class {
|
|
29040
28909
|
app;
|
|
@@ -29043,7 +28912,6 @@ var SatoriServer = class {
|
|
|
29043
28912
|
wsClients = [];
|
|
29044
28913
|
actionMap;
|
|
29045
28914
|
routesRegistered = false;
|
|
29046
|
-
injectWebSocket;
|
|
29047
28915
|
constructor(ctx, config) {
|
|
29048
28916
|
this.ctx = ctx;
|
|
29049
28917
|
this.config = config;
|
|
@@ -29077,18 +28945,20 @@ var SatoriServer = class {
|
|
|
29077
28945
|
this.routesRegistered = true;
|
|
29078
28946
|
}
|
|
29079
28947
|
const { host, port } = this.config;
|
|
28948
|
+
const wss = new WebSocketServer({
|
|
28949
|
+
noServer: true,
|
|
28950
|
+
maxPayload: constants.MAX_STRING_LENGTH
|
|
28951
|
+
});
|
|
29080
28952
|
this.httpServer = serve({
|
|
29081
28953
|
fetch: this.app.fetch,
|
|
28954
|
+
websocket: { server: wss },
|
|
29082
28955
|
port,
|
|
29083
28956
|
hostname: host
|
|
29084
28957
|
}, () => {
|
|
29085
28958
|
this.ctx.logger.info(`Satori server started ${host || "0.0.0.0"}:${port}`);
|
|
29086
28959
|
});
|
|
29087
|
-
this.injectWebSocket?.(this.httpServer);
|
|
29088
28960
|
}
|
|
29089
28961
|
registerRoutes() {
|
|
29090
|
-
const { injectWebSocket, upgradeWebSocket } = createNodeWebSocket({ app: this.app });
|
|
29091
|
-
this.injectWebSocket = injectWebSocket;
|
|
29092
28962
|
this.app.get("/v1/events", upgradeWebSocket((c) => {
|
|
29093
28963
|
return { onMessage: async (event, ws) => {
|
|
29094
28964
|
let payload;
|
|
@@ -42366,7 +42236,6 @@ var MilkyHttpHandler = class {
|
|
|
42366
42236
|
this.ctx.logger.info("MilkyHttp", `${c.env.incoming.socket.remoteAddress} -> ${c.req.path} (${response.retcode === 0 ? "OK" : response.retcode} ${end - start}ms)`, payload);
|
|
42367
42237
|
return c.json(response);
|
|
42368
42238
|
});
|
|
42369
|
-
const { injectWebSocket, upgradeWebSocket } = createNodeWebSocket({ app: this.app });
|
|
42370
42239
|
this.app.get(`${this.config.prefix}/event`, upgradeWebSocket((c) => {
|
|
42371
42240
|
return {
|
|
42372
42241
|
onOpen: (event, ws) => {
|
|
@@ -42407,15 +42276,19 @@ var MilkyHttpHandler = class {
|
|
|
42407
42276
|
});
|
|
42408
42277
|
});
|
|
42409
42278
|
});
|
|
42279
|
+
const wss = new WebSocketServer({
|
|
42280
|
+
noServer: true,
|
|
42281
|
+
maxPayload: constants.MAX_STRING_LENGTH
|
|
42282
|
+
});
|
|
42410
42283
|
this.httpServer = serve({
|
|
42411
42284
|
fetch: this.app.fetch,
|
|
42285
|
+
websocket: { server: wss },
|
|
42412
42286
|
port: this.config.port,
|
|
42413
42287
|
hostname: this.config.host
|
|
42414
42288
|
}, () => {
|
|
42415
42289
|
const displayHost = this.config.host || "0.0.0.0";
|
|
42416
42290
|
this.ctx.logger.info("MilkyHttp", `HTTP server started at ${displayHost}:${this.config.port}${this.config.prefix}`);
|
|
42417
42291
|
});
|
|
42418
|
-
injectWebSocket(this.httpServer);
|
|
42419
42292
|
}
|
|
42420
42293
|
stop() {
|
|
42421
42294
|
for (const stream of this.sseClients) stream.abort();
|
|
@@ -46434,7 +46307,7 @@ function getIgnoreAttributesFn(ignoreAttributes) {
|
|
|
46434
46307
|
return () => false;
|
|
46435
46308
|
}
|
|
46436
46309
|
//#endregion
|
|
46437
|
-
//#region node_modules/
|
|
46310
|
+
//#region node_modules/path-expression-matcher/src/Expression.js
|
|
46438
46311
|
/**
|
|
46439
46312
|
* Expression - Parses and stores a tag pattern expression
|
|
46440
46313
|
*
|
|
@@ -46586,7 +46459,7 @@ var Expression = class {
|
|
|
46586
46459
|
}
|
|
46587
46460
|
};
|
|
46588
46461
|
//#endregion
|
|
46589
|
-
//#region node_modules/
|
|
46462
|
+
//#region node_modules/path-expression-matcher/src/ExpressionSet.js
|
|
46590
46463
|
/**
|
|
46591
46464
|
* ExpressionSet - An indexed collection of Expressions for efficient bulk matching
|
|
46592
46465
|
*
|
|
@@ -46759,7 +46632,7 @@ var ExpressionSet = class {
|
|
|
46759
46632
|
}
|
|
46760
46633
|
};
|
|
46761
46634
|
//#endregion
|
|
46762
|
-
//#region node_modules/
|
|
46635
|
+
//#region node_modules/path-expression-matcher/src/Matcher.js
|
|
46763
46636
|
/**
|
|
46764
46637
|
* MatcherView - A lightweight read-only view over a Matcher's internal state.
|
|
46765
46638
|
*
|
|
@@ -54186,9 +54059,7 @@ var NTQQUserApi = class extends Service {
|
|
|
54186
54059
|
return await this.ctx.pmhq.invoke("nodeIKernelProfileService/getCoreAndBaseInfo", ["nodeStore", uids]);
|
|
54187
54060
|
}
|
|
54188
54061
|
async getBuddyNick(uid) {
|
|
54189
|
-
|
|
54190
|
-
if (nick === void 0) this.ctx.logger.warn(`获取昵称失败, uid: ${uid}`);
|
|
54191
|
-
return nick ?? "";
|
|
54062
|
+
return (await this.ctx.pmhq.invoke("nodeIKernelBuddyService/getBuddyNick", [[uid]])).get(uid);
|
|
54192
54063
|
}
|
|
54193
54064
|
async getCookies(domain) {
|
|
54194
54065
|
const clientKeyData = await this.forceFetchClientKey();
|
|
@@ -54212,7 +54083,11 @@ var NTQQUserApi = class extends Service {
|
|
|
54212
54083
|
return await this.ctx.pmhq.invoke("nodeIKernelTicketService/forceFetchClientKey", [""]);
|
|
54213
54084
|
}
|
|
54214
54085
|
async getSelfNick(refresh = true) {
|
|
54215
|
-
if ((refresh || !selfInfo.nick) && selfInfo.uid)
|
|
54086
|
+
if ((refresh || !selfInfo.nick) && selfInfo.uid) {
|
|
54087
|
+
let nick = await this.getBuddyNick(selfInfo.uid);
|
|
54088
|
+
if (nick === void 0) nick = (await this.getUserSimpleInfo(selfInfo.uid, refresh)).coreInfo.nick;
|
|
54089
|
+
selfInfo.nick = nick;
|
|
54090
|
+
}
|
|
54216
54091
|
return selfInfo.nick;
|
|
54217
54092
|
}
|
|
54218
54093
|
async setSelfStatus(status, extStatus, batteryStatus) {
|
|
@@ -54425,101 +54300,152 @@ var NTQQWebApi = class extends Service {
|
|
|
54425
54300
|
const filePath = filePathList[i];
|
|
54426
54301
|
const fileBuffer = await fsPromise.readFile(filePath);
|
|
54427
54302
|
const fileSize = fileBuffer.length;
|
|
54428
|
-
const
|
|
54429
|
-
const getSessionUrl = `https://${domain}/webapp/json/sliceUpload/FileBatchControl/${checksum}?g_tk=${gtk}`;
|
|
54303
|
+
const fileType = await fileTypeFromBuffer(fileBuffer);
|
|
54430
54304
|
const timestamp = Math.floor(Date.now() / 1e3);
|
|
54431
|
-
const
|
|
54432
|
-
|
|
54433
|
-
|
|
54434
|
-
|
|
54435
|
-
|
|
54436
|
-
|
|
54437
|
-
|
|
54438
|
-
|
|
54439
|
-
|
|
54440
|
-
|
|
54441
|
-
|
|
54442
|
-
"env": {
|
|
54443
|
-
"refer": "qzone",
|
|
54444
|
-
"deviceInfo": "h5"
|
|
54445
|
-
},
|
|
54446
|
-
"model": 0,
|
|
54447
|
-
"biz_req": {
|
|
54448
|
-
"sPicTitle": "",
|
|
54449
|
-
"sPicDesc": "",
|
|
54450
|
-
"sAlbumName": "",
|
|
54451
|
-
"sAlbumID": albumID,
|
|
54452
|
-
"iAlbumTypeID": 0,
|
|
54453
|
-
"iBitmap": 0,
|
|
54454
|
-
"iUploadType": 0,
|
|
54455
|
-
"iUpPicType": 0,
|
|
54456
|
-
"iBatchID": iBatchID,
|
|
54457
|
-
"sPicPath": "",
|
|
54458
|
-
"iPicWidth": 0,
|
|
54459
|
-
"iPicHight": 0,
|
|
54460
|
-
"iWaterType": 0,
|
|
54461
|
-
"iDistinctUse": 0,
|
|
54462
|
-
"iNeedFeeds": 1,
|
|
54463
|
-
"iUploadTime": timestamp,
|
|
54464
|
-
"mapExt": {
|
|
54465
|
-
"appid": "qun",
|
|
54466
|
-
"userid": groupCode
|
|
54305
|
+
const isVideo = fileType?.mime.startsWith("video");
|
|
54306
|
+
let res;
|
|
54307
|
+
if (isVideo) {
|
|
54308
|
+
const checksum = getSha1HexFromBuffer(fileBuffer);
|
|
54309
|
+
const getSessionUrl = `https://${domain}/webapp/json/sliceUpload/FileBatchControl/${checksum}?g_tk=${gtk}`;
|
|
54310
|
+
const getSessionPostData = { "control_req": [{
|
|
54311
|
+
"uin": selfInfo.uin,
|
|
54312
|
+
"token": {
|
|
54313
|
+
"type": 4,
|
|
54314
|
+
"data": cookiesObject.p_skey,
|
|
54315
|
+
"appid": 5
|
|
54467
54316
|
},
|
|
54468
|
-
"
|
|
54469
|
-
|
|
54470
|
-
|
|
54471
|
-
|
|
54472
|
-
|
|
54473
|
-
|
|
54474
|
-
"
|
|
54475
|
-
|
|
54476
|
-
|
|
54477
|
-
|
|
54478
|
-
|
|
54479
|
-
|
|
54480
|
-
|
|
54481
|
-
|
|
54482
|
-
|
|
54483
|
-
|
|
54484
|
-
|
|
54317
|
+
"appid": "video_qun",
|
|
54318
|
+
"checksum": checksum,
|
|
54319
|
+
"check_type": 1,
|
|
54320
|
+
"file_len": fileSize,
|
|
54321
|
+
"env": {
|
|
54322
|
+
"refer": "qzone",
|
|
54323
|
+
"deviceInfo": "h5"
|
|
54324
|
+
},
|
|
54325
|
+
"model": 0,
|
|
54326
|
+
"biz_req": {
|
|
54327
|
+
"sPicTitle": "",
|
|
54328
|
+
"sPicDesc": "",
|
|
54329
|
+
"sAlbumName": "",
|
|
54330
|
+
"sAlbumID": "",
|
|
54331
|
+
"iAlbumTypeID": 0,
|
|
54332
|
+
"iBitmap": 0,
|
|
54333
|
+
"iUploadType": 3,
|
|
54334
|
+
"iUpPicType": 0,
|
|
54335
|
+
"iBatchID": 0,
|
|
54336
|
+
"sPicPath": "",
|
|
54337
|
+
"iPicWidth": 0,
|
|
54338
|
+
"iPicHight": 0,
|
|
54339
|
+
"iWaterType": 0,
|
|
54340
|
+
"iDistinctUse": 0,
|
|
54341
|
+
"sTitle": "",
|
|
54342
|
+
"sDesc": "",
|
|
54343
|
+
"iFlag": 0,
|
|
54344
|
+
"iUploadTime": timestamp,
|
|
54345
|
+
"iPlayTime": 0,
|
|
54346
|
+
"sCoverUrl": "",
|
|
54347
|
+
"iIsNew": 111,
|
|
54348
|
+
"iIsOriginalVideo": 0,
|
|
54349
|
+
"iIsFormatF20": 0,
|
|
54350
|
+
"extend_info": {
|
|
54351
|
+
"video_type": "3",
|
|
54352
|
+
"domainid": "5",
|
|
54353
|
+
"photo_num": "0",
|
|
54354
|
+
"video_num": fileLen,
|
|
54355
|
+
"batch_num": fileLen,
|
|
54356
|
+
"qun_id": groupCode
|
|
54357
|
+
}
|
|
54358
|
+
},
|
|
54359
|
+
"session": "",
|
|
54360
|
+
"asy_upload": 0,
|
|
54361
|
+
"cmd": "FileUploadVideo"
|
|
54362
|
+
}] };
|
|
54363
|
+
res = await HttpUtil.post(getSessionUrl, getSessionPostData, this.cookieToString(cookiesObject));
|
|
54364
|
+
} else {
|
|
54365
|
+
const checksum = getMd5HexFromBuffer(fileBuffer);
|
|
54366
|
+
const getSessionUrl = `https://${domain}/webapp/json/sliceUpload/FileBatchControl/${checksum}?g_tk=${gtk}`;
|
|
54367
|
+
const getSessionPostData = { "control_req": [{
|
|
54368
|
+
"uin": selfInfo.uin,
|
|
54369
|
+
"token": {
|
|
54370
|
+
"type": 4,
|
|
54371
|
+
"data": cookiesObject.p_skey,
|
|
54372
|
+
"appid": 5
|
|
54373
|
+
},
|
|
54374
|
+
"appid": "qun",
|
|
54375
|
+
"checksum": checksum,
|
|
54376
|
+
"check_type": 0,
|
|
54377
|
+
"file_len": fileSize,
|
|
54378
|
+
"env": {
|
|
54379
|
+
"refer": "qzone",
|
|
54380
|
+
"deviceInfo": "h5"
|
|
54381
|
+
},
|
|
54382
|
+
"model": 0,
|
|
54383
|
+
"biz_req": {
|
|
54384
|
+
"sPicTitle": "",
|
|
54385
|
+
"sPicDesc": "",
|
|
54386
|
+
"sAlbumName": "",
|
|
54387
|
+
"sAlbumID": albumID,
|
|
54388
|
+
"iAlbumTypeID": 0,
|
|
54389
|
+
"iBitmap": 0,
|
|
54390
|
+
"iUploadType": 0,
|
|
54391
|
+
"iUpPicType": 0,
|
|
54392
|
+
"iBatchID": iBatchID,
|
|
54393
|
+
"sPicPath": "",
|
|
54394
|
+
"iPicWidth": 0,
|
|
54395
|
+
"iPicHight": 0,
|
|
54396
|
+
"iWaterType": 0,
|
|
54397
|
+
"iDistinctUse": 0,
|
|
54398
|
+
"iNeedFeeds": 1,
|
|
54399
|
+
"iUploadTime": timestamp,
|
|
54400
|
+
"mapExt": {
|
|
54401
|
+
"appid": "qun",
|
|
54402
|
+
"userid": groupCode
|
|
54403
|
+
},
|
|
54404
|
+
"stExtendInfo": { "mapParams": {
|
|
54405
|
+
"photo_num": fileLen,
|
|
54406
|
+
"video_num": "0",
|
|
54407
|
+
"batch_num": fileLen
|
|
54408
|
+
} },
|
|
54409
|
+
"mutliPicInfo": {
|
|
54410
|
+
"iBatUploadNum": fileLen,
|
|
54411
|
+
"iCurUpload": i,
|
|
54412
|
+
"iSuccNum": 0,
|
|
54413
|
+
"iFailNum": 0
|
|
54414
|
+
}
|
|
54415
|
+
},
|
|
54416
|
+
"session": "",
|
|
54417
|
+
"asy_upload": 0,
|
|
54418
|
+
"cmd": "FileUpload"
|
|
54419
|
+
}] };
|
|
54420
|
+
res = await HttpUtil.post(getSessionUrl, getSessionPostData, this.cookieToString(cookiesObject));
|
|
54421
|
+
}
|
|
54422
|
+
const resJson = await res.json();
|
|
54485
54423
|
if (resJson.ret !== 0) {
|
|
54486
54424
|
this.ctx.logger.error(`获取群相册上传 session 失败: ${resJson.msg}`);
|
|
54487
54425
|
errIndexList.push(i);
|
|
54488
54426
|
continue;
|
|
54489
54427
|
}
|
|
54490
|
-
const sessionId = resJson.data.session;
|
|
54491
54428
|
const sliceSize = resJson.data.slice_size;
|
|
54492
54429
|
let offset = 0;
|
|
54493
54430
|
let seq = 1;
|
|
54494
54431
|
const concurrency = 10;
|
|
54495
|
-
|
|
54496
|
-
while (offset < fileSize) {
|
|
54497
|
-
const end = Math.min(offset + sliceSize, fileSize);
|
|
54498
|
-
const chunk = fileBuffer.subarray(offset, end);
|
|
54499
|
-
slices.push({
|
|
54500
|
-
offset,
|
|
54501
|
-
end,
|
|
54502
|
-
seq,
|
|
54503
|
-
chunk
|
|
54504
|
-
});
|
|
54505
|
-
offset = end;
|
|
54506
|
-
seq++;
|
|
54507
|
-
}
|
|
54432
|
+
let sVid;
|
|
54508
54433
|
const uploadSlice = async (slice) => {
|
|
54509
|
-
const
|
|
54434
|
+
const cmd = slice.isVideo ? "FileUploadVideo" : "FileUpload";
|
|
54435
|
+
const uploadUrl = `https://${domain}/webapp/json/sliceUpload/${cmd}?seq=${slice.seq}&retry=0&offset=${slice.offset}&end=${slice.end}&total=${fileSize}&type=form&g_tk=${gtk}`;
|
|
54510
54436
|
const formData = new FormData();
|
|
54511
54437
|
formData.append("uin", selfInfo.uin);
|
|
54512
|
-
formData.append("appid", "qun");
|
|
54438
|
+
formData.append("appid", slice.isVideo ? "video_qun" : "qun");
|
|
54513
54439
|
formData.append("data", new Blob([Uint8Array.from(slice.chunk)]));
|
|
54514
|
-
formData.append("session", sessionId);
|
|
54440
|
+
formData.append("session", slice.sessionId);
|
|
54515
54441
|
formData.append("offset", slice.offset.toString());
|
|
54516
54442
|
formData.append("checksum", "");
|
|
54517
54443
|
formData.append("check_type", "0");
|
|
54518
54444
|
formData.append("retry", "0");
|
|
54519
54445
|
formData.append("seq", slice.seq.toString());
|
|
54520
54446
|
formData.append("end", slice.end.toString());
|
|
54521
|
-
formData.append("cmd",
|
|
54522
|
-
formData.append("slice_size", sliceSize
|
|
54447
|
+
formData.append("cmd", cmd);
|
|
54448
|
+
formData.append("slice_size", slice.sliceSize);
|
|
54523
54449
|
formData.append("biz_req.iUploadType", "0");
|
|
54524
54450
|
const uploadResJson = await (await fetch(uploadUrl, {
|
|
54525
54451
|
method: "POST",
|
|
@@ -54529,8 +54455,24 @@ var NTQQWebApi = class extends Service {
|
|
|
54529
54455
|
if (uploadResJson.ret !== 0) {
|
|
54530
54456
|
if (!errIndexList.includes(i)) errIndexList.push(i);
|
|
54531
54457
|
throw new Error(`群相册分片上传失败 (seq: ${slice.seq}): ${uploadResJson.msg}, file: ${filePath}`);
|
|
54532
|
-
}
|
|
54458
|
+
} else if (uploadResJson.data.biz.sVid) sVid = uploadResJson.data.biz.sVid;
|
|
54533
54459
|
};
|
|
54460
|
+
const slices = [];
|
|
54461
|
+
while (offset < fileSize) {
|
|
54462
|
+
const end = Math.min(offset + sliceSize, fileSize);
|
|
54463
|
+
const chunk = fileBuffer.subarray(offset, end);
|
|
54464
|
+
slices.push({
|
|
54465
|
+
offset,
|
|
54466
|
+
end,
|
|
54467
|
+
seq,
|
|
54468
|
+
chunk,
|
|
54469
|
+
isVideo: !!isVideo,
|
|
54470
|
+
sessionId: resJson.data.session,
|
|
54471
|
+
sliceSize: sliceSize.toString()
|
|
54472
|
+
});
|
|
54473
|
+
offset = end;
|
|
54474
|
+
seq++;
|
|
54475
|
+
}
|
|
54534
54476
|
for (let i = 0; i < slices.length; i += concurrency) {
|
|
54535
54477
|
const batch = slices.slice(i, i + concurrency);
|
|
54536
54478
|
try {
|
|
@@ -54539,6 +54481,112 @@ var NTQQWebApi = class extends Service {
|
|
|
54539
54481
|
this.ctx.logger.error(e);
|
|
54540
54482
|
}
|
|
54541
54483
|
}
|
|
54484
|
+
if (sVid) {
|
|
54485
|
+
const filePath = await createThumb(this.ctx, filePathList[i]);
|
|
54486
|
+
const fileBuffer = await fsPromise.readFile(filePath);
|
|
54487
|
+
const fileSize = fileBuffer.length;
|
|
54488
|
+
const timestamp = Math.floor(Date.now() / 1e3);
|
|
54489
|
+
const checksum = getMd5HexFromBuffer(fileBuffer);
|
|
54490
|
+
const getSessionUrl = `https://${domain}/webapp/json/sliceUpload/FileBatchControl/${checksum}?g_tk=${gtk}`;
|
|
54491
|
+
const getSessionPostData = { "control_req": [{
|
|
54492
|
+
"uin": selfInfo.uin,
|
|
54493
|
+
"token": {
|
|
54494
|
+
"type": 4,
|
|
54495
|
+
"data": cookiesObject.p_skey,
|
|
54496
|
+
"appid": 5
|
|
54497
|
+
},
|
|
54498
|
+
"appid": "qun",
|
|
54499
|
+
"checksum": checksum,
|
|
54500
|
+
"check_type": 0,
|
|
54501
|
+
"file_len": fileSize,
|
|
54502
|
+
"env": {
|
|
54503
|
+
"refer": "huodong",
|
|
54504
|
+
"deviceInfo": "h5"
|
|
54505
|
+
},
|
|
54506
|
+
"model": 0,
|
|
54507
|
+
"biz_req": {
|
|
54508
|
+
"sPicTitle": "",
|
|
54509
|
+
"sPicDesc": "",
|
|
54510
|
+
"sAlbumName": "",
|
|
54511
|
+
"sAlbumID": albumID,
|
|
54512
|
+
"iAlbumTypeID": 0,
|
|
54513
|
+
"iBitmap": 0,
|
|
54514
|
+
"iUploadType": 2,
|
|
54515
|
+
"iUpPicType": 0,
|
|
54516
|
+
"iBatchID": iBatchID,
|
|
54517
|
+
"sPicPath": "",
|
|
54518
|
+
"iPicWidth": 0,
|
|
54519
|
+
"iPicHight": 0,
|
|
54520
|
+
"iWaterType": 0,
|
|
54521
|
+
"iDistinctUse": 0,
|
|
54522
|
+
"mutliPicInfo": {
|
|
54523
|
+
"iBatUploadNum": fileLen,
|
|
54524
|
+
"iCurUpload": i,
|
|
54525
|
+
"iSuccNum": 0,
|
|
54526
|
+
"iFailNum": 0
|
|
54527
|
+
},
|
|
54528
|
+
"iNeedFeeds": 1,
|
|
54529
|
+
"iUploadTime": timestamp,
|
|
54530
|
+
"stExtendInfo": { "mapParams": {
|
|
54531
|
+
"vid": sVid,
|
|
54532
|
+
"photo_num": "0",
|
|
54533
|
+
"video_num": fileLen,
|
|
54534
|
+
"batch_num": fileLen
|
|
54535
|
+
} },
|
|
54536
|
+
"stExternalMapExt": {
|
|
54537
|
+
"is_client_upload_cover": "1",
|
|
54538
|
+
"is_pic_video_mix_feeds": "1"
|
|
54539
|
+
},
|
|
54540
|
+
"mapExt": {
|
|
54541
|
+
"appid": "qun",
|
|
54542
|
+
"userid": groupCode
|
|
54543
|
+
},
|
|
54544
|
+
"sExif_CameraMaker": "",
|
|
54545
|
+
"sExif_CameraModel": "",
|
|
54546
|
+
"sExif_Time": "",
|
|
54547
|
+
"sExif_LatitudeRef": "",
|
|
54548
|
+
"sExif_Latitude": "",
|
|
54549
|
+
"sExif_LongitudeRef": "",
|
|
54550
|
+
"sExif_Longitude": ""
|
|
54551
|
+
},
|
|
54552
|
+
"session": "",
|
|
54553
|
+
"asy_upload": 0
|
|
54554
|
+
}] };
|
|
54555
|
+
const resJson = await (await HttpUtil.post(getSessionUrl, getSessionPostData, this.cookieToString(cookiesObject))).json();
|
|
54556
|
+
if (resJson.ret !== 0) {
|
|
54557
|
+
this.ctx.logger.error(`获取群相册上传 session 失败: ${resJson.msg}`);
|
|
54558
|
+
errIndexList.push(i);
|
|
54559
|
+
continue;
|
|
54560
|
+
}
|
|
54561
|
+
const sliceSize = resJson.data.slice_size;
|
|
54562
|
+
let offset = 0;
|
|
54563
|
+
let seq = 1;
|
|
54564
|
+
const concurrency = 10;
|
|
54565
|
+
const slices = [];
|
|
54566
|
+
while (offset < fileSize) {
|
|
54567
|
+
const end = Math.min(offset + sliceSize, fileSize);
|
|
54568
|
+
const chunk = fileBuffer.subarray(offset, end);
|
|
54569
|
+
slices.push({
|
|
54570
|
+
offset,
|
|
54571
|
+
end,
|
|
54572
|
+
seq,
|
|
54573
|
+
chunk,
|
|
54574
|
+
isVideo: false,
|
|
54575
|
+
sessionId: resJson.data.session,
|
|
54576
|
+
sliceSize: sliceSize.toString()
|
|
54577
|
+
});
|
|
54578
|
+
offset = end;
|
|
54579
|
+
seq++;
|
|
54580
|
+
}
|
|
54581
|
+
for (let i = 0; i < slices.length; i += concurrency) {
|
|
54582
|
+
const batch = slices.slice(i, i + concurrency);
|
|
54583
|
+
try {
|
|
54584
|
+
await Promise.all(batch.map((slice) => uploadSlice(slice)));
|
|
54585
|
+
} catch (e) {
|
|
54586
|
+
this.ctx.logger.error(e);
|
|
54587
|
+
}
|
|
54588
|
+
}
|
|
54589
|
+
}
|
|
54542
54590
|
}
|
|
54543
54591
|
this.ctx.logger.info("群相册上传完成");
|
|
54544
54592
|
return {
|
|
@@ -54547,6 +54595,37 @@ var NTQQWebApi = class extends Service {
|
|
|
54547
54595
|
fail_indexes: errIndexList
|
|
54548
54596
|
};
|
|
54549
54597
|
}
|
|
54598
|
+
async publishGroupBulletin(groupCode, text, pinned, type, isShowEditCard, tipWindowType, confirmRequired, picId, imgWidth, imgHeight) {
|
|
54599
|
+
const cookieObject = await this.ctx.ntUserApi.getCookies("qun.qq.com");
|
|
54600
|
+
const bkn = this.genBkn(cookieObject.skey);
|
|
54601
|
+
const picInfo = {
|
|
54602
|
+
pic: picId,
|
|
54603
|
+
imgWidth: imgWidth?.toString(),
|
|
54604
|
+
imgHeight: imgHeight?.toString()
|
|
54605
|
+
};
|
|
54606
|
+
const res = await fetch("https://web.qun.qq.com/cgi-bin/announce/add_qun_notice", {
|
|
54607
|
+
method: "POST",
|
|
54608
|
+
headers: {
|
|
54609
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
54610
|
+
"Cookie": this.cookieToString(cookieObject)
|
|
54611
|
+
},
|
|
54612
|
+
body: new URLSearchParams({
|
|
54613
|
+
qid: groupCode,
|
|
54614
|
+
bkn,
|
|
54615
|
+
text,
|
|
54616
|
+
pinned: pinned.toString(),
|
|
54617
|
+
type: type.toString(),
|
|
54618
|
+
settings: JSON.stringify({
|
|
54619
|
+
is_show_edit_card: isShowEditCard,
|
|
54620
|
+
tip_window_type: tipWindowType,
|
|
54621
|
+
confirm_required: confirmRequired
|
|
54622
|
+
}),
|
|
54623
|
+
...picId ? picInfo : {}
|
|
54624
|
+
})
|
|
54625
|
+
});
|
|
54626
|
+
if (!res.ok) throw new Error(`HTTP error! Status: ${res.status}`);
|
|
54627
|
+
return await res.json();
|
|
54628
|
+
}
|
|
54550
54629
|
};
|
|
54551
54630
|
//#endregion
|
|
54552
54631
|
//#region src/ntqqapi/api/system.ts
|
|
@@ -58044,7 +58123,7 @@ var package_exports = /* @__PURE__ */ __exportAll({
|
|
|
58044
58123
|
var name, version, description, main, scripts, repository, keywords, author, license, bugs, homepage, devDependencies, engines, package_default;
|
|
58045
58124
|
var init_package = __esmMin((() => {
|
|
58046
58125
|
name = "nodemailer";
|
|
58047
|
-
version = "8.0.
|
|
58126
|
+
version = "8.0.7";
|
|
58048
58127
|
description = "Easy as cake e-mail sending from your Node.js applications";
|
|
58049
58128
|
main = "lib/nodemailer.js";
|
|
58050
58129
|
scripts = {
|
|
@@ -58067,20 +58146,19 @@ var init_package = __esmMin((() => {
|
|
|
58067
58146
|
bugs = { "url": "https://github.com/nodemailer/nodemailer/issues" };
|
|
58068
58147
|
homepage = "https://nodemailer.com/";
|
|
58069
58148
|
devDependencies = {
|
|
58070
|
-
"@aws-sdk/client-sesv2": "3.
|
|
58149
|
+
"@aws-sdk/client-sesv2": "3.1037.0",
|
|
58071
58150
|
"bunyan": "1.8.15",
|
|
58072
58151
|
"c8": "11.0.0",
|
|
58073
|
-
"eslint": "10.2.
|
|
58152
|
+
"eslint": "10.2.1",
|
|
58074
58153
|
"eslint-config-prettier": "10.1.8",
|
|
58075
|
-
"globals": "17.
|
|
58154
|
+
"globals": "17.5.0",
|
|
58076
58155
|
"libbase64": "1.3.0",
|
|
58077
|
-
"libmime": "5.3.
|
|
58156
|
+
"libmime": "5.3.8",
|
|
58078
58157
|
"libqp": "2.1.1",
|
|
58079
|
-
"
|
|
58080
|
-
"prettier": "3.8.1",
|
|
58158
|
+
"prettier": "3.8.3",
|
|
58081
58159
|
"proxy": "1.0.2",
|
|
58082
58160
|
"proxy-test-server": "1.0.0",
|
|
58083
|
-
"smtp-server": "3.18.
|
|
58161
|
+
"smtp-server": "3.18.4"
|
|
58084
58162
|
};
|
|
58085
58163
|
engines = { "node": ">=6.0.0" };
|
|
58086
58164
|
package_default = {
|
|
@@ -63478,9 +63556,10 @@ var require_mime_node = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
63478
63556
|
if (lastAt < 0) return address;
|
|
63479
63557
|
let user = address.substr(0, lastAt);
|
|
63480
63558
|
const domain = address.substr(lastAt + 1);
|
|
63481
|
-
let encodedDomain;
|
|
63559
|
+
let encodedDomain = domain;
|
|
63482
63560
|
try {
|
|
63483
|
-
encodedDomain = punycode.
|
|
63561
|
+
if (/[\x80-\uFFFF]/.test(user)) encodedDomain = punycode.toUnicode(domain.toLowerCase());
|
|
63562
|
+
else encodedDomain = punycode.toASCII(domain.toLowerCase());
|
|
63484
63563
|
} catch (_err) {}
|
|
63485
63564
|
if (user.indexOf(" ") >= 0) {
|
|
63486
63565
|
if (user.charAt(0) !== "\"") user = "\"" + user;
|