llonebot-dist 7.12.13 → 7.12.15
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 +1076 -750
- package/llbot.js.map +1 -1
- package/package.json +1 -1
- package/webui/assets/index-CM5wLm3n.css +2 -0
- package/webui/assets/{index-nQk7kGKN.js → index-QGFL6Imu.js} +9 -12
- package/webui/index.html +2 -2
- package//346/233/264/346/226/260/346/227/245/345/277/227.txt +12 -0
- package/webui/assets/index-D-XIyK1s.css +0 -2
package/llbot.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
2
|
import * as path$4 from "node:path";
|
|
3
3
|
import path, { dirname, join } from "node:path";
|
|
4
|
-
import
|
|
5
|
-
import fs
|
|
6
|
-
import * as fs$
|
|
7
|
-
import fs$
|
|
4
|
+
import fsPromise, { copyFile, mkdir, readFile, stat, unlink, writeFile } from "node:fs/promises";
|
|
5
|
+
import fs, { existsSync } from "fs";
|
|
6
|
+
import * as fs$5 from "node:fs";
|
|
7
|
+
import fs$1, { appendFile, appendFileSync, createReadStream, existsSync as existsSync$1, mkdirSync, promises, stat as stat$1, statSync, watch } from "node:fs";
|
|
8
8
|
import os from "node:os";
|
|
9
9
|
import { Binary, Time, camelize, clone, deduplicate, deepEqual, defineProperty, difference, filterKeys, hyphenate, is, isNonNullable, isNullable, isPlainObject, makeArray, mapValues, noop, omit, pick, remove, valueMap } from "cosmokit";
|
|
10
10
|
import { Exporter, Factory } from "reggol";
|
|
@@ -21,7 +21,7 @@ import http, { STATUS_CODES, createServer, request } from "node:http";
|
|
|
21
21
|
import { Http2ServerRequest, constants as constants$1 } from "node:http2";
|
|
22
22
|
import { Readable, Transform } from "node:stream";
|
|
23
23
|
import { deflateSync, gunzipSync, gzipSync, inflateSync } from "node:zlib";
|
|
24
|
-
import fsPromise, { stat as stat$2, unlink as unlink$1 } from "fs/promises";
|
|
24
|
+
import fsPromise$1, { stat as stat$2, unlink as unlink$1 } from "fs/promises";
|
|
25
25
|
import { inspect, isDeepStrictEqual } from "node:util";
|
|
26
26
|
import net, { connect } from "node:net";
|
|
27
27
|
import https from "node:https";
|
|
@@ -3973,7 +3973,7 @@ var require_utils$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
3973
3973
|
//#endregion
|
|
3974
3974
|
//#region node_modules/qrcode/lib/renderer/png.js
|
|
3975
3975
|
var require_png = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
3976
|
-
var fs$
|
|
3976
|
+
var fs$10 = __require("fs");
|
|
3977
3977
|
var PNG = require_png$1().PNG;
|
|
3978
3978
|
var Utils = require_utils$1();
|
|
3979
3979
|
exports.render = function render(qrData, options) {
|
|
@@ -4025,7 +4025,7 @@ var require_png = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
4025
4025
|
called = true;
|
|
4026
4026
|
cb.apply(null, args);
|
|
4027
4027
|
};
|
|
4028
|
-
const stream = fs$
|
|
4028
|
+
const stream = fs$10.createWriteStream(path);
|
|
4029
4029
|
stream.on("error", done);
|
|
4030
4030
|
stream.on("close", done);
|
|
4031
4031
|
exports.renderToFileStream(stream, qrData, options);
|
|
@@ -6475,19 +6475,6 @@ var ChatType = /* @__PURE__ */ function(ChatType) {
|
|
|
6475
6475
|
ChatType[ChatType["TempC2CFromGroup"] = 100] = "TempC2CFromGroup";
|
|
6476
6476
|
return ChatType;
|
|
6477
6477
|
}({});
|
|
6478
|
-
var RMBizType = /* @__PURE__ */ function(RMBizType) {
|
|
6479
|
-
RMBizType[RMBizType["Unknown"] = 0] = "Unknown";
|
|
6480
|
-
RMBizType[RMBizType["C2CFile"] = 1] = "C2CFile";
|
|
6481
|
-
RMBizType[RMBizType["GroupFile"] = 2] = "GroupFile";
|
|
6482
|
-
RMBizType[RMBizType["C2CPic"] = 3] = "C2CPic";
|
|
6483
|
-
RMBizType[RMBizType["GroupPic"] = 4] = "GroupPic";
|
|
6484
|
-
RMBizType[RMBizType["DiscPic"] = 5] = "DiscPic";
|
|
6485
|
-
RMBizType[RMBizType["C2CVideo"] = 6] = "C2CVideo";
|
|
6486
|
-
RMBizType[RMBizType["GroupVideo"] = 7] = "GroupVideo";
|
|
6487
|
-
RMBizType[RMBizType["C2CPtt"] = 8] = "C2CPtt";
|
|
6488
|
-
RMBizType[RMBizType["GroupPtt"] = 9] = "GroupPtt";
|
|
6489
|
-
return RMBizType;
|
|
6490
|
-
}({});
|
|
6491
6478
|
var MsgType = /* @__PURE__ */ function(MsgType) {
|
|
6492
6479
|
MsgType[MsgType["ArkStruct"] = 11] = "ArkStruct";
|
|
6493
6480
|
MsgType[MsgType["FaceBubble"] = 24] = "FaceBubble";
|
|
@@ -6624,7 +6611,7 @@ async function logSummaryMessage(ctx, message) {
|
|
|
6624
6611
|
var require_windows = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
6625
6612
|
module.exports = isexe;
|
|
6626
6613
|
isexe.sync = sync;
|
|
6627
|
-
var fs$
|
|
6614
|
+
var fs$9 = __require("fs");
|
|
6628
6615
|
function checkPathExt(path, options) {
|
|
6629
6616
|
var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
|
|
6630
6617
|
if (!pathext) return true;
|
|
@@ -6641,12 +6628,12 @@ var require_windows = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
6641
6628
|
return checkPathExt(path, options);
|
|
6642
6629
|
}
|
|
6643
6630
|
function isexe(path, options, cb) {
|
|
6644
|
-
fs$
|
|
6631
|
+
fs$9.stat(path, function(er, stat) {
|
|
6645
6632
|
cb(er, er ? false : checkStat(stat, path, options));
|
|
6646
6633
|
});
|
|
6647
6634
|
}
|
|
6648
6635
|
function sync(path, options) {
|
|
6649
|
-
return checkStat(fs$
|
|
6636
|
+
return checkStat(fs$9.statSync(path), path, options);
|
|
6650
6637
|
}
|
|
6651
6638
|
}));
|
|
6652
6639
|
//#endregion
|
|
@@ -6654,14 +6641,14 @@ var require_windows = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
6654
6641
|
var require_mode = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
6655
6642
|
module.exports = isexe;
|
|
6656
6643
|
isexe.sync = sync;
|
|
6657
|
-
var fs$
|
|
6644
|
+
var fs$8 = __require("fs");
|
|
6658
6645
|
function isexe(path, options, cb) {
|
|
6659
|
-
fs$
|
|
6646
|
+
fs$8.stat(path, function(er, stat) {
|
|
6660
6647
|
cb(er, er ? false : checkStat(stat, options));
|
|
6661
6648
|
});
|
|
6662
6649
|
}
|
|
6663
6650
|
function sync(path, options) {
|
|
6664
|
-
return checkStat(fs$
|
|
6651
|
+
return checkStat(fs$8.statSync(path), options);
|
|
6665
6652
|
}
|
|
6666
6653
|
function checkStat(stat, options) {
|
|
6667
6654
|
return stat.isFile() && checkMode(stat, options);
|
|
@@ -9153,7 +9140,7 @@ var require_processor = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
9153
9140
|
//#endregion
|
|
9154
9141
|
//#region node_modules/fluent-ffmpeg/lib/capabilities.js
|
|
9155
9142
|
var require_capabilities = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
9156
|
-
var fs$
|
|
9143
|
+
var fs$7 = __require("fs");
|
|
9157
9144
|
var path$7 = __require("path");
|
|
9158
9145
|
var async = require_async();
|
|
9159
9146
|
var utils = require_utils();
|
|
@@ -9229,7 +9216,7 @@ var require_capabilities = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
9229
9216
|
proto._getFfmpegPath = function(callback) {
|
|
9230
9217
|
if ("ffmpegPath" in cache) return callback(null, cache.ffmpegPath);
|
|
9231
9218
|
async.waterfall([function(cb) {
|
|
9232
|
-
if (process.env.FFMPEG_PATH) fs$
|
|
9219
|
+
if (process.env.FFMPEG_PATH) fs$7.exists(process.env.FFMPEG_PATH, function(exists) {
|
|
9233
9220
|
if (exists) cb(null, process.env.FFMPEG_PATH);
|
|
9234
9221
|
else cb(null, "");
|
|
9235
9222
|
});
|
|
@@ -9260,7 +9247,7 @@ var require_capabilities = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
9260
9247
|
if ("ffprobePath" in cache) return callback(null, cache.ffprobePath);
|
|
9261
9248
|
async.waterfall([
|
|
9262
9249
|
function(cb) {
|
|
9263
|
-
if (process.env.FFPROBE_PATH) fs$
|
|
9250
|
+
if (process.env.FFPROBE_PATH) fs$7.exists(process.env.FFPROBE_PATH, function(exists) {
|
|
9264
9251
|
cb(null, exists ? process.env.FFPROBE_PATH : "");
|
|
9265
9252
|
});
|
|
9266
9253
|
else cb(null, "");
|
|
@@ -9278,7 +9265,7 @@ var require_capabilities = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
9278
9265
|
else if (ffmpeg.length) {
|
|
9279
9266
|
var name = utils.isWindows ? "ffprobe.exe" : "ffprobe";
|
|
9280
9267
|
var ffprobe = path$7.join(path$7.dirname(ffmpeg), name);
|
|
9281
|
-
fs$
|
|
9268
|
+
fs$7.exists(ffprobe, function(exists) {
|
|
9282
9269
|
cb(null, exists ? ffprobe : "");
|
|
9283
9270
|
});
|
|
9284
9271
|
} else cb(null, "");
|
|
@@ -9303,14 +9290,14 @@ var require_capabilities = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
9303
9290
|
if ("flvtoolPath" in cache) return callback(null, cache.flvtoolPath);
|
|
9304
9291
|
async.waterfall([
|
|
9305
9292
|
function(cb) {
|
|
9306
|
-
if (process.env.FLVMETA_PATH) fs$
|
|
9293
|
+
if (process.env.FLVMETA_PATH) fs$7.exists(process.env.FLVMETA_PATH, function(exists) {
|
|
9307
9294
|
cb(null, exists ? process.env.FLVMETA_PATH : "");
|
|
9308
9295
|
});
|
|
9309
9296
|
else cb(null, "");
|
|
9310
9297
|
},
|
|
9311
9298
|
function(flvtool, cb) {
|
|
9312
9299
|
if (flvtool.length) return cb(null, flvtool);
|
|
9313
|
-
if (process.env.FLVTOOL2_PATH) fs$
|
|
9300
|
+
if (process.env.FLVTOOL2_PATH) fs$7.exists(process.env.FLVTOOL2_PATH, function(exists) {
|
|
9314
9301
|
cb(null, exists ? process.env.FLVTOOL2_PATH : "");
|
|
9315
9302
|
});
|
|
9316
9303
|
else cb(null, "");
|
|
@@ -9815,7 +9802,7 @@ var require_ffprobe = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
9815
9802
|
//#endregion
|
|
9816
9803
|
//#region node_modules/fluent-ffmpeg/lib/recipes.js
|
|
9817
9804
|
var require_recipes = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
9818
|
-
var fs$
|
|
9805
|
+
var fs$6 = __require("fs");
|
|
9819
9806
|
var path$6 = __require("path");
|
|
9820
9807
|
var PassThrough$4 = __require("stream").PassThrough;
|
|
9821
9808
|
var async = require_async();
|
|
@@ -10021,8 +10008,8 @@ var require_recipes = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
10021
10008
|
next(null, filenames);
|
|
10022
10009
|
},
|
|
10023
10010
|
function createDirectory(filenames, next) {
|
|
10024
|
-
fs$
|
|
10025
|
-
if (!exists) fs$
|
|
10011
|
+
fs$6.exists(config.folder, function(exists) {
|
|
10012
|
+
if (!exists) fs$6.mkdir(config.folder, function(err) {
|
|
10026
10013
|
if (err) next(err);
|
|
10027
10014
|
else next(null, filenames);
|
|
10028
10015
|
});
|
|
@@ -10270,7 +10257,7 @@ function setFFMpegPath(ffmpegPath) {
|
|
|
10270
10257
|
path.join(import.meta.dirname, "ffmpeg.exe"),
|
|
10271
10258
|
process.env["FFMPEG_PATH"] || ""
|
|
10272
10259
|
];
|
|
10273
|
-
for (const p of paths) if (fs$
|
|
10260
|
+
for (const p of paths) if (fs$1.existsSync(p)) {
|
|
10274
10261
|
import_fluent_ffmpeg.default.setFfmpegPath(p);
|
|
10275
10262
|
console.log("set ffmpeg successfully", p);
|
|
10276
10263
|
break;
|
|
@@ -10801,7 +10788,7 @@ function encodeCQCode(input) {
|
|
|
10801
10788
|
}
|
|
10802
10789
|
//#endregion
|
|
10803
10790
|
//#region src/onebot11/transform/message/incoming.ts
|
|
10804
|
-
async function transformIncomingSegments$1(ctx, message
|
|
10791
|
+
async function transformIncomingSegments$1(ctx, message) {
|
|
10805
10792
|
const segments = [];
|
|
10806
10793
|
let cqCode = "";
|
|
10807
10794
|
for (const element of message.elements) {
|
|
@@ -10873,28 +10860,22 @@ async function transformIncomingSegments$1(ctx, message, rootMsgID, peer) {
|
|
|
10873
10860
|
data: {
|
|
10874
10861
|
file: picElement.fileName,
|
|
10875
10862
|
subType: picElement.picSubType,
|
|
10876
|
-
url: await ctx.ntFileApi.getImageUrl(picElement),
|
|
10863
|
+
url: await ctx.ntFileApi.getImageUrl(picElement.originImageUrl, picElement.md5HexStr),
|
|
10877
10864
|
file_size: fileSize
|
|
10878
10865
|
}
|
|
10879
10866
|
};
|
|
10880
10867
|
ctx.store.addFileCache({
|
|
10881
|
-
peerUid: message.peerUid,
|
|
10882
|
-
msgId: message.msgId,
|
|
10883
10868
|
msgTime: +message.msgTime,
|
|
10884
10869
|
chatType: message.chatType,
|
|
10885
|
-
elementId: element.elementId,
|
|
10886
10870
|
elementType: element.elementType,
|
|
10887
10871
|
fileName: picElement.fileName,
|
|
10888
10872
|
fileUuid: picElement.fileUuid,
|
|
10889
|
-
fileSize
|
|
10890
|
-
|
|
10873
|
+
fileSize,
|
|
10874
|
+
md5HexStr: picElement.md5HexStr
|
|
10875
|
+
});
|
|
10891
10876
|
} else if (element.videoElement) {
|
|
10892
10877
|
const { videoElement } = element;
|
|
10893
|
-
const videoUrl = await ctx.ntFileApi.getVideoUrl(
|
|
10894
|
-
chatType: message.chatType,
|
|
10895
|
-
peerUid: message.peerUid,
|
|
10896
|
-
guildId: ""
|
|
10897
|
-
}, rootMsgID ?? message.msgId, element.elementId);
|
|
10878
|
+
const videoUrl = await ctx.ntFileApi.getVideoUrl(videoElement.fileUuid, message.chatType === ChatType.Group);
|
|
10898
10879
|
const fileSize = videoElement.fileSize ?? "0";
|
|
10899
10880
|
messageSegment = {
|
|
10900
10881
|
type: OB11MessageDataType.Video,
|
|
@@ -10906,16 +10887,14 @@ async function transformIncomingSegments$1(ctx, message, rootMsgID, peer) {
|
|
|
10906
10887
|
}
|
|
10907
10888
|
};
|
|
10908
10889
|
ctx.store.addFileCache({
|
|
10909
|
-
peerUid: message.peerUid,
|
|
10910
|
-
msgId: message.msgId,
|
|
10911
10890
|
msgTime: +message.msgTime,
|
|
10912
10891
|
chatType: message.chatType,
|
|
10913
|
-
elementId: element.elementId,
|
|
10914
10892
|
elementType: element.elementType,
|
|
10915
10893
|
fileName: videoElement.fileName,
|
|
10916
10894
|
fileUuid: videoElement.fileUuid,
|
|
10917
|
-
fileSize
|
|
10918
|
-
|
|
10895
|
+
fileSize,
|
|
10896
|
+
md5HexStr: videoElement.videoMd5
|
|
10897
|
+
});
|
|
10919
10898
|
} else if (element.fileElement) {
|
|
10920
10899
|
const { fileElement } = element;
|
|
10921
10900
|
const fileSize = fileElement.fileSize ?? "0";
|
|
@@ -10930,16 +10909,14 @@ async function transformIncomingSegments$1(ctx, message, rootMsgID, peer) {
|
|
|
10930
10909
|
}
|
|
10931
10910
|
};
|
|
10932
10911
|
ctx.store.addFileCache({
|
|
10933
|
-
peerUid: message.peerUid,
|
|
10934
|
-
msgId: message.msgId,
|
|
10935
10912
|
msgTime: +message.msgTime,
|
|
10936
10913
|
chatType: message.chatType,
|
|
10937
|
-
elementId: element.elementId,
|
|
10938
10914
|
elementType: element.elementType,
|
|
10939
10915
|
fileName: fileElement.fileName,
|
|
10940
10916
|
fileUuid: fileElement.fileUuid,
|
|
10941
|
-
fileSize
|
|
10942
|
-
|
|
10917
|
+
fileSize,
|
|
10918
|
+
md5HexStr: fileElement.fileMd5
|
|
10919
|
+
});
|
|
10943
10920
|
} else if (element.pttElement) {
|
|
10944
10921
|
const { pttElement } = element;
|
|
10945
10922
|
const fileSize = pttElement.fileSize ?? "0";
|
|
@@ -10953,16 +10930,14 @@ async function transformIncomingSegments$1(ctx, message, rootMsgID, peer) {
|
|
|
10953
10930
|
}
|
|
10954
10931
|
};
|
|
10955
10932
|
ctx.store.addFileCache({
|
|
10956
|
-
peerUid: message.peerUid,
|
|
10957
|
-
msgId: message.msgId,
|
|
10958
10933
|
msgTime: +message.msgTime,
|
|
10959
10934
|
chatType: message.chatType,
|
|
10960
|
-
elementId: element.elementId,
|
|
10961
10935
|
elementType: element.elementType,
|
|
10962
10936
|
fileName: pttElement.fileName,
|
|
10963
10937
|
fileUuid: pttElement.fileUuid,
|
|
10964
|
-
fileSize
|
|
10965
|
-
|
|
10938
|
+
fileSize,
|
|
10939
|
+
md5HexStr: pttElement.md5HexStr
|
|
10940
|
+
});
|
|
10966
10941
|
} else if (element.arkElement) {
|
|
10967
10942
|
const { arkElement } = element;
|
|
10968
10943
|
try {
|
|
@@ -11081,11 +11056,11 @@ async function transformIncomingSegments$1(ctx, message, rootMsgID, peer) {
|
|
|
11081
11056
|
//#region src/onebot11/entities.ts
|
|
11082
11057
|
var OB11Entities;
|
|
11083
11058
|
(function(_OB11Entities) {
|
|
11084
|
-
async function message(ctx, msg,
|
|
11059
|
+
async function message(ctx, msg, config) {
|
|
11085
11060
|
if (!msg.senderUin || msg.senderUin === "0" || msg.msgType === 1) return;
|
|
11086
11061
|
const selfUin = selfInfo.uin;
|
|
11087
11062
|
const msgShortId = ctx.store.createMsgShortId(msg);
|
|
11088
|
-
const { segments, cqCode } = await transformIncomingSegments$1(ctx, msg
|
|
11063
|
+
const { segments, cqCode } = await transformIncomingSegments$1(ctx, msg);
|
|
11089
11064
|
const resMsg = {
|
|
11090
11065
|
self_id: Number(selfUin),
|
|
11091
11066
|
user_id: Number(msg.senderUin),
|
|
@@ -11251,16 +11226,16 @@ var OB11Entities;
|
|
|
11251
11226
|
_OB11Entities.recallEvent = recallEvent;
|
|
11252
11227
|
function friend(raw) {
|
|
11253
11228
|
return {
|
|
11254
|
-
user_id:
|
|
11255
|
-
nickname: raw.
|
|
11256
|
-
remark: raw.
|
|
11257
|
-
sex: sex(raw.
|
|
11258
|
-
birthday_year: raw.
|
|
11259
|
-
birthday_month: raw.
|
|
11260
|
-
birthday_day: raw.
|
|
11261
|
-
age: raw.
|
|
11262
|
-
qid: raw.
|
|
11263
|
-
long_nick: raw.
|
|
11229
|
+
user_id: raw.uin,
|
|
11230
|
+
nickname: raw.nick,
|
|
11231
|
+
remark: raw.remark,
|
|
11232
|
+
sex: sex(raw.sex),
|
|
11233
|
+
birthday_year: raw.birthdayYear,
|
|
11234
|
+
birthday_month: raw.birthdayMonth,
|
|
11235
|
+
birthday_day: raw.birthdayDay,
|
|
11236
|
+
age: raw.age,
|
|
11237
|
+
qid: raw.qid,
|
|
11238
|
+
long_nick: raw.longNick
|
|
11264
11239
|
};
|
|
11265
11240
|
}
|
|
11266
11241
|
_OB11Entities.friend = friend;
|
|
@@ -11389,7 +11364,7 @@ var OB11HeartbeatEvent = class extends OB11BaseMetaEvent {
|
|
|
11389
11364
|
};
|
|
11390
11365
|
//#endregion
|
|
11391
11366
|
//#region src/version.ts
|
|
11392
|
-
var version$2 = "7.12.
|
|
11367
|
+
var version$2 = "7.12.15";
|
|
11393
11368
|
//#endregion
|
|
11394
11369
|
//#region node_modules/sift/es5m/index.js
|
|
11395
11370
|
/******************************************************************************
|
|
@@ -17047,7 +17022,7 @@ var processQueue = async () => {
|
|
|
17047
17022
|
const promises = queue.splice(0, concurrency).map(async ({ filePath, resolve, reject }) => {
|
|
17048
17023
|
let handle;
|
|
17049
17024
|
try {
|
|
17050
|
-
handle = await fs$
|
|
17025
|
+
handle = await fs$5.promises.open(path$4.resolve(filePath), "r");
|
|
17051
17026
|
} catch (err) {
|
|
17052
17027
|
return reject(err);
|
|
17053
17028
|
}
|
|
@@ -17094,7 +17069,7 @@ function checkUriType(uri) {
|
|
|
17094
17069
|
if (uri.startsWith("data:")) return { type: FileUriType.DataURL };
|
|
17095
17070
|
if (uri.startsWith("http://") || uri.startsWith("https://")) return { type: FileUriType.RemoteURL };
|
|
17096
17071
|
if (uri.startsWith("file://")) return { type: FileUriType.FileURL };
|
|
17097
|
-
if (fs$
|
|
17072
|
+
if (fs$1.existsSync(uri)) return { type: FileUriType.Path };
|
|
17098
17073
|
return { type: FileUriType.Unknown };
|
|
17099
17074
|
}
|
|
17100
17075
|
async function fetchFile(url, headersInit) {
|
|
@@ -17124,7 +17099,7 @@ async function uri2local(ctx, uri, needExt) {
|
|
|
17124
17099
|
const { type } = checkUriType(uri);
|
|
17125
17100
|
if (type === FileUriType.FileURL) {
|
|
17126
17101
|
const filePath = fileURLToPath(uri);
|
|
17127
|
-
if (!fs$
|
|
17102
|
+
if (!fs$1.existsSync(filePath)) return {
|
|
17128
17103
|
success: false,
|
|
17129
17104
|
errMsg: "路径不存在",
|
|
17130
17105
|
fileName: "",
|
|
@@ -17150,12 +17125,12 @@ async function uri2local(ctx, uri, needExt) {
|
|
|
17150
17125
|
const res = await fetchFile(uri);
|
|
17151
17126
|
let fileName = randomUUID();
|
|
17152
17127
|
let filePath = path.join(TEMP_DIR, fileName);
|
|
17153
|
-
await
|
|
17128
|
+
await fsPromise.writeFile(filePath, res.data);
|
|
17154
17129
|
if (needExt) {
|
|
17155
|
-
const ext = (await
|
|
17130
|
+
const ext = (await getFileType(filePath)).ext;
|
|
17156
17131
|
fileName += `.${ext}`;
|
|
17157
17132
|
const newPath = `${filePath}.${ext}`;
|
|
17158
|
-
await
|
|
17133
|
+
await fsPromise.rename(filePath, newPath);
|
|
17159
17134
|
filePath = newPath;
|
|
17160
17135
|
}
|
|
17161
17136
|
return {
|
|
@@ -17178,11 +17153,11 @@ async function uri2local(ctx, uri, needExt) {
|
|
|
17178
17153
|
let filename = randomUUID();
|
|
17179
17154
|
let filePath = path.join(TEMP_DIR, filename);
|
|
17180
17155
|
const base64 = uri.replace(/^base64:\/\//, "");
|
|
17181
|
-
await
|
|
17156
|
+
await fsPromise.writeFile(filePath, base64, "base64");
|
|
17182
17157
|
if (needExt) {
|
|
17183
|
-
const ext = (await
|
|
17158
|
+
const ext = (await getFileType(filePath)).ext;
|
|
17184
17159
|
filename += `.${ext}`;
|
|
17185
|
-
await
|
|
17160
|
+
await fsPromise.rename(filePath, `${filePath}.${ext}`);
|
|
17186
17161
|
filePath = `${filePath}.${ext}`;
|
|
17187
17162
|
}
|
|
17188
17163
|
return {
|
|
@@ -17199,11 +17174,11 @@ async function uri2local(ctx, uri, needExt) {
|
|
|
17199
17174
|
let filename = randomUUID();
|
|
17200
17175
|
const [, _type, base64] = capture;
|
|
17201
17176
|
let filePath = path.join(TEMP_DIR, filename);
|
|
17202
|
-
await
|
|
17177
|
+
await fsPromise.writeFile(filePath, base64, "base64");
|
|
17203
17178
|
if (needExt) {
|
|
17204
|
-
const ext = (await
|
|
17179
|
+
const ext = (await getFileType(filePath)).ext;
|
|
17205
17180
|
filename += `.${ext}`;
|
|
17206
|
-
await
|
|
17181
|
+
await fsPromise.rename(filePath, `${filePath}.${ext}`);
|
|
17207
17182
|
filePath = `${filePath}.${ext}`;
|
|
17208
17183
|
}
|
|
17209
17184
|
return {
|
|
@@ -17219,13 +17194,20 @@ async function uri2local(ctx, uri, needExt) {
|
|
|
17219
17194
|
let fileCache = await ctx.store.getFileCacheById(uri);
|
|
17220
17195
|
if (!fileCache?.length) fileCache = await ctx.store.getFileCacheByName(uri);
|
|
17221
17196
|
if (fileCache?.length) {
|
|
17222
|
-
const
|
|
17223
|
-
|
|
17224
|
-
|
|
17225
|
-
|
|
17226
|
-
|
|
17227
|
-
|
|
17228
|
-
|
|
17197
|
+
const isGroup = fileCache[0].chatType === ChatType.Group;
|
|
17198
|
+
let url;
|
|
17199
|
+
if (fileCache[0].elementType === ElementType.Pic) {
|
|
17200
|
+
const originImageUrl = `/download?appid=${isGroup ? 1407 : 1406}&fileid=${fileCache[0].fileUuid}&spec=0`;
|
|
17201
|
+
url = await ctx.ntFileApi.getImageUrl(originImageUrl, fileCache[0].md5HexStr);
|
|
17202
|
+
} else if (fileCache[0].elementType === ElementType.Video) url = await ctx.ntFileApi.getVideoUrl(fileCache[0].fileUuid, isGroup);
|
|
17203
|
+
else if (fileCache[0].elementType === ElementType.Ptt) url = await ctx.ntFileApi.getPttUrl(fileCache[0].fileUuid, isGroup);
|
|
17204
|
+
if (url) return await uri2local(ctx, url, needExt);
|
|
17205
|
+
else return {
|
|
17206
|
+
success: false,
|
|
17207
|
+
errMsg: `不支持的文件类型: ${fileCache[0].elementType}`,
|
|
17208
|
+
fileName: "",
|
|
17209
|
+
path: "",
|
|
17210
|
+
isLocal: false
|
|
17229
17211
|
};
|
|
17230
17212
|
}
|
|
17231
17213
|
}
|
|
@@ -17267,13 +17249,13 @@ function getSha1HexFromBuffer(buf) {
|
|
|
17267
17249
|
}
|
|
17268
17250
|
async function getMd5HexFromFile(filePath) {
|
|
17269
17251
|
const hash = createHash("md5");
|
|
17270
|
-
const stream = fs$
|
|
17252
|
+
const stream = fs$1.createReadStream(filePath);
|
|
17271
17253
|
for await (const chunk of stream) hash.update(chunk);
|
|
17272
17254
|
return hash.digest("hex");
|
|
17273
17255
|
}
|
|
17274
17256
|
async function getSha1HexFromFile(filePath) {
|
|
17275
17257
|
const hash = createHash("sha1");
|
|
17276
|
-
const stream = fs$
|
|
17258
|
+
const stream = fs$1.createReadStream(filePath);
|
|
17277
17259
|
for await (const chunk of stream) hash.update(chunk);
|
|
17278
17260
|
return hash.digest("hex");
|
|
17279
17261
|
}
|
|
@@ -17282,13 +17264,13 @@ function getMd5BufferFromBuffer(buf) {
|
|
|
17282
17264
|
}
|
|
17283
17265
|
async function getMd5BufferFromFile(filePath) {
|
|
17284
17266
|
const hash = createHash("md5");
|
|
17285
|
-
const stream = fs$
|
|
17267
|
+
const stream = fs$1.createReadStream(filePath);
|
|
17286
17268
|
for await (const chunk of stream) hash.update(chunk);
|
|
17287
17269
|
return hash.digest();
|
|
17288
17270
|
}
|
|
17289
17271
|
async function getSha1BufferFromFile(filePath) {
|
|
17290
17272
|
const hash = createHash("sha1");
|
|
17291
|
-
const stream = fs$
|
|
17273
|
+
const stream = fs$1.createReadStream(filePath);
|
|
17292
17274
|
for await (const chunk of stream) hash.update(chunk);
|
|
17293
17275
|
return hash.digest();
|
|
17294
17276
|
}
|
|
@@ -17524,7 +17506,7 @@ async function calculateSha1StreamBytes(filePath) {
|
|
|
17524
17506
|
let bytesRead = 0;
|
|
17525
17507
|
let nextBlockBoundary = blockSize;
|
|
17526
17508
|
const byteArrayList = [];
|
|
17527
|
-
const readable = fs$
|
|
17509
|
+
const readable = fs$1.createReadStream(filePath);
|
|
17528
17510
|
for await (const chunk of readable) {
|
|
17529
17511
|
let buf;
|
|
17530
17512
|
if (tail.length > 0) {
|
|
@@ -17549,7 +17531,7 @@ async function calculateSha1StreamBytes(filePath) {
|
|
|
17549
17531
|
}
|
|
17550
17532
|
async function readAndHash10M(filePath) {
|
|
17551
17533
|
const maxSize = 10002432;
|
|
17552
|
-
const fd = await
|
|
17534
|
+
const fd = await fsPromise.open(filePath, "r");
|
|
17553
17535
|
const buffer = Buffer.allocUnsafe(maxSize);
|
|
17554
17536
|
const { bytesRead } = await fd.read(buffer, 0, maxSize, 0);
|
|
17555
17537
|
await fd.close();
|
|
@@ -17591,13 +17573,13 @@ var TriSha1 = class {
|
|
|
17591
17573
|
};
|
|
17592
17574
|
async function calculateTriSha1(filePath, fileSize) {
|
|
17593
17575
|
const hash = new TriSha1(fileSize);
|
|
17594
|
-
const stream = fs$
|
|
17576
|
+
const stream = fs$1.createReadStream(filePath);
|
|
17595
17577
|
for await (const chunk of stream) hash.update(chunk);
|
|
17596
17578
|
return hash.finalize();
|
|
17597
17579
|
}
|
|
17598
17580
|
var defaultVideoThumb = Buffer.from("/9j/4AAQSkZJRgABAQAAAQABAAD//gAXR2VuZXJhdGVkIGJ5IFNuaXBhc3Rl/9sAhAAKBwcIBwYKCAgICwoKCw4YEA4NDQ4dFRYRGCMfJSQiHyIhJis3LyYpNCkhIjBBMTQ5Oz4+PiUuRElDPEg3PT47AQoLCw4NDhwQEBw7KCIoOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozv/wAARCAF/APADAREAAhEBAxEB/8QBogAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoLEAACAQMDAgQDBQUEBAAAAX0BAgMABBEFEiExQQYTUWEHInEUMoGRoQgjQrHBFVLR8CQzYnKCCQoWFxgZGiUmJygpKjQ1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4eLj5OXm5+jp6vHy8/T19vf4+foBAAMBAQEBAQEBAQEAAAAAAAABAgMEBQYHCAkKCxEAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwDiAayNxwagBwNAC5oAM0xBmgBM0ANJoAjY0AQsaBkTGgCM0DEpAFAC0AFMBaACgAoEJTASgQlACUwCgQ4UAOFADhQA4UAOFADxQIkBqDQUGgBwagBQaBC5pgGaAELUAMLUARs1AETGgBhNAxhoASkAUALQIKYxaBBQAUwEoAQ0CEoASmAUAOoEKKAHCgBwoAeKAHigQ7NZmoZpgLmgBd1Ahd1ABupgNLUAMLUAMY0AMJoAYaAENACUCCgAoAWgAoAWgBKYCUAJQISgApgLQAooEOFACigB4oAeKBDxQAVmaiZpgGaAFzQAbqAE3UAIWpgNJoAYTQIaaAEoAQ0CEoASgBaACgBaACmAUAJQAlAgoAKYC0AKKBCigB4FADgKBDwKAHigBuazNRM0DEzTAM0AJmgAzQAhNAhpNACGmA2gQlACUCEoAKACgBaAFpgFACUAJQAUCCmAUALQIcBQA4CgB4FADgKBDhQA4UAMzWZqNzTGJQAZoATNABmgBKAEoEIaYCUCEoASgQlABQAtABQAtMBKACgAoEFABimAYoEKBQA4CgB4FADwKBDgKAFFADhQBCazNhKAEpgFACUAFACUAFAhDTAbQISgAoEJQAUALQAtMAoAKADFABigQYoAMUALimIUCgBwFAh4FADgKAHUALQAtAENZmwlACUwEoAKAEoAKACgQlMBpoEJQAUCCgBcUAFABTAXFAC4oAMUAGKBBigAxQIKYCigQ8UAOFADhQAtAC0ALQBDWZqJQMSgBKYBQAlABQISgBKYCGgQlAC0CCgBcUAFABTAUCkA7FMAxQAYoEJQAUCCmAooEOFADxQA4UAFAC0ALQBDWZqJQAlACUxhQAlABQIKAEoASmISgBcUCCgBaACgBcUAKBQAuKYC0CEoAQ0AJQISmAooEPFADhQA4UALQAtAC0AQ1maiUAFACUAJTAKAEoAKAEoAMUxBigAxQIWgAoAKAFAoAWgBaYBQIQ0ANNACUCCmIUUAOFADxQA4UALQAtABQBFWZqFACUAFACYpgFACUAFACUAFAgxTEFABQAUALQAooAWgAoAKYDTQIaaAEpiCgQ4UAOFAh4oGOFAC0ALSAKYEdZmglABQAUDDFACUwEoASgAoAKBBQIKYBQAUALQAtAC0AJQAhpgNJoENJoATNMQCgQ8UCHigB4oAWgYtABQAUAMrM0CgAoAKADFACUxiUAJQAlAgoAKYgoAKACgYtAC0AFAhDTAQmgBhNAhpNACZpiFBoEPFAEi0CHigB1ABQAUDEoAbWZoFABQAtABTAQ0ANNAxDQAlAhaAEpiCgAoGFAC0AFABmgBCaYhpNADCaBDSaBBmgABpiJFNAEimgB4NADqAFzQAlACE0AJWZoFAC0AFAC0wEIoAaaAG0AJQAUCCgApjCgAoAKADNABmgBpNMQ0mgBpNAhhNAgzQAoNADwaAHqaAJAaBDgaYC5oATNACZoAWszQKACgBaBDqYCGgBpoAYaBiUCCgBKYBQMKACgAoAM0AITQIaTQA0mmA0mgQ3NAhKAHCgBwNADwaAHg0AOBpiFzQAZoATNAD6zNAoAKAFoEOpgBoAaaAGGmAw0AJmgAzQMM0AGaADNABmgBM0AITQIaTQAhNMQw0AJQIKAFFADhQA4GgBwNADs0xC5oAM0CDNAEtZmoUCCgBaAHUwCgBppgRtQAw0ANzQAZoAM0AGaADNABmgBKAEoAQ0ANNMQhoEJQAlMBaQDgaAFBoAcDTAdmgQuaADNAgzQBPWZqFAgoAWgBaYC0CGmmBG1AyM0ANJoATNACZoAXNABmgAzQAUAJQAhoAQ0xDTQISmAUALQAUgHA0AKDTAdmgQuaBBQAtAFiszQKACgBaAFFMAoEIaYEbUDI2oAYaAEoASgAzQAuaACgAoAKAENMQ00AJTEFAhKACgAoAXNACg0AOBoAWgQtAC0AWazNAoAKACgBaYBQIQ0AMNMYw0AMIoAbQAlMAoAKACgAzSAKYhKAENACUxBQIKACgBKACgBaAHCgQ4UALQAUAWqzNAoAKACgApgFACGgQ00xjTQAwigBCKAG4pgJQAlABQAUCCgBKACgBKYgoEFABQISgAoAWgBRQA4UALQAUCLdZmoUAFABQAlMAoASgBDQA00wENACYoATFMBpFADSKAEoEJQAUAFABQAlMQtAgoASgQUAJQAUAKKAHCgBaBBQBbrM1CgAoAKACmAUAJQAlADaYBQAlACYpgIRQA0igBpFAhtABQAUAFMAoEFABQIKAEoASgQUALQAooAWgQUAW81mbC0CCgApgFACUAIaAEpgJQAUAFABQAhFMBpFADSKAGkUCExQAYoAMUAGKADFMQYoAMUCExSATFABQIKYBQAtABQIt5qDYM0ALmgQtIApgIaAENADaACmAlAC0ALQAUwGkUANIoAaRQAmKBBigAxQAYoAMUAGKBBigBMUAJigQmKAExTAKBC0AFAFnNQaig0AKDQAtAgoASgBDQAlMBKACgAFADhQAtMBCKAGkUAIRQAmKADFABigQmKADFACYoAXFABigQmKAExQAmKBCYpgJigAoAnzUGgZoAcDQAuaBC0AJQAhoASmAlABQAtADhQAtMAoATFACEUAJigAxQAYoATFAhMUAFABQAuKADFABigBpWgBCKBCYpgJigB+ag0DNADgaBDgaAFzQITNACUAJTAKACgBRQAopgOoAWgBKAEoAKACgAoASgBpoEJQAooAWgBaBhigBMUCEIoAQigBMUAJSLCgBQaBDgaQC5oEFACUwCgBKACmAtADhQA4UALQAUAJQAUAJQAUAJQAhoENoAWgBRQAooGLQAUAGKAGkUAIRQIZSKEoGKKBDhQAUCCgAoAKBBQAUwFoGKKAHCgBaACgAoASgAoASgBCaAEoEJmgAoAUGgBQaAHZoGFABQAUANoAjpDEoAWgBaAFoEFACUALQAUCCmAUAOFAxRQAtAC0AJQAUAJQAmaBDSaAEzQAmaYBmgBQaAHA0gFzQAuaBhmgAzQAlAEdIYUALQAtAgoAKAEoEFAC0AFMAoAUUDFFAC0ALQAUAJQAhoENNACE0wEoATNABmgBc0ALmgBc0gDNAC5oATNABmgBKRQlACigB1AgoASgQlABTAWgBKACgBaBi0ALQAZoAM0AFACGgQ00wENACUAJQAUCFzQMM0ALmgAzQAZoAM0AGaQC0igoAUUALQIWgBDQISmAUAFACUAFABQAuaBi5oAM0AGaBBmgBKAEpgIaAG0AJQAUCFoAM0DDNAC5oATNABmgAzQBJUlBQAooAWgQtACGmIaaACgAoASgBKACgBc0DCgQUAGaADNABTASgBDQAlACUAFAgoAKBhQAUAFABQAlAE1SUFAxRQIWgQtMBDQIQ0AJQAlAhKBiUAFABmgBc0AGaADNABTAKACgBKAEoASgQlABQAUAFAC0AFACUAFAE1SaBQAUCHCgQtMBKBCUAJQISgBDQA00DEzQAuaADNMBc0AGaADNABQAUAJQAlABQISgAoAKACgBaACgBKAEoAnqTQSgBRQIcKBC0xCUAJQISgBKAENADDQAmaYwzQAuaADNAC0AFABQAUAFAhKACgBKACgAoAWgAoELQAlAxKAJqk0EoAWgQooELTEFADaBCUABoENNMY00ANNAwzQAZoAXNAC0AFAC0CFoASgAoASgBKACgAoAWgQtABQAUANNAyWpNAoAKBCimIWgQUCEoASmIQ0ANNADTQMaaAEoGLmgAzQAtADhQIWgBaACgQhoASgYlACUALQIWgBaACgBKAENAyWpNBKYBQIcKBC0CEoEJTAKBCUANNADDQMQ0ANoGFAC5oAUGgBwNAhRQIWgBaAENACGgBtAwoAKAFzQIXNABmgAoAQ0DJKRoJQAtAhRQSLQIKYCUCCgBDQA00AMNAxpoGNoAM0AGaAFBoAcDQIcKBDqACgBDQAhoAQ0DEoAKADNAC5oEGaBhmgAoAkpGgUCCgQooELQIKYhKACgBKAGmgBpoGMNAxDQAlAwzQIUUAOFAhwoAcKBC0AJQAhoGNNACUAFABQAZoAXNABQAUAS0ixKACgQoNAhaYgoEFACUABoAaaAGmgYw0DENAxtABQAooEOFADhQIcKAFoASgBDQAhoGJQAUAFACUALQIKBi0CJDSLEoATNAhc0CHZpiCgQUAJQIKBjTQAhoGNNAxpoATFABigBQKAHCgBwoAWgAoAKACgBKAEoASgAoASgBaAAUAOoEONIoaTQAZoAUGmIUGgQtAgzQISgAoAQ0DGmgYlAxKACgAxQAtACigBRQAtAxaACgAoATFABigBCKAG0CEoAWgBRTAUUAf//Z", "base64");
|
|
17599
17581
|
async function getVideoInfo(filePath) {
|
|
17600
|
-
const size = fs$
|
|
17582
|
+
const size = fs$1.statSync(filePath).size;
|
|
17601
17583
|
return new Promise((resolve, reject) => {
|
|
17602
17584
|
(0, import_fluent_ffmpeg.default)(filePath).ffprobe((err, metadata) => {
|
|
17603
17585
|
if (err) reject(err);
|
|
@@ -17674,7 +17656,7 @@ function convert(ctx, input, options, outputPath) {
|
|
|
17674
17656
|
});
|
|
17675
17657
|
}
|
|
17676
17658
|
async function encodeSilk(ctx, filePath) {
|
|
17677
|
-
const file = await
|
|
17659
|
+
const file = await fsPromise.readFile(filePath);
|
|
17678
17660
|
if (!isSilk(file)) {
|
|
17679
17661
|
ctx.logger.info(`语音文件${filePath}需要转换成silk`);
|
|
17680
17662
|
let result;
|
|
@@ -17693,7 +17675,7 @@ async function encodeSilk(ctx, filePath) {
|
|
|
17693
17675
|
"-f s16le"
|
|
17694
17676
|
] }), 24e3);
|
|
17695
17677
|
const pttPath = path.join(TEMP_DIR, randomUUID());
|
|
17696
|
-
await
|
|
17678
|
+
await fsPromise.writeFile(pttPath, result.data);
|
|
17697
17679
|
ctx.logger.info(`语音文件${filePath}转换成功!`, pttPath, `时长:`, result.duration);
|
|
17698
17680
|
return {
|
|
17699
17681
|
converted: true,
|
|
@@ -17716,11 +17698,11 @@ async function encodeSilk(ctx, filePath) {
|
|
|
17716
17698
|
}
|
|
17717
17699
|
}
|
|
17718
17700
|
async function decodeSilk(ctx, inputFilePath, outFormat) {
|
|
17719
|
-
const { data } = await decode(await
|
|
17701
|
+
const { data } = await decode(await fsPromise.readFile(inputFilePath), 24e3);
|
|
17720
17702
|
const tmpPath = path.join(TEMP_DIR, path.basename(inputFilePath));
|
|
17721
17703
|
const outFilePath = tmpPath + `.${outFormat}`;
|
|
17722
17704
|
const pcmFilePath = tmpPath + ".pcm";
|
|
17723
|
-
await
|
|
17705
|
+
await fsPromise.writeFile(pcmFilePath, data);
|
|
17724
17706
|
return convert(ctx, pcmFilePath, { input: [
|
|
17725
17707
|
"-f s16le",
|
|
17726
17708
|
"-ar 24000",
|
|
@@ -17776,16 +17758,17 @@ var SendElement;
|
|
|
17776
17758
|
const fileSize = (await stat(picPath)).size;
|
|
17777
17759
|
if (fileSize === 0) throw new Error(`文件异常,大小为 0: ${picPath}`);
|
|
17778
17760
|
const { md5, fileName, path } = await ctx.ntFileApi.uploadFile(picPath, ElementType.Pic, subType);
|
|
17779
|
-
const
|
|
17761
|
+
const fileType = await getFileType(picPath);
|
|
17762
|
+
const size = await getImageSize(picPath);
|
|
17780
17763
|
const picElement = {
|
|
17781
17764
|
md5HexStr: md5,
|
|
17782
17765
|
fileSize: fileSize.toString(),
|
|
17783
|
-
picWidth:
|
|
17784
|
-
picHeight:
|
|
17766
|
+
picWidth: size.width,
|
|
17767
|
+
picHeight: size.height,
|
|
17785
17768
|
fileName,
|
|
17786
17769
|
sourcePath: path,
|
|
17787
17770
|
original: true,
|
|
17788
|
-
picType:
|
|
17771
|
+
picType: fileType.ext === "gif" ? PicType.GIF : PicType.JPEG,
|
|
17789
17772
|
picSubType: subType,
|
|
17790
17773
|
fileUuid: "",
|
|
17791
17774
|
fileSubId: "",
|
|
@@ -18066,6 +18049,9 @@ function uint32ToIPV4Addr(value) {
|
|
|
18066
18049
|
function sleep(ms = 0) {
|
|
18067
18050
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
18068
18051
|
}
|
|
18052
|
+
function isHttpUrl(str) {
|
|
18053
|
+
return /^https?:\/\/.+/.test(str);
|
|
18054
|
+
}
|
|
18069
18055
|
//#endregion
|
|
18070
18056
|
//#region src/common/utils/sign.ts
|
|
18071
18057
|
var MusicSign = class {
|
|
@@ -18198,7 +18184,7 @@ async function createSendElements(ctx, messageData, peer, ignoreTypes = []) {
|
|
|
18198
18184
|
case OB11MessageDataType.Contact:
|
|
18199
18185
|
{
|
|
18200
18186
|
const { type, id } = segment.data;
|
|
18201
|
-
const data = type === "qq" ? ctx.ntFriendApi.
|
|
18187
|
+
const data = type === "qq" ? ctx.ntFriendApi.getFriendRecommendContactArk(+id) : ctx.ntGroupApi.getGroupRecommendContact(id);
|
|
18202
18188
|
sendElements.push(SendElement.ark(await data));
|
|
18203
18189
|
}
|
|
18204
18190
|
break;
|
|
@@ -18314,7 +18300,7 @@ async function createPeer(ctx, payload, mode = CreatePeerMode.Normal) {
|
|
|
18314
18300
|
if ((mode === CreatePeerMode.Private || mode === CreatePeerMode.Normal) && payload.user_id) {
|
|
18315
18301
|
const uid = await ctx.ntUserApi.getUidByUin(payload.user_id.toString(), payload.group_id?.toString());
|
|
18316
18302
|
if (!uid) throw new Error("无法获取用户信息");
|
|
18317
|
-
if (!await ctx.ntFriendApi.
|
|
18303
|
+
if (!await ctx.ntFriendApi.isFriend(uid)) {
|
|
18318
18304
|
if ((await ctx.ntMsgApi.getTempChatInfo(ChatType.TempC2CFromGroup, uid)).tmpChatInfo.groupCode) return {
|
|
18319
18305
|
chatType: ChatType.TempC2CFromGroup,
|
|
18320
18306
|
peerUid: uid,
|
|
@@ -18391,12 +18377,8 @@ async function handleMsg(ctx, msg, quickAction) {
|
|
|
18391
18377
|
}
|
|
18392
18378
|
async function handleFriendRequest$1(ctx, request, quickAction) {
|
|
18393
18379
|
if (!isNullable(quickAction.approve)) {
|
|
18394
|
-
|
|
18395
|
-
if (
|
|
18396
|
-
const uid = data[0];
|
|
18397
|
-
const reqTime = data[1];
|
|
18398
|
-
await ctx.ntFriendApi.handleFriendRequest(uid, reqTime, quickAction.approve).catch((e) => ctx.logger.error(e));
|
|
18399
|
-
if (!isNullable(quickAction.remark)) ctx.ntFriendApi.setBuddyRemark(uid, quickAction.remark).catch((e) => ctx.logger.error(e));
|
|
18380
|
+
await ctx.ntFriendApi.approvalFriendRequest(request.flag, quickAction.approve).catch((e) => ctx.logger.error(e));
|
|
18381
|
+
if (!isNullable(quickAction.remark)) await ctx.ntFriendApi.setFriendRemark(request.flag, quickAction.remark).catch((e) => ctx.logger.error(e));
|
|
18400
18382
|
}
|
|
18401
18383
|
}
|
|
18402
18384
|
async function handleGroupRequest(ctx, request, quickAction) {
|
|
@@ -21234,10 +21216,31 @@ var CloseEvent = globalThis.CloseEvent ?? class extends Event {
|
|
|
21234
21216
|
var generateConnectionSymbol = () => Symbol("connection");
|
|
21235
21217
|
var CONNECTION_SYMBOL_KEY = Symbol("CONNECTION_SYMBOL_KEY");
|
|
21236
21218
|
var WAIT_FOR_WEBSOCKET_SYMBOL = Symbol("WAIT_FOR_WEBSOCKET_SYMBOL");
|
|
21237
|
-
var
|
|
21238
|
-
|
|
21239
|
-
|
|
21240
|
-
|
|
21219
|
+
var responseHeadersToSkip = new Set([
|
|
21220
|
+
"connection",
|
|
21221
|
+
"content-length",
|
|
21222
|
+
"keep-alive",
|
|
21223
|
+
"proxy-authenticate",
|
|
21224
|
+
"proxy-authorization",
|
|
21225
|
+
"te",
|
|
21226
|
+
"trailer",
|
|
21227
|
+
"transfer-encoding",
|
|
21228
|
+
"upgrade",
|
|
21229
|
+
"sec-websocket-accept",
|
|
21230
|
+
"sec-websocket-extensions",
|
|
21231
|
+
"sec-websocket-protocol"
|
|
21232
|
+
]);
|
|
21233
|
+
var appendResponseHeaders = (headers, responseHeaders) => {
|
|
21234
|
+
if (!responseHeaders) return;
|
|
21235
|
+
responseHeaders.forEach((value, key) => {
|
|
21236
|
+
if (responseHeadersToSkip.has(key.toLowerCase())) return;
|
|
21237
|
+
headers.push(`${key}: ${value}`);
|
|
21238
|
+
});
|
|
21239
|
+
};
|
|
21240
|
+
var rejectUpgradeRequest = (socket, status, responseHeaders) => {
|
|
21241
|
+
const responseLines = ["Connection: close", "Content-Length: 0"];
|
|
21242
|
+
appendResponseHeaders(responseLines, responseHeaders);
|
|
21243
|
+
socket.end(`HTTP/1.1 ${status.toString()} ${STATUS_CODES[status] ?? ""}\r\n${responseLines.join("\r\n")}\r\n\r
|
|
21241
21244
|
`);
|
|
21242
21245
|
};
|
|
21243
21246
|
var createUpgradeRequest = (request) => {
|
|
@@ -21278,9 +21281,13 @@ var setupWebSocket = (options) => {
|
|
|
21278
21281
|
[WAIT_FOR_WEBSOCKET_SYMBOL]: waitForWebSocket
|
|
21279
21282
|
};
|
|
21280
21283
|
let status = 400;
|
|
21284
|
+
let responseHeaders;
|
|
21281
21285
|
try {
|
|
21282
21286
|
const response = await fetchCallback(createUpgradeRequest(request), env);
|
|
21283
|
-
if (response instanceof Response)
|
|
21287
|
+
if (response instanceof Response) {
|
|
21288
|
+
status = response.status;
|
|
21289
|
+
responseHeaders = response.headers;
|
|
21290
|
+
}
|
|
21284
21291
|
} catch {
|
|
21285
21292
|
if (server.listenerCount("upgrade") === 1) rejectUpgradeRequest(socket, 500);
|
|
21286
21293
|
return;
|
|
@@ -21288,12 +21295,20 @@ var setupWebSocket = (options) => {
|
|
|
21288
21295
|
const waiter = waiterMap.get(request);
|
|
21289
21296
|
if (!waiter || waiter.connectionSymbol !== env[CONNECTION_SYMBOL_KEY]) {
|
|
21290
21297
|
waiterMap.delete(request);
|
|
21291
|
-
if (server.listenerCount("upgrade") === 1) rejectUpgradeRequest(socket, status);
|
|
21298
|
+
if (server.listenerCount("upgrade") === 1) rejectUpgradeRequest(socket, status, responseHeaders);
|
|
21292
21299
|
return;
|
|
21293
21300
|
}
|
|
21294
|
-
|
|
21295
|
-
|
|
21296
|
-
}
|
|
21301
|
+
const addResponseHeaders = (headers) => {
|
|
21302
|
+
appendResponseHeaders(headers, responseHeaders);
|
|
21303
|
+
};
|
|
21304
|
+
wss.on("headers", addResponseHeaders);
|
|
21305
|
+
try {
|
|
21306
|
+
wss.handleUpgrade(request, socket, head, (ws) => {
|
|
21307
|
+
wss.emit("connection", ws, request);
|
|
21308
|
+
});
|
|
21309
|
+
} finally {
|
|
21310
|
+
wss.off("headers", addResponseHeaders);
|
|
21311
|
+
}
|
|
21297
21312
|
});
|
|
21298
21313
|
server.on("close", () => {
|
|
21299
21314
|
wss.close();
|
|
@@ -21773,7 +21788,7 @@ var GetMsg = class extends BaseAction {
|
|
|
21773
21788
|
status = "deleted";
|
|
21774
21789
|
}
|
|
21775
21790
|
} else msg = res.msgList[0];
|
|
21776
|
-
const retMsg = await OB11Entities.message(this.ctx, msg,
|
|
21791
|
+
const retMsg = await OB11Entities.message(this.ctx, msg, config);
|
|
21777
21792
|
if (!retMsg) throw new Error("消息为空");
|
|
21778
21793
|
retMsg.real_id = retMsg.message_seq;
|
|
21779
21794
|
retMsg.status = status;
|
|
@@ -21802,8 +21817,8 @@ var GetLoginInfo$1 = class extends BaseAction {
|
|
|
21802
21817
|
var GetFriendList$1 = class extends BaseAction {
|
|
21803
21818
|
actionName = ActionName.GetFriendList;
|
|
21804
21819
|
async _handle() {
|
|
21805
|
-
const
|
|
21806
|
-
return OB11Entities.friends(
|
|
21820
|
+
const result = await this.ctx.ntFriendApi.getFriendList(true);
|
|
21821
|
+
return OB11Entities.friends(result.friends);
|
|
21807
21822
|
}
|
|
21808
21823
|
};
|
|
21809
21824
|
//#endregion
|
|
@@ -23669,6 +23684,168 @@ var Oidb;
|
|
|
23669
23684
|
allFileCount: ProtoField(7, "uint32"),
|
|
23670
23685
|
nextIndex: ProtoField(13, "uint32")
|
|
23671
23686
|
}) });
|
|
23687
|
+
_Oidb.ImageOcrReq = ProtoMessage.of({
|
|
23688
|
+
version: ProtoField(1, "uint32"),
|
|
23689
|
+
client: ProtoField(2, "uint32"),
|
|
23690
|
+
entrance: ProtoField(3, "uint32"),
|
|
23691
|
+
ocrReqBody: ProtoField(10, {
|
|
23692
|
+
imageUrl: ProtoField(1, "string"),
|
|
23693
|
+
languageType: ProtoField(2, "uint32"),
|
|
23694
|
+
scene: ProtoField(3, "uint32"),
|
|
23695
|
+
originMd5: ProtoField(10, "string"),
|
|
23696
|
+
afterCompressMd5: ProtoField(11, "string"),
|
|
23697
|
+
afterCompressFileSize: ProtoField(12, "string"),
|
|
23698
|
+
afterCompressWeight: ProtoField(13, "string"),
|
|
23699
|
+
afterCompressHeight: ProtoField(14, "string"),
|
|
23700
|
+
isCut: ProtoField(15, "bool")
|
|
23701
|
+
})
|
|
23702
|
+
});
|
|
23703
|
+
_Oidb.ImageOcrResp = ProtoMessage.of({
|
|
23704
|
+
retCode: ProtoField(1, "int32", "optional"),
|
|
23705
|
+
errMsg: ProtoField(2, "string"),
|
|
23706
|
+
wording: ProtoField(3, "string", "optional"),
|
|
23707
|
+
ocrRspBody: ProtoField(10, {
|
|
23708
|
+
textDetections: ProtoField(1, {
|
|
23709
|
+
detectedText: ProtoField(1, "string"),
|
|
23710
|
+
confidence: ProtoField(2, "uint32"),
|
|
23711
|
+
polygon: ProtoField(3, { coordinates: ProtoField(1, {
|
|
23712
|
+
x: ProtoField(1, "int32"),
|
|
23713
|
+
y: ProtoField(2, "int32")
|
|
23714
|
+
}, "repeated") }),
|
|
23715
|
+
advancedInfo: ProtoField(4, "string")
|
|
23716
|
+
}, "repeated"),
|
|
23717
|
+
language: ProtoField(2, "string"),
|
|
23718
|
+
requestId: ProtoField(3, "string"),
|
|
23719
|
+
ocrLanguageList: ProtoField(101, "string", "repeated"),
|
|
23720
|
+
dstTranslateLanguageList: ProtoField(102, "string", "repeated"),
|
|
23721
|
+
languageList: ProtoField(103, {
|
|
23722
|
+
languageCode: ProtoField(1, "string"),
|
|
23723
|
+
languageDesc: ProtoField(2, "string")
|
|
23724
|
+
}, "repeated"),
|
|
23725
|
+
afterCompressWeight: ProtoField(111, "uint32"),
|
|
23726
|
+
afterCompressHeight: ProtoField(112, "uint32")
|
|
23727
|
+
})
|
|
23728
|
+
});
|
|
23729
|
+
_Oidb.SetFriendRequestReq = ProtoMessage.of({
|
|
23730
|
+
accept: ProtoField(1, "uint32"),
|
|
23731
|
+
targetUid: ProtoField(2, "string")
|
|
23732
|
+
});
|
|
23733
|
+
_Oidb.SetFilteredFriendRequestReq = ProtoMessage.of({
|
|
23734
|
+
selfUid: ProtoField(1, "string"),
|
|
23735
|
+
requestUid: ProtoField(2, "string")
|
|
23736
|
+
});
|
|
23737
|
+
_Oidb.IncPullReq = ProtoMessage.of({
|
|
23738
|
+
reqCount: ProtoField(2, "uint32"),
|
|
23739
|
+
time: ProtoField(3, "uint32"),
|
|
23740
|
+
localSeq: ProtoField(4, "uint32"),
|
|
23741
|
+
cookie: ProtoField(5, "bytes", "optional"),
|
|
23742
|
+
flag: ProtoField(6, "int32"),
|
|
23743
|
+
proxySeq: ProtoField(7, "uint32"),
|
|
23744
|
+
requestBiz: ProtoField(10001, {
|
|
23745
|
+
bizType: ProtoField(1, "int32"),
|
|
23746
|
+
bizData: ProtoField(2, { extBusi: ProtoField(1, "int32", "repeated") })
|
|
23747
|
+
}, "repeated"),
|
|
23748
|
+
extSnsFlagKey: ProtoField(10002, "uint32", "repeated"),
|
|
23749
|
+
extPrivateIdListKey: ProtoField(10003, "uint32", "repeated")
|
|
23750
|
+
});
|
|
23751
|
+
_Oidb.IncPullResp = ProtoMessage.of({
|
|
23752
|
+
seq: ProtoField(1, "uint32"),
|
|
23753
|
+
cookie: ProtoField(2, "bytes", "optional"),
|
|
23754
|
+
isEnd: ProtoField(3, "bool"),
|
|
23755
|
+
time: ProtoField(6, "uint32"),
|
|
23756
|
+
selfUin: ProtoField(7, "uint32"),
|
|
23757
|
+
smallSeq: ProtoField(8, "uint32"),
|
|
23758
|
+
friendList: ProtoField(101, {
|
|
23759
|
+
uid: ProtoField(1, "string"),
|
|
23760
|
+
categoryId: ProtoField(2, "int32"),
|
|
23761
|
+
uin: ProtoField(3, "uint32"),
|
|
23762
|
+
subBiz: ProtoField(10001, ["int32", {
|
|
23763
|
+
numData: ProtoField(1, ["int32", "int32"]),
|
|
23764
|
+
data: ProtoField(2, ["int32", "bytes"])
|
|
23765
|
+
}])
|
|
23766
|
+
}, "repeated"),
|
|
23767
|
+
category: ProtoField(102, {
|
|
23768
|
+
categoryId: ProtoField(1, "int32"),
|
|
23769
|
+
categoryName: ProtoField(2, "string"),
|
|
23770
|
+
categoryMemberCount: ProtoField(3, "int32"),
|
|
23771
|
+
categorySortId: ProtoField(4, "int32")
|
|
23772
|
+
}, "repeated")
|
|
23773
|
+
});
|
|
23774
|
+
_Oidb.FetchPinsResp = ProtoMessage.of({
|
|
23775
|
+
friends: ProtoField(1, { uid: ProtoField(1, "string") }, "repeated"),
|
|
23776
|
+
groups: ProtoField(3, { groupCode: ProtoField(1, "uint32") }, "repeated")
|
|
23777
|
+
});
|
|
23778
|
+
_Oidb.GetFriendRecommendContactArkReq = ProtoMessage.of({
|
|
23779
|
+
uin: ProtoField(1, "uint32"),
|
|
23780
|
+
phoneNumber: ProtoField(2, "string"),
|
|
23781
|
+
jumpUrl: ProtoField(3, "string")
|
|
23782
|
+
});
|
|
23783
|
+
_Oidb.GetFriendRecommendContactArkResp = ProtoMessage.of({ ark: ProtoField(1, "string") });
|
|
23784
|
+
_Oidb.SetFriendRemarkReq = ProtoMessage.of({
|
|
23785
|
+
uid: ProtoField(1, "string"),
|
|
23786
|
+
remark: ProtoField(2, "string")
|
|
23787
|
+
});
|
|
23788
|
+
_Oidb.DeleteFriendReq = ProtoMessage.of({ field1: ProtoField(1, {
|
|
23789
|
+
targetUid: ProtoField(1, "string"),
|
|
23790
|
+
field2: ProtoField(2, {
|
|
23791
|
+
field1: ProtoField(1, "uint32"),
|
|
23792
|
+
field2: ProtoField(2, "uint32"),
|
|
23793
|
+
field3: ProtoField(3, {
|
|
23794
|
+
field1: ProtoField(1, "uint32"),
|
|
23795
|
+
field2: ProtoField(2, "uint32"),
|
|
23796
|
+
field3: ProtoField(3, "uint32")
|
|
23797
|
+
})
|
|
23798
|
+
}),
|
|
23799
|
+
block: ProtoField(3, "bool"),
|
|
23800
|
+
bothDelete: ProtoField(4, "bool")
|
|
23801
|
+
}) });
|
|
23802
|
+
_Oidb.SetFriendCategoryReq = ProtoMessage.of({
|
|
23803
|
+
uid: ProtoField(1, "string"),
|
|
23804
|
+
categoryId: ProtoField(2, "uint32")
|
|
23805
|
+
});
|
|
23806
|
+
_Oidb.FetchFriendRequestsReq = ProtoMessage.of({
|
|
23807
|
+
version: ProtoField(1, "int32"),
|
|
23808
|
+
type: ProtoField(3, "int32"),
|
|
23809
|
+
selfUid: ProtoField(4, "string"),
|
|
23810
|
+
startIndex: ProtoField(5, "int32"),
|
|
23811
|
+
reqNum: ProtoField(6, "int32"),
|
|
23812
|
+
getFlag: ProtoField(8, "int32"),
|
|
23813
|
+
startTime: ProtoField(9, "int32"),
|
|
23814
|
+
needCommFriend: ProtoField(12, "int32"),
|
|
23815
|
+
field22: ProtoField(22, "int32")
|
|
23816
|
+
});
|
|
23817
|
+
_Oidb.FetchFriendRequestsResp = ProtoMessage.of({
|
|
23818
|
+
field1: ProtoField(1, "int32"),
|
|
23819
|
+
field2: ProtoField(2, "int32"),
|
|
23820
|
+
info: ProtoField(3, {
|
|
23821
|
+
field2: ProtoField(2, "int32"),
|
|
23822
|
+
count: ProtoField(3, "int32"),
|
|
23823
|
+
requests: ProtoField(7, {
|
|
23824
|
+
selfUid: ProtoField(1, "string"),
|
|
23825
|
+
friendUid: ProtoField(2, "string"),
|
|
23826
|
+
state: ProtoField(3, "int32"),
|
|
23827
|
+
timestamp: ProtoField(4, "uint32"),
|
|
23828
|
+
comment: ProtoField(5, "string"),
|
|
23829
|
+
source: ProtoField(6, "string"),
|
|
23830
|
+
sourceId: ProtoField(7, "int32"),
|
|
23831
|
+
subSourceId: ProtoField(8, "int32"),
|
|
23832
|
+
isInitiator: ProtoField(20, "bool")
|
|
23833
|
+
}, "repeated")
|
|
23834
|
+
})
|
|
23835
|
+
});
|
|
23836
|
+
_Oidb.FetchFilteredFriendRequestsReq = ProtoMessage.of({
|
|
23837
|
+
field1: ProtoField(1, "int32"),
|
|
23838
|
+
field2: ProtoField(2, { count: ProtoField(1, "int32") })
|
|
23839
|
+
});
|
|
23840
|
+
_Oidb.FetchFilteredFriendRequestsResp = ProtoMessage.of({ info: ProtoField(2, { requests: ProtoField(1, {
|
|
23841
|
+
sourceUid: ProtoField(1, "string"),
|
|
23842
|
+
sourceNickname: ProtoField(2, "string"),
|
|
23843
|
+
comment: ProtoField(5, "string"),
|
|
23844
|
+
source: ProtoField(6, "string"),
|
|
23845
|
+
warningInfo: ProtoField(7, "string"),
|
|
23846
|
+
timestamp: ProtoField(8, "uint32"),
|
|
23847
|
+
groupCode: ProtoField(9, "uint32")
|
|
23848
|
+
}, "repeated") }) });
|
|
23672
23849
|
})(Oidb || (Oidb = {}));
|
|
23673
23850
|
//#endregion
|
|
23674
23851
|
//#region src/ntqqapi/proto/msg.ts
|
|
@@ -23956,53 +24133,10 @@ var MessageEncoder$1 = class MessageEncoder$1 {
|
|
|
23956
24133
|
this.content = void 0;
|
|
23957
24134
|
this.preview = "";
|
|
23958
24135
|
}
|
|
23959
|
-
async packImage(
|
|
23960
|
-
const imageSize = await this.ctx.ntFileApi.getImageSize(data.filePath);
|
|
24136
|
+
async packImage(msgInfo) {
|
|
23961
24137
|
return { commonElem: {
|
|
23962
24138
|
serviceType: 48,
|
|
23963
|
-
pbElem: Media.MsgInfo.encode(
|
|
23964
|
-
msgInfoBody: [{
|
|
23965
|
-
index: {
|
|
23966
|
-
info: {
|
|
23967
|
-
fileSize: +data.commonFileInfo.fileSize,
|
|
23968
|
-
md5HexStr: data.commonFileInfo.md5,
|
|
23969
|
-
sha1HexStr: data.commonFileInfo.sha,
|
|
23970
|
-
fileName: data.commonFileInfo.fileName,
|
|
23971
|
-
fileType: {
|
|
23972
|
-
type: 1,
|
|
23973
|
-
picFormat: imageSize.type === "gif" ? 2e3 : 1e3
|
|
23974
|
-
},
|
|
23975
|
-
width: imageSize.width,
|
|
23976
|
-
height: imageSize.height,
|
|
23977
|
-
time: 0,
|
|
23978
|
-
original: 1
|
|
23979
|
-
},
|
|
23980
|
-
fileUuid: data.fileId,
|
|
23981
|
-
storeID: 1,
|
|
23982
|
-
expire: this.isGroup ? 2678400 : 15768e4
|
|
23983
|
-
},
|
|
23984
|
-
pic: {
|
|
23985
|
-
urlPath: `/download?appid=${this.isGroup ? 1407 : 1406}&fileid=${data.fileId}`,
|
|
23986
|
-
ext: {
|
|
23987
|
-
originalParam: "&spec=0",
|
|
23988
|
-
bigParam: "&spec=720",
|
|
23989
|
-
thumbParam: "&spec=198"
|
|
23990
|
-
},
|
|
23991
|
-
domain: "multimedia.nt.qq.com.cn"
|
|
23992
|
-
},
|
|
23993
|
-
fileExist: true
|
|
23994
|
-
}],
|
|
23995
|
-
extBizInfo: {
|
|
23996
|
-
pic: {
|
|
23997
|
-
bizType: 0,
|
|
23998
|
-
summary: "",
|
|
23999
|
-
fromScene: this.isGroup ? 2 : 1,
|
|
24000
|
-
toScene: this.isGroup ? 2 : 1,
|
|
24001
|
-
oldFileId: this.isGroup ? 574859779 : void 0
|
|
24002
|
-
},
|
|
24003
|
-
busiType
|
|
24004
|
-
}
|
|
24005
|
-
}),
|
|
24139
|
+
pbElem: Media.MsgInfo.encode(msgInfo),
|
|
24006
24140
|
businessType: this.isGroup ? 20 : 10
|
|
24007
24141
|
} };
|
|
24008
24142
|
}
|
|
@@ -24084,11 +24218,11 @@ var MessageEncoder$1 = class MessageEncoder$1 {
|
|
|
24084
24218
|
const busiType = Number(segment.data.subType) || 0;
|
|
24085
24219
|
const { path: picPath } = await handleOb11RichMedia(this.ctx, segment, this.deleteAfterSentFiles);
|
|
24086
24220
|
if ((await stat(picPath)).size === 0) throw new Error(`文件异常,大小为 0: ${picPath}`);
|
|
24087
|
-
|
|
24088
|
-
|
|
24089
|
-
this.
|
|
24221
|
+
let data;
|
|
24222
|
+
if (this.isGroup) data = await this.ctx.ntFileApi.uploadGroupImage(this.peer.peerUid, picPath);
|
|
24223
|
+
else data = await this.ctx.ntFileApi.uploadC2CImage(this.peer.peerUid, picPath);
|
|
24224
|
+
this.children.push(await this.packImage(data.msgInfo));
|
|
24090
24225
|
this.preview += busiType === 1 ? "[动画表情]" : "[图片]";
|
|
24091
|
-
this.deleteAfterSentFiles.push(path);
|
|
24092
24226
|
} else if (type === OB11MessageDataType.Forward) {
|
|
24093
24227
|
const forwardData = data;
|
|
24094
24228
|
if (forwardData.id) this.children.push(this.packForwardMessage(forwardData.id, void 0, forwardData));
|
|
@@ -24607,16 +24741,8 @@ var SetFriendAddRequest = class extends BaseAction {
|
|
|
24607
24741
|
remark: lib_default$1.string()
|
|
24608
24742
|
});
|
|
24609
24743
|
async _handle(payload) {
|
|
24610
|
-
|
|
24611
|
-
if (
|
|
24612
|
-
const uid = data[0];
|
|
24613
|
-
const reqTime = data[1];
|
|
24614
|
-
const res = await this.ctx.ntFriendApi.handleFriendRequest(uid, reqTime, payload.approve);
|
|
24615
|
-
if (res.result !== 0) throw new Error(res.errMsg);
|
|
24616
|
-
if (payload.remark) {
|
|
24617
|
-
const res = await this.ctx.ntFriendApi.setBuddyRemark(uid, payload.remark);
|
|
24618
|
-
if (res.result !== 0) throw new Error(res.errMsg);
|
|
24619
|
-
}
|
|
24744
|
+
await this.ctx.ntFriendApi.approvalFriendRequest(payload.flag, payload.approve);
|
|
24745
|
+
if (payload.remark) await this.ctx.ntFriendApi.setFriendRemark(payload.flag, payload.remark);
|
|
24620
24746
|
return null;
|
|
24621
24747
|
}
|
|
24622
24748
|
};
|
|
@@ -24740,26 +24866,23 @@ var GetFileBase = class extends BaseAction {
|
|
|
24740
24866
|
if (!fileCache?.length) fileCache = await this.ctx.store.getFileCacheByName(payload.file);
|
|
24741
24867
|
if (fileCache?.length) {
|
|
24742
24868
|
let downloadPath = "";
|
|
24743
|
-
if (payload.download)
|
|
24869
|
+
if (payload.download) {
|
|
24870
|
+
const file = await uri2local(this.ctx, fileCache[0].fileUuid, true);
|
|
24871
|
+
if (file.errMsg) throw new Error(file.errMsg);
|
|
24872
|
+
downloadPath = file.path;
|
|
24873
|
+
}
|
|
24744
24874
|
const res = {
|
|
24745
24875
|
file: downloadPath,
|
|
24746
24876
|
url: "",
|
|
24747
24877
|
file_size: fileCache[0].fileSize,
|
|
24748
24878
|
file_name: fileCache[0].fileName
|
|
24749
24879
|
};
|
|
24750
|
-
const
|
|
24751
|
-
chatType: fileCache[0].chatType,
|
|
24752
|
-
peerUid: fileCache[0].peerUid,
|
|
24753
|
-
guildId: ""
|
|
24754
|
-
};
|
|
24880
|
+
const isGroup = fileCache[0].chatType === ChatType.Group;
|
|
24755
24881
|
if (fileCache[0].elementType === ElementType.Pic) {
|
|
24756
|
-
const
|
|
24757
|
-
|
|
24758
|
-
|
|
24759
|
-
|
|
24760
|
-
res.url = await this.ctx.ntFileApi.getImageUrl(findEle.picElement);
|
|
24761
|
-
} else if (fileCache[0].elementType === ElementType.Video) res.url = await this.ctx.ntFileApi.getVideoUrl(peer, fileCache[0].msgId, fileCache[0].elementId);
|
|
24762
|
-
else if (fileCache[0].elementType === ElementType.Ptt) res.url = await this.ctx.ntFileApi.getPttUrl(fileCache[0].fileUuid, peer.chatType === 2);
|
|
24882
|
+
const originImageUrl = `/download?appid=${isGroup ? 1407 : 1406}&fileid=${fileCache[0].fileUuid}&spec=0`;
|
|
24883
|
+
res.url = await this.ctx.ntFileApi.getImageUrl(originImageUrl, fileCache[0].md5HexStr);
|
|
24884
|
+
} else if (fileCache[0].elementType === ElementType.Video) res.url = await this.ctx.ntFileApi.getVideoUrl(fileCache[0].fileUuid, isGroup);
|
|
24885
|
+
else if (fileCache[0].elementType === ElementType.Ptt) res.url = await this.ctx.ntFileApi.getPttUrl(fileCache[0].fileUuid, isGroup);
|
|
24763
24886
|
if (enableLocalFile2Url && downloadPath && (res.file === res.url || res.url === void 0)) try {
|
|
24764
24887
|
res.base64 = await readFile(downloadPath, "base64");
|
|
24765
24888
|
} catch (e) {
|
|
@@ -24807,8 +24930,9 @@ var GetRecord = class extends BaseAction {
|
|
|
24807
24930
|
async _handle(payload) {
|
|
24808
24931
|
const fileCache = await this.ctx.store.getFileCacheByName(payload.file);
|
|
24809
24932
|
if (fileCache?.length) {
|
|
24810
|
-
const
|
|
24811
|
-
|
|
24933
|
+
const originFile = await uri2local(this.ctx, fileCache[0].fileUuid, true);
|
|
24934
|
+
if (originFile.errMsg) throw new Error(originFile.errMsg);
|
|
24935
|
+
const file = await decodeSilk(this.ctx, originFile.path, payload.out_format);
|
|
24812
24936
|
const res = {
|
|
24813
24937
|
file,
|
|
24814
24938
|
file_name: path.basename(file),
|
|
@@ -24907,17 +25031,17 @@ var DownloadFile = class extends BaseAction {
|
|
|
24907
25031
|
const isRandomName = !payload.name;
|
|
24908
25032
|
const name = payload.name ? path.basename(payload.name) : randomUUID();
|
|
24909
25033
|
const filePath = path.join(TEMP_DIR, name);
|
|
24910
|
-
if (payload.base64) await fsPromise.writeFile(filePath, payload.base64, "base64");
|
|
25034
|
+
if (payload.base64) await fsPromise$1.writeFile(filePath, payload.base64, "base64");
|
|
24911
25035
|
else if (payload.url) {
|
|
24912
25036
|
const headers = this.getHeaders(payload.headers);
|
|
24913
25037
|
const res = await fetchFile(payload.url, headers);
|
|
24914
|
-
await fsPromise.writeFile(filePath, res.data);
|
|
25038
|
+
await fsPromise$1.writeFile(filePath, res.data);
|
|
24915
25039
|
} else throw new Error("不存在任何文件, 无法下载");
|
|
24916
|
-
if (fs
|
|
25040
|
+
if (fs.existsSync(filePath)) {
|
|
24917
25041
|
if (isRandomName) {
|
|
24918
25042
|
const md5 = await getMd5HexFromFile(filePath);
|
|
24919
25043
|
const newPath = path.join(TEMP_DIR, md5);
|
|
24920
|
-
await fsPromise.rename(filePath, newPath);
|
|
25044
|
+
await fsPromise$1.rename(filePath, newPath);
|
|
24921
25045
|
return { file: newPath };
|
|
24922
25046
|
}
|
|
24923
25047
|
return { file: filePath };
|
|
@@ -24960,7 +25084,7 @@ var GetGroupMsgHistory = class extends BaseAction {
|
|
|
24960
25084
|
const msg = this.ctx.store.getMsgCache(rawMsg.msgId);
|
|
24961
25085
|
if (msg) rawMsg = msg;
|
|
24962
25086
|
}
|
|
24963
|
-
return OB11Entities.message(this.ctx, rawMsg,
|
|
25087
|
+
return OB11Entities.message(this.ctx, rawMsg, config);
|
|
24964
25088
|
}))),
|
|
24965
25089
|
seq: +msgList[0].msgSeq
|
|
24966
25090
|
};
|
|
@@ -25020,7 +25144,7 @@ async function decodeMultiMessage(ctx, items, messageFormat) {
|
|
|
25020
25144
|
} else if (serviceType === 48 && (businessType === 11 || businessType === 21)) {
|
|
25021
25145
|
const { msgInfoBody } = Media.MsgInfo.decode(pbElem);
|
|
25022
25146
|
const { index } = msgInfoBody[0];
|
|
25023
|
-
const url = await ctx.ntFileApi.
|
|
25147
|
+
const url = await ctx.ntFileApi.getVideoUrl(index.fileUuid, businessType === 21);
|
|
25024
25148
|
segment = {
|
|
25025
25149
|
type: OB11MessageDataType.Video,
|
|
25026
25150
|
data: {
|
|
@@ -25087,7 +25211,7 @@ var GetForwardMsg = class extends BaseAction {
|
|
|
25087
25211
|
throw new Error(data.errMsg);
|
|
25088
25212
|
}
|
|
25089
25213
|
return { messages: filterNullable(await Promise.all(data.msgList.map(async (msg) => {
|
|
25090
|
-
const res = await OB11Entities.message(this.ctx, msg,
|
|
25214
|
+
const res = await OB11Entities.message(this.ctx, msg, config);
|
|
25091
25215
|
if (res) {
|
|
25092
25216
|
const segments = message2List(res.message);
|
|
25093
25217
|
for (const item of segments) if (item.type === OB11MessageDataType.Forward) this.ctx.store.addMultiMsgInfo(rootMsgId, item.data.id, peer);
|
|
@@ -25537,7 +25661,7 @@ var GetFriendMsgHistory = class extends BaseAction {
|
|
|
25537
25661
|
const msg = this.ctx.store.getMsgCache(rawMsg.msgId);
|
|
25538
25662
|
if (msg) rawMsg = msg;
|
|
25539
25663
|
}
|
|
25540
|
-
return OB11Entities.message(this.ctx, rawMsg,
|
|
25664
|
+
return OB11Entities.message(this.ctx, rawMsg, config);
|
|
25541
25665
|
}))),
|
|
25542
25666
|
seq: +msgList[0].msgSeq
|
|
25543
25667
|
};
|
|
@@ -25546,7 +25670,7 @@ var GetFriendMsgHistory = class extends BaseAction {
|
|
|
25546
25670
|
const uid = await this.ctx.ntUserApi.getUidByUin(payload.user_id.toString());
|
|
25547
25671
|
if (!uid) throw new Error(`无法获取用户信息`);
|
|
25548
25672
|
const peer = {
|
|
25549
|
-
chatType: await this.ctx.ntFriendApi.
|
|
25673
|
+
chatType: await this.ctx.ntFriendApi.isFriend(uid) ? ChatType.C2C : ChatType.TempC2CFromGroup,
|
|
25550
25674
|
peerUid: uid,
|
|
25551
25675
|
guildId: ""
|
|
25552
25676
|
};
|
|
@@ -25609,32 +25733,16 @@ var GetGroupFilesByFolder = class extends BaseAction {
|
|
|
25609
25733
|
var GetFriendWithCategory = class extends BaseAction {
|
|
25610
25734
|
actionName = ActionName.GetFriendsWithCategory;
|
|
25611
25735
|
async _handle() {
|
|
25612
|
-
const
|
|
25613
|
-
|
|
25614
|
-
|
|
25615
|
-
|
|
25616
|
-
|
|
25617
|
-
|
|
25618
|
-
|
|
25619
|
-
|
|
25620
|
-
|
|
25621
|
-
|
|
25622
|
-
...item,
|
|
25623
|
-
buddyList
|
|
25624
|
-
});
|
|
25625
|
-
}
|
|
25626
|
-
return category.map((item) => {
|
|
25627
|
-
return {
|
|
25628
|
-
categoryId: item.categoryId,
|
|
25629
|
-
categorySortId: item.categorySortId,
|
|
25630
|
-
categoryName: item.categroyName,
|
|
25631
|
-
categoryMbCount: item.categroyMbCount,
|
|
25632
|
-
onlineCount: item.onlineCount,
|
|
25633
|
-
buddyList: item.buddyList.map((buddy) => {
|
|
25634
|
-
return OB11Entities.friend(buddy);
|
|
25635
|
-
})
|
|
25636
|
-
};
|
|
25637
|
-
});
|
|
25736
|
+
const result = await this.ctx.ntFriendApi.getFriendList(true);
|
|
25737
|
+
return result.categories.values().map((item) => ({
|
|
25738
|
+
categoryId: item.categoryId,
|
|
25739
|
+
categorySortId: item.categorySortId,
|
|
25740
|
+
categoryName: item.categoryName,
|
|
25741
|
+
categoryMbCount: item.categoryMemberCount,
|
|
25742
|
+
buddyList: result.friends.filter((friend) => friend.categoryId === item.categoryId).map((friend) => {
|
|
25743
|
+
return OB11Entities.friend(friend);
|
|
25744
|
+
})
|
|
25745
|
+
})).toArray();
|
|
25638
25746
|
}
|
|
25639
25747
|
};
|
|
25640
25748
|
//#endregion
|
|
@@ -25781,8 +25889,7 @@ var DeleteFriend$1 = class extends BaseAction {
|
|
|
25781
25889
|
const uin = payload.user_id.toString();
|
|
25782
25890
|
const uid = await this.ctx.ntUserApi.getUidByUin(uin);
|
|
25783
25891
|
if (!uid) throw new Error("无法获取用户信息");
|
|
25784
|
-
|
|
25785
|
-
if (res.result !== 0) throw new Error(res.errMsg);
|
|
25892
|
+
await this.ctx.ntFriendApi.deleteFriend(uid);
|
|
25786
25893
|
return null;
|
|
25787
25894
|
}
|
|
25788
25895
|
};
|
|
@@ -25792,29 +25899,24 @@ var OCRImage = class extends BaseAction {
|
|
|
25792
25899
|
actionName = ActionName.GoCQHTTP_OCRImage;
|
|
25793
25900
|
payloadSchema = lib_default$1.object({ image: lib_default$1.string().required() });
|
|
25794
25901
|
async _handle(payload) {
|
|
25795
|
-
|
|
25796
|
-
if (
|
|
25797
|
-
|
|
25798
|
-
|
|
25799
|
-
|
|
25800
|
-
|
|
25902
|
+
let url;
|
|
25903
|
+
if (isHttpUrl(payload.image)) url = payload.image;
|
|
25904
|
+
else {
|
|
25905
|
+
const { errMsg, isLocal, path, success } = await uri2local(this.ctx, payload.image);
|
|
25906
|
+
if (!success) throw new Error(errMsg);
|
|
25907
|
+
const { msgInfo } = await this.ctx.ntFileApi.uploadC2CImage(selfInfo.uid, path);
|
|
25908
|
+
if (!isLocal) unlink(path).catch(noop);
|
|
25909
|
+
const { pic, index } = msgInfo.msgInfoBody[0];
|
|
25910
|
+
url = await this.ctx.ntFileApi.getImageUrl(pic.urlPath + pic.ext.originalParam, index.info.md5HexStr);
|
|
25911
|
+
}
|
|
25912
|
+
const { textDetections, language } = await this.ctx.ntFileApi.ocrImage(url);
|
|
25801
25913
|
return {
|
|
25802
|
-
texts:
|
|
25803
|
-
|
|
25804
|
-
|
|
25805
|
-
|
|
25806
|
-
|
|
25807
|
-
|
|
25808
|
-
for (let i = 0; i < 4; i++) {
|
|
25809
|
-
const pt = item[`pt${i + 1}`];
|
|
25810
|
-
ret.coordinates.push({
|
|
25811
|
-
x: +pt.x,
|
|
25812
|
-
y: +pt.y
|
|
25813
|
-
});
|
|
25814
|
-
}
|
|
25815
|
-
return ret;
|
|
25816
|
-
}),
|
|
25817
|
-
language: ""
|
|
25914
|
+
texts: textDetections.map((item) => ({
|
|
25915
|
+
text: item.detectedText,
|
|
25916
|
+
confidence: item.confidence,
|
|
25917
|
+
coordinates: item.polygon.coordinates
|
|
25918
|
+
})),
|
|
25919
|
+
language
|
|
25818
25920
|
};
|
|
25819
25921
|
}
|
|
25820
25922
|
};
|
|
@@ -25925,8 +26027,7 @@ var SetFriendCategory = class extends BaseAction {
|
|
|
25925
26027
|
async _handle(payload) {
|
|
25926
26028
|
const uid = await this.ctx.ntUserApi.getUidByUin(payload.user_id.toString());
|
|
25927
26029
|
if (!uid) throw new Error("无法获取好友信息");
|
|
25928
|
-
|
|
25929
|
-
if (res.result !== 0) throw new Error(res.errMsg);
|
|
26030
|
+
await this.ctx.ntFriendApi.setFriendCategory(uid, +payload.category_id);
|
|
25930
26031
|
return null;
|
|
25931
26032
|
}
|
|
25932
26033
|
};
|
|
@@ -25941,8 +26042,7 @@ var SetFriendRemark = class extends BaseAction {
|
|
|
25941
26042
|
async _handle(payload) {
|
|
25942
26043
|
const uid = await this.ctx.ntUserApi.getUidByUin(payload.user_id.toString());
|
|
25943
26044
|
if (!uid) throw new Error("无法获取好友信息");
|
|
25944
|
-
|
|
25945
|
-
if (res.result !== 0) throw new Error(res.errMsg);
|
|
26045
|
+
await this.ctx.ntFriendApi.setFriendRemark(uid, payload.remark);
|
|
25946
26046
|
return null;
|
|
25947
26047
|
}
|
|
25948
26048
|
};
|
|
@@ -26461,17 +26561,17 @@ var GetDoubtFriendsAddRequest = class extends BaseAction {
|
|
|
26461
26561
|
actionName = ActionName.GetDoubtFriendsAddRequest;
|
|
26462
26562
|
payloadSchema = lib_default$1.object({ count: lib_default$1.union([Number, String]).default(50) });
|
|
26463
26563
|
async _handle(payload) {
|
|
26464
|
-
const res = await this.ctx.ntFriendApi.
|
|
26465
|
-
return await Promise.all(res.
|
|
26564
|
+
const res = await this.ctx.ntFriendApi.getDoubtFriendRequests(+payload.count);
|
|
26565
|
+
return await Promise.all(res.map(async (e) => {
|
|
26466
26566
|
return {
|
|
26467
|
-
flag: e.
|
|
26468
|
-
uin: await this.ctx.ntUserApi.getUinByUid(e.
|
|
26469
|
-
nick: e.
|
|
26567
|
+
flag: e.sourceUid,
|
|
26568
|
+
uin: await this.ctx.ntUserApi.getUinByUid(e.sourceUid),
|
|
26569
|
+
nick: e.sourceNickname,
|
|
26470
26570
|
source: e.source,
|
|
26471
|
-
reason: e.
|
|
26472
|
-
msg: e.
|
|
26473
|
-
group_code: e.groupCode,
|
|
26474
|
-
time: e.
|
|
26571
|
+
reason: e.warningInfo,
|
|
26572
|
+
msg: e.comment,
|
|
26573
|
+
group_code: e.groupCode.toString(),
|
|
26574
|
+
time: e.timestamp.toString(),
|
|
26475
26575
|
type: "doubt"
|
|
26476
26576
|
};
|
|
26477
26577
|
}));
|
|
@@ -26483,8 +26583,7 @@ var SetDoubtFriendsAddRequest = class extends BaseAction {
|
|
|
26483
26583
|
actionName = ActionName.SetDoubtFriendsAddRequest;
|
|
26484
26584
|
payloadSchema = lib_default$1.object({ flag: lib_default$1.string().required() });
|
|
26485
26585
|
async _handle(payload) {
|
|
26486
|
-
|
|
26487
|
-
if (res.result !== 0) throw new Error(res.errMsg);
|
|
26586
|
+
await this.ctx.ntFriendApi.approvalDoubtFriendRequest(payload.flag);
|
|
26488
26587
|
return null;
|
|
26489
26588
|
}
|
|
26490
26589
|
};
|
|
@@ -26928,7 +27027,6 @@ var Onebot11Adapter = class extends Service {
|
|
|
26928
27027
|
static inject = [
|
|
26929
27028
|
"ntMsgApi",
|
|
26930
27029
|
"ntFileApi",
|
|
26931
|
-
"ntFileCacheApi",
|
|
26932
27030
|
"ntFriendApi",
|
|
26933
27031
|
"ntGroupApi",
|
|
26934
27032
|
"ntUserApi",
|
|
@@ -27063,7 +27161,7 @@ var Onebot11Adapter = class extends Service {
|
|
|
27063
27161
|
}
|
|
27064
27162
|
async handleFriendRequest(req) {
|
|
27065
27163
|
const uin = await this.ctx.ntUserApi.getUinByUid(req.friendUid);
|
|
27066
|
-
const flag = req.friendUid
|
|
27164
|
+
const flag = req.friendUid;
|
|
27067
27165
|
const friendRequestEvent = new OB11FriendRequestEvent(+uin, req.extWords, flag, req.addSource ?? "");
|
|
27068
27166
|
this.dispatch(friendRequestEvent);
|
|
27069
27167
|
}
|
|
@@ -28013,10 +28111,10 @@ var robotUinRanges = [
|
|
|
28013
28111
|
];
|
|
28014
28112
|
function decodeUser(user) {
|
|
28015
28113
|
return {
|
|
28016
|
-
id: user.uin,
|
|
28114
|
+
id: user.uin.toString(),
|
|
28017
28115
|
name: user.nick,
|
|
28018
28116
|
avatar: `http://q.qlogo.cn/headimg_dl?dst_uin=${user.uin}&spec=640`,
|
|
28019
|
-
is_bot: robotUinRanges.some((e) => user.uin >= e.minUin && user.uin <= e.maxUin)
|
|
28117
|
+
is_bot: robotUinRanges.some((e) => +user.uin >= +e.minUin && +user.uin <= +e.maxUin)
|
|
28020
28118
|
};
|
|
28021
28119
|
}
|
|
28022
28120
|
function decodeGuildChannelId(data) {
|
|
@@ -28059,7 +28157,7 @@ async function decodeElement(ctx, data, quoted = false) {
|
|
|
28059
28157
|
ctx.logger.error("获取不到引用的消息", e, v.replyElement, e.stack);
|
|
28060
28158
|
}
|
|
28061
28159
|
} else if (v.picElement) {
|
|
28062
|
-
const src = await ctx.ntFileApi.getImageUrl(v.picElement);
|
|
28160
|
+
const src = await ctx.ntFileApi.getImageUrl(v.picElement.originImageUrl, v.picElement.md5HexStr);
|
|
28063
28161
|
buffer.push(lib_default.img(src, {
|
|
28064
28162
|
width: v.picElement.picWidth,
|
|
28065
28163
|
height: v.picElement.picHeight,
|
|
@@ -28069,11 +28167,7 @@ async function decodeElement(ctx, data, quoted = false) {
|
|
|
28069
28167
|
const src = await ctx.ntFileApi.getPttUrl(v.pttElement.fileUuid, data.chatType === ChatType.Group);
|
|
28070
28168
|
buffer.push(lib_default.audio(src, { duration: v.pttElement.duration }));
|
|
28071
28169
|
} else if (v.videoElement) {
|
|
28072
|
-
const src = await ctx.ntFileApi.getVideoUrl(
|
|
28073
|
-
chatType: data.chatType,
|
|
28074
|
-
peerUid: data.peerUid,
|
|
28075
|
-
guildId: ""
|
|
28076
|
-
}, data.msgId, v.elementId) || pathToFileURL(v.videoElement.filePath).href;
|
|
28170
|
+
const src = await ctx.ntFileApi.getVideoUrl(v.videoElement.fileUuid, data.chatType === ChatType.Group);
|
|
28077
28171
|
buffer.push(lib_default.video(src));
|
|
28078
28172
|
} else if (v.marketFaceElement) {
|
|
28079
28173
|
const { emojiId, supportSize } = v.marketFaceElement;
|
|
@@ -28166,7 +28260,7 @@ async function getPeer(ctx, channelId) {
|
|
|
28166
28260
|
const uin = channelId.replace("private:", "");
|
|
28167
28261
|
const uid = await ctx.ntUserApi.getUidByUin(uin);
|
|
28168
28262
|
if (!uid) throw new Error("无法获取用户信息");
|
|
28169
|
-
if (!await ctx.ntFriendApi.
|
|
28263
|
+
if (!await ctx.ntFriendApi.isFriend(uid)) {
|
|
28170
28264
|
if ((await ctx.ntMsgApi.getTempChatInfo(ChatType.TempC2CFromGroup, uid)).tmpChatInfo.groupCode) return {
|
|
28171
28265
|
chatType: ChatType.TempC2CFromGroup,
|
|
28172
28266
|
peerUid: uid,
|
|
@@ -28672,53 +28766,13 @@ async function ntToProto(ctx, input, peer) {
|
|
|
28672
28766
|
else if (input.elementType === ElementType.Pic) {
|
|
28673
28767
|
const isGroup = peer.chatType === ChatType.Group;
|
|
28674
28768
|
const path = input.picElement.sourcePath;
|
|
28675
|
-
|
|
28769
|
+
let data;
|
|
28770
|
+
if (isGroup) data = await ctx.ntFileApi.uploadGroupImage(peer.peerUid, path);
|
|
28771
|
+
else data = await ctx.ntFileApi.uploadC2CImage(peer.peerUid, path);
|
|
28676
28772
|
return {
|
|
28677
28773
|
element: { commonElem: {
|
|
28678
28774
|
serviceType: 48,
|
|
28679
|
-
pbElem: Media.MsgInfo.encode(
|
|
28680
|
-
msgInfoBody: [{
|
|
28681
|
-
index: {
|
|
28682
|
-
info: {
|
|
28683
|
-
fileSize: +data.commonFileInfo.fileSize,
|
|
28684
|
-
md5HexStr: data.commonFileInfo.md5,
|
|
28685
|
-
sha1HexStr: data.commonFileInfo.sha,
|
|
28686
|
-
fileName: data.commonFileInfo.fileName,
|
|
28687
|
-
fileType: {
|
|
28688
|
-
type: 1,
|
|
28689
|
-
picFormat: input.picElement.picType
|
|
28690
|
-
},
|
|
28691
|
-
width: input.picElement.picWidth,
|
|
28692
|
-
height: input.picElement.picHeight,
|
|
28693
|
-
time: 0,
|
|
28694
|
-
original: 1
|
|
28695
|
-
},
|
|
28696
|
-
fileUuid: data.fileId,
|
|
28697
|
-
storeID: 1,
|
|
28698
|
-
expire: isGroup ? 2678400 : 15768e4
|
|
28699
|
-
},
|
|
28700
|
-
pic: {
|
|
28701
|
-
urlPath: `/download?appid=${isGroup ? 1407 : 1406}&fileid=${data.fileId}`,
|
|
28702
|
-
ext: {
|
|
28703
|
-
originalParam: "&spec=0",
|
|
28704
|
-
bigParam: "&spec=720",
|
|
28705
|
-
thumbParam: "&spec=198"
|
|
28706
|
-
},
|
|
28707
|
-
domain: "multimedia.nt.qq.com.cn"
|
|
28708
|
-
},
|
|
28709
|
-
fileExist: true
|
|
28710
|
-
}],
|
|
28711
|
-
extBizInfo: {
|
|
28712
|
-
pic: {
|
|
28713
|
-
bizType: 0,
|
|
28714
|
-
summary: "",
|
|
28715
|
-
fromScene: isGroup ? 2 : 1,
|
|
28716
|
-
toScene: isGroup ? 2 : 1,
|
|
28717
|
-
oldFileId: isGroup ? 574859779 : void 0
|
|
28718
|
-
},
|
|
28719
|
-
busiType: input.picElement.picSubType
|
|
28720
|
-
}
|
|
28721
|
-
}),
|
|
28775
|
+
pbElem: Media.MsgInfo.encode(data.msgInfo),
|
|
28722
28776
|
businessType: isGroup ? 20 : 10
|
|
28723
28777
|
} },
|
|
28724
28778
|
preview: input.picElement.picSubType === 1 ? "[动画表情]" : "[图片]"
|
|
@@ -28898,20 +28952,15 @@ var getUser = async (ctx, payload) => {
|
|
|
28898
28952
|
//#endregion
|
|
28899
28953
|
//#region src/satori/api/friend/list.ts
|
|
28900
28954
|
var getFriendList = async (ctx) => {
|
|
28901
|
-
return { data: (await ctx.ntFriendApi.
|
|
28902
|
-
user: decodeUser(e
|
|
28903
|
-
nick: e.
|
|
28955
|
+
return { data: (await ctx.ntFriendApi.getFriendList(true)).friends.map((e) => ({
|
|
28956
|
+
user: decodeUser(e),
|
|
28957
|
+
nick: e.remark
|
|
28904
28958
|
})) };
|
|
28905
28959
|
};
|
|
28906
28960
|
//#endregion
|
|
28907
28961
|
//#region src/satori/api/friend/approve.ts
|
|
28908
28962
|
var handleFriendRequest = async (ctx, payload) => {
|
|
28909
|
-
|
|
28910
|
-
if (data.length < 2) throw new Error("无效的 message_id");
|
|
28911
|
-
const uid = data[0];
|
|
28912
|
-
const reqTime = data[1];
|
|
28913
|
-
const res = await ctx.ntFriendApi.handleFriendRequest(uid, reqTime, payload.approve);
|
|
28914
|
-
if (res.result !== 0) throw new Error(res.errMsg);
|
|
28963
|
+
await ctx.ntFriendApi.approvalFriendRequest(payload.message_id, payload.approve);
|
|
28915
28964
|
return {};
|
|
28916
28965
|
};
|
|
28917
28966
|
//#endregion
|
|
@@ -28919,8 +28968,7 @@ var handleFriendRequest = async (ctx, payload) => {
|
|
|
28919
28968
|
var deleteFriend = async (ctx, payload) => {
|
|
28920
28969
|
const uid = await ctx.ntUserApi.getUidByUin(payload.user_id);
|
|
28921
28970
|
if (!uid) throw new Error("无法获取用户信息");
|
|
28922
|
-
|
|
28923
|
-
if (res.result !== 0) throw new Error(res.errMsg);
|
|
28971
|
+
await ctx.ntFriendApi.deleteFriend(uid);
|
|
28924
28972
|
return {};
|
|
28925
28973
|
};
|
|
28926
28974
|
//#endregion
|
|
@@ -29209,7 +29257,7 @@ async function parseGuildMemberRequest(bot, input, doubt) {
|
|
|
29209
29257
|
//#endregion
|
|
29210
29258
|
//#region src/satori/event/user.ts
|
|
29211
29259
|
async function parseFriendRequest(bot, input) {
|
|
29212
|
-
const flag = input.friendUid
|
|
29260
|
+
const flag = input.friendUid;
|
|
29213
29261
|
const user = await bot.ctx.ntUserApi.getUserSimpleInfo(input.friendUid);
|
|
29214
29262
|
return bot.event("friend-request", {
|
|
29215
29263
|
user: decodeUser(user.coreInfo),
|
|
@@ -29279,7 +29327,6 @@ var SatoriAdapter = class extends Service {
|
|
|
29279
29327
|
static inject = [
|
|
29280
29328
|
"ntMsgApi",
|
|
29281
29329
|
"ntFileApi",
|
|
29282
|
-
"ntFileCacheApi",
|
|
29283
29330
|
"ntFriendApi",
|
|
29284
29331
|
"ntGroupApi",
|
|
29285
29332
|
"ntUserApi",
|
|
@@ -40911,7 +40958,7 @@ function _null(params) {
|
|
|
40911
40958
|
var ZodAny = /* @__PURE__ */ $constructor("ZodAny", (inst, def) => {
|
|
40912
40959
|
$ZodAny.init(inst, def);
|
|
40913
40960
|
ZodType.init(inst, def);
|
|
40914
|
-
inst._zod.processJSONSchema = (ctx, json, params) =>
|
|
40961
|
+
inst._zod.processJSONSchema = (ctx, json, params) => void 0;
|
|
40915
40962
|
});
|
|
40916
40963
|
function any() {
|
|
40917
40964
|
return /* @__PURE__ */ _any(ZodAny);
|
|
@@ -40919,7 +40966,7 @@ function any() {
|
|
|
40919
40966
|
var ZodUnknown = /* @__PURE__ */ $constructor("ZodUnknown", (inst, def) => {
|
|
40920
40967
|
$ZodUnknown.init(inst, def);
|
|
40921
40968
|
ZodType.init(inst, def);
|
|
40922
|
-
inst._zod.processJSONSchema = (ctx, json, params) =>
|
|
40969
|
+
inst._zod.processJSONSchema = (ctx, json, params) => void 0;
|
|
40923
40970
|
});
|
|
40924
40971
|
function unknown() {
|
|
40925
40972
|
return /* @__PURE__ */ _unknown(ZodUnknown);
|
|
@@ -42413,14 +42460,14 @@ function transformGender(gender) {
|
|
|
42413
42460
|
}
|
|
42414
42461
|
function transformFriend(friend, category) {
|
|
42415
42462
|
return {
|
|
42416
|
-
user_id:
|
|
42417
|
-
nickname: friend.
|
|
42418
|
-
sex: transformGender(friend.
|
|
42419
|
-
qid: friend.
|
|
42420
|
-
remark: friend.
|
|
42463
|
+
user_id: friend.uin,
|
|
42464
|
+
nickname: friend.nick,
|
|
42465
|
+
sex: transformGender(friend.sex),
|
|
42466
|
+
qid: friend.qid,
|
|
42467
|
+
remark: friend.remark,
|
|
42421
42468
|
category: {
|
|
42422
42469
|
category_id: category.categoryId,
|
|
42423
|
-
category_name: category.
|
|
42470
|
+
category_name: category.categoryName
|
|
42424
42471
|
}
|
|
42425
42472
|
};
|
|
42426
42473
|
}
|
|
@@ -43484,7 +43531,7 @@ async function download(url, headers) {
|
|
|
43484
43531
|
return Buffer.from(bytes);
|
|
43485
43532
|
}
|
|
43486
43533
|
async function resolveMilkyUri(uri) {
|
|
43487
|
-
if (uri.startsWith("file://")) return await
|
|
43534
|
+
if (uri.startsWith("file://")) return await fsPromise.readFile(fileURLToPath(uri));
|
|
43488
43535
|
if (uri.startsWith("http://") || uri.startsWith("https://")) return await download(uri);
|
|
43489
43536
|
if (uri.startsWith("base64://")) return Buffer.from(uri.slice(9), "base64");
|
|
43490
43537
|
throw new Error(`Unsupported URI scheme: ${uri}`);
|
|
@@ -43527,22 +43574,16 @@ var SystemApi = [
|
|
|
43527
43574
|
school: info.school
|
|
43528
43575
|
});
|
|
43529
43576
|
}),
|
|
43530
|
-
defineApi("get_friend_list", GetFriendListInput, GetFriendListOutput, async (ctx) => {
|
|
43531
|
-
const
|
|
43532
|
-
const category = /* @__PURE__ */ new Map();
|
|
43577
|
+
defineApi("get_friend_list", GetFriendListInput, GetFriendListOutput, async (ctx, payload) => {
|
|
43578
|
+
const result = await ctx.ntFriendApi.getFriendList(payload.no_cache);
|
|
43533
43579
|
const friendList = [];
|
|
43534
|
-
for (const friend of friends)
|
|
43535
|
-
const { categoryId } = friend.baseInfo;
|
|
43536
|
-
if (!category.has(categoryId)) category.set(categoryId, await ctx.ntFriendApi.getCategoryById(categoryId));
|
|
43537
|
-
friendList.push(transformFriend(friend, category.get(categoryId)));
|
|
43538
|
-
}
|
|
43580
|
+
for (const friend of result.friends) friendList.push(transformFriend(friend, result.categories.get(friend.categoryId)));
|
|
43539
43581
|
return Ok({ friends: friendList });
|
|
43540
43582
|
}),
|
|
43541
43583
|
defineApi("get_friend_info", GetFriendInfoInput, GetFriendInfoOutput, async (ctx, payload) => {
|
|
43542
|
-
const
|
|
43543
|
-
if (!
|
|
43544
|
-
|
|
43545
|
-
return Ok({ friend: transformFriend(friend, await ctx.ntFriendApi.getCategoryById(friend.baseInfo.categoryId)) });
|
|
43584
|
+
const result = await ctx.ntFriendApi.getFriendInfoByUin(payload.user_id, payload.no_cache);
|
|
43585
|
+
if (!result) return Failed(-404, "Friend not found");
|
|
43586
|
+
return Ok({ friend: transformFriend(result.friend, result.category) });
|
|
43546
43587
|
}),
|
|
43547
43588
|
defineApi("get_group_list", GetGroupListInput, GetGroupListOutput, async (ctx) => {
|
|
43548
43589
|
const { groups } = await ctx.pmhq.fetchGroups();
|
|
@@ -43598,28 +43639,15 @@ var SystemApi = [
|
|
|
43598
43639
|
return Ok({ member: transformGroupMember(await ctx.ntGroupApi.getGroupMember(groupCode, memberUid, payload.no_cache), payload.group_id) });
|
|
43599
43640
|
}),
|
|
43600
43641
|
defineApi("get_peer_pins", zod_default.object({}), GetPeerPinsOutput, async (ctx) => {
|
|
43601
|
-
const
|
|
43602
|
-
const category = /* @__PURE__ */ new Map();
|
|
43603
|
-
const { groups } = await ctx.pmhq.fetchGroups();
|
|
43642
|
+
const result = await ctx.ntMsgApi.getPins();
|
|
43604
43643
|
return Ok({
|
|
43605
|
-
friends: await Promise.all(friends.
|
|
43606
|
-
const
|
|
43607
|
-
|
|
43608
|
-
return transformFriend(e, category.get(categoryId));
|
|
43644
|
+
friends: await Promise.all(result.friends.map(async (e) => {
|
|
43645
|
+
const info = await ctx.ntFriendApi.getFriendInfoByUid(e.uid, false);
|
|
43646
|
+
return transformFriend(info.friend, info.category);
|
|
43609
43647
|
})),
|
|
43610
|
-
groups:
|
|
43611
|
-
return
|
|
43612
|
-
|
|
43613
|
-
group_name: e.info.groupName,
|
|
43614
|
-
member_count: e.info.memberCount,
|
|
43615
|
-
max_member_count: e.info.memberMax,
|
|
43616
|
-
remark: e.customInfo.remark ?? "",
|
|
43617
|
-
created_time: e.info.createdTime,
|
|
43618
|
-
description: e.info.richDescription ?? "",
|
|
43619
|
-
question: e.info.question ?? "",
|
|
43620
|
-
announcement: e.info.announcement ?? ""
|
|
43621
|
-
};
|
|
43622
|
-
})
|
|
43648
|
+
groups: await Promise.all(result.groups.map(async (e) => {
|
|
43649
|
+
return transformGroup(await ctx.ntGroupApi.getGroupDetailInfo(e.groupCode.toString()));
|
|
43650
|
+
}))
|
|
43623
43651
|
});
|
|
43624
43652
|
}),
|
|
43625
43653
|
defineApi("set_peer_pin", SetPeerPinInput, zod_default.object({}), async (ctx, payload) => {
|
|
@@ -43873,53 +43901,10 @@ var ForwardMessageEncoder = class ForwardMessageEncoder {
|
|
|
43873
43901
|
this.children = [];
|
|
43874
43902
|
this.preview = "";
|
|
43875
43903
|
}
|
|
43876
|
-
async packImage(
|
|
43877
|
-
const imageSize = await this.ctx.ntFileApi.getImageSize(data.filePath);
|
|
43904
|
+
async packImage(msgInfo) {
|
|
43878
43905
|
return { commonElem: {
|
|
43879
43906
|
serviceType: 48,
|
|
43880
|
-
pbElem: Media.MsgInfo.encode(
|
|
43881
|
-
msgInfoBody: [{
|
|
43882
|
-
index: {
|
|
43883
|
-
info: {
|
|
43884
|
-
fileSize: +data.commonFileInfo.fileSize,
|
|
43885
|
-
md5HexStr: data.commonFileInfo.md5,
|
|
43886
|
-
sha1HexStr: data.commonFileInfo.sha,
|
|
43887
|
-
fileName: data.commonFileInfo.fileName,
|
|
43888
|
-
fileType: {
|
|
43889
|
-
type: 1,
|
|
43890
|
-
picFormat: imageSize.type === "gif" ? 2e3 : 1e3
|
|
43891
|
-
},
|
|
43892
|
-
width: imageSize.width,
|
|
43893
|
-
height: imageSize.height,
|
|
43894
|
-
time: 0,
|
|
43895
|
-
original: 1
|
|
43896
|
-
},
|
|
43897
|
-
fileUuid: data.fileId,
|
|
43898
|
-
storeID: 1,
|
|
43899
|
-
expire: this.isGroup ? 2678400 : 15768e4
|
|
43900
|
-
},
|
|
43901
|
-
pic: {
|
|
43902
|
-
urlPath: `/download?appid=${this.isGroup ? 1407 : 1406}&fileid=${data.fileId}`,
|
|
43903
|
-
ext: {
|
|
43904
|
-
originalParam: "&spec=0",
|
|
43905
|
-
bigParam: "&spec=720",
|
|
43906
|
-
thumbParam: "&spec=198"
|
|
43907
|
-
},
|
|
43908
|
-
domain: "multimedia.nt.qq.com.cn"
|
|
43909
|
-
},
|
|
43910
|
-
fileExist: true
|
|
43911
|
-
}],
|
|
43912
|
-
extBizInfo: {
|
|
43913
|
-
pic: {
|
|
43914
|
-
bizType: 0,
|
|
43915
|
-
summary: "",
|
|
43916
|
-
fromScene: this.isGroup ? 2 : 1,
|
|
43917
|
-
toScene: this.isGroup ? 2 : 1,
|
|
43918
|
-
oldFileId: this.isGroup ? 574859779 : void 0
|
|
43919
|
-
},
|
|
43920
|
-
busiType
|
|
43921
|
-
}
|
|
43922
|
-
}),
|
|
43907
|
+
pbElem: Media.MsgInfo.encode(msgInfo),
|
|
43923
43908
|
businessType: this.isGroup ? 20 : 10
|
|
43924
43909
|
} };
|
|
43925
43910
|
}
|
|
@@ -43976,9 +43961,11 @@ var ForwardMessageEncoder = class ForwardMessageEncoder {
|
|
|
43976
43961
|
const imageBuffer = await resolveMilkyUri(segment.data.uri);
|
|
43977
43962
|
const tempPath = path.join(TEMP_DIR, `image-${randomUUID()}`);
|
|
43978
43963
|
await writeFile(tempPath, imageBuffer);
|
|
43979
|
-
|
|
43964
|
+
let data;
|
|
43965
|
+
if (this.isGroup) data = await this.ctx.ntFileApi.uploadGroupImage(this.peerUid, tempPath);
|
|
43966
|
+
else data = await this.ctx.ntFileApi.uploadC2CImage(this.peerUid, tempPath);
|
|
43980
43967
|
const busiType = segment.data.sub_type === "sticker" ? 1 : 0;
|
|
43981
|
-
this.children.push(await this.packImage(data
|
|
43968
|
+
this.children.push(await this.packImage(data.msgInfo));
|
|
43982
43969
|
this.preview += busiType === 1 ? "[动画表情]" : "[图片]";
|
|
43983
43970
|
unlink(tempPath).catch(noop);
|
|
43984
43971
|
} else if (type === "forward") {
|
|
@@ -47591,7 +47578,7 @@ function readStopNodeData(xmlData, tagName, i) {
|
|
|
47591
47578
|
else if (c1 === 33 && xmlData.charCodeAt(i + 2) === 45 && xmlData.charCodeAt(i + 3) === 45) i = findClosingIndex(xmlData, "-->", i + 3, "StopNode is not closed.");
|
|
47592
47579
|
else if (c1 === 33 && xmlData.charCodeAt(i + 2) === 91) i = findClosingIndex(xmlData, "]]>", i, "StopNode is not closed.") - 2;
|
|
47593
47580
|
else {
|
|
47594
|
-
const tagData = readTagExp(xmlData, i,
|
|
47581
|
+
const tagData = readTagExp(xmlData, i, false);
|
|
47595
47582
|
if (tagData) {
|
|
47596
47583
|
if ((tagData && tagData.tagName) === tagName && tagData.tagExp[tagData.tagExp.length - 1] !== "/") openTagCount++;
|
|
47597
47584
|
i = tagData.closeIndex;
|
|
@@ -47676,6 +47663,7 @@ function compress(arr, options, matcher, readonlyMatcher) {
|
|
|
47676
47663
|
else if (tagObj[property]) {
|
|
47677
47664
|
let val = compress(tagObj[property], options, matcher, readonlyMatcher);
|
|
47678
47665
|
const isLeaf = isLeafTag(val, options);
|
|
47666
|
+
if (Object.keys(val).length === 0 && options.alwaysCreateTextNode) val[options.textNodeName] = "";
|
|
47679
47667
|
if (tagObj[":@"]) assignAttributes(val, tagObj[":@"], readonlyMatcher, options);
|
|
47680
47668
|
else if (Object.keys(val).length === 1 && val[options.textNodeName] !== void 0 && !options.alwaysCreateTextNode) val = val[options.textNodeName];
|
|
47681
47669
|
else if (Object.keys(val).length === 0) if (options.alwaysCreateTextNode) val[options.textNodeName] = "";
|
|
@@ -47784,7 +47772,25 @@ async function transformIncomingPrivateMessage(ctx, friend, category, message) {
|
|
|
47784
47772
|
sender_id: +message.senderUin,
|
|
47785
47773
|
time: +message.msgTime,
|
|
47786
47774
|
segments: await transformIncomingSegments(ctx, message),
|
|
47787
|
-
friend: transformFriend(
|
|
47775
|
+
friend: transformFriend({
|
|
47776
|
+
uid: friend.uid,
|
|
47777
|
+
uin: +friend.uin,
|
|
47778
|
+
categoryId: friend.baseInfo.categoryId,
|
|
47779
|
+
nick: friend.coreInfo.nick,
|
|
47780
|
+
longNick: friend.baseInfo.longNick,
|
|
47781
|
+
remark: friend.coreInfo.remark,
|
|
47782
|
+
qid: friend.baseInfo.qid,
|
|
47783
|
+
age: friend.baseInfo.age,
|
|
47784
|
+
sex: friend.baseInfo.sex,
|
|
47785
|
+
birthdayYear: friend.baseInfo.birthday_year,
|
|
47786
|
+
birthdayMonth: friend.baseInfo.birthday_month,
|
|
47787
|
+
birthdayDay: friend.baseInfo.birthday_day
|
|
47788
|
+
}, {
|
|
47789
|
+
categoryId: category.categoryId,
|
|
47790
|
+
categoryName: category.categroyName,
|
|
47791
|
+
categoryMemberCount: category.categroyMbCount,
|
|
47792
|
+
categorySortId: category.categorySortId
|
|
47793
|
+
})
|
|
47788
47794
|
};
|
|
47789
47795
|
}
|
|
47790
47796
|
async function transformIncomingGroupMessage(ctx, group, member, message) {
|
|
@@ -47855,7 +47861,7 @@ async function transformIncomingSegments(ctx, message) {
|
|
|
47855
47861
|
type: "image",
|
|
47856
47862
|
data: {
|
|
47857
47863
|
resource_id: element.picElement.fileUuid,
|
|
47858
|
-
temp_url: await ctx.ntFileApi.getImageUrl(element.picElement),
|
|
47864
|
+
temp_url: await ctx.ntFileApi.getImageUrl(element.picElement.originImageUrl, element.picElement.md5HexStr),
|
|
47859
47865
|
width: element.picElement.picWidth,
|
|
47860
47866
|
height: element.picElement.picHeight,
|
|
47861
47867
|
summary: element.picElement.summary || "[图片]",
|
|
@@ -47878,7 +47884,7 @@ async function transformIncomingSegments(ctx, message) {
|
|
|
47878
47884
|
type: "video",
|
|
47879
47885
|
data: {
|
|
47880
47886
|
resource_id: element.videoElement.fileUuid,
|
|
47881
|
-
temp_url: await ctx.ntFileApi.
|
|
47887
|
+
temp_url: await ctx.ntFileApi.getVideoUrl(element.videoElement.fileUuid, message.chatType === ChatType.Group),
|
|
47882
47888
|
width: element.videoElement.thumbWidth,
|
|
47883
47889
|
height: element.videoElement.thumbHeight,
|
|
47884
47890
|
duration: element.videoElement.fileTime
|
|
@@ -47922,20 +47928,22 @@ async function transformIncomingSegments(ctx, message) {
|
|
|
47922
47928
|
break;
|
|
47923
47929
|
case ElementType.Ark: {
|
|
47924
47930
|
const { arkElement } = element;
|
|
47925
|
-
const
|
|
47926
|
-
if (
|
|
47927
|
-
|
|
47928
|
-
|
|
47929
|
-
|
|
47930
|
-
|
|
47931
|
-
|
|
47932
|
-
|
|
47933
|
-
|
|
47934
|
-
|
|
47935
|
-
|
|
47931
|
+
const match = arkElement.bytesData.match(/"app"\s*:\s*"([^"]*)"/);
|
|
47932
|
+
if (match?.[1]) if (match[1] === "com.tencent.multimsg") {
|
|
47933
|
+
const data = JSON.parse(arkElement.bytesData);
|
|
47934
|
+
segments.push({
|
|
47935
|
+
type: "forward",
|
|
47936
|
+
data: {
|
|
47937
|
+
forward_id: data.meta.detail.resid,
|
|
47938
|
+
title: data.meta.detail.source,
|
|
47939
|
+
preview: data.meta.detail.news.map((item) => item.text),
|
|
47940
|
+
summary: data.meta.detail.summary
|
|
47941
|
+
}
|
|
47942
|
+
});
|
|
47943
|
+
} else segments.push({
|
|
47936
47944
|
type: "light_app",
|
|
47937
47945
|
data: {
|
|
47938
|
-
app_name:
|
|
47946
|
+
app_name: match[1],
|
|
47939
47947
|
json_payload: arkElement.bytesData
|
|
47940
47948
|
}
|
|
47941
47949
|
});
|
|
@@ -47983,7 +47991,7 @@ async function transformIncomingForwardedMessage(ctx, message) {
|
|
|
47983
47991
|
} else if (serviceType === 48 && (businessType === 11 || businessType === 21)) {
|
|
47984
47992
|
const { msgInfoBody } = Media.MsgInfo.decode(elem.commonElem.pbElem);
|
|
47985
47993
|
const { index } = msgInfoBody[0];
|
|
47986
|
-
const url = await ctx.ntFileApi.
|
|
47994
|
+
const url = await ctx.ntFileApi.getVideoUrl(index.fileUuid, businessType === 21);
|
|
47987
47995
|
segments.push({
|
|
47988
47996
|
type: "video",
|
|
47989
47997
|
data: {
|
|
@@ -48044,7 +48052,7 @@ var SendPrivateMessage = defineApi("send_private_message", SendPrivateMessageInp
|
|
|
48044
48052
|
peerUid: uid,
|
|
48045
48053
|
guildId: ""
|
|
48046
48054
|
};
|
|
48047
|
-
if (!await ctx.ntFriendApi.
|
|
48055
|
+
if (!await ctx.ntFriendApi.isFriend(uid)) {
|
|
48048
48056
|
if ((await ctx.ntMsgApi.getTempChatInfo(100, uid)).tmpChatInfo.groupCode) peer.chatType = 100;
|
|
48049
48057
|
}
|
|
48050
48058
|
const { elements, deleteAfterSentFiles } = await transformOutgoingMessage(ctx, payload.message, uid, false);
|
|
@@ -48076,7 +48084,7 @@ var RecallPrivateMessage = defineApi("recall_private_message", RecallPrivateMess
|
|
|
48076
48084
|
peerUid: uid,
|
|
48077
48085
|
guildId: ""
|
|
48078
48086
|
};
|
|
48079
|
-
if (!await ctx.ntFriendApi.
|
|
48087
|
+
if (!await ctx.ntFriendApi.isFriend(uid)) {
|
|
48080
48088
|
if ((await ctx.ntMsgApi.getTempChatInfo(100, uid)).tmpChatInfo.groupCode) peer.chatType = 100;
|
|
48081
48089
|
}
|
|
48082
48090
|
const msg = await ctx.ntMsgApi.getMsgsBySeqAndCount(peer, payload.message_seq.toString(), 1, true, true);
|
|
@@ -48191,7 +48199,7 @@ var MessageApi = [
|
|
|
48191
48199
|
const rkeyData = await ctx.ntFileApi.rkeyManager.getRkey(true);
|
|
48192
48200
|
const rkey = appid === 1406 ? rkeyData.private_rkey : rkeyData.group_rkey;
|
|
48193
48201
|
return Ok({ url: `${IMAGE_HTTP_HOST_NT}/download?appid=${appid}&fileid=${payload.resource_id}&spec=0${rkey}` });
|
|
48194
|
-
} else if (appid === 1413 || appid === 1415) return Ok({ url: await ctx.ntFileApi.
|
|
48202
|
+
} else if (appid === 1413 || appid === 1415) return Ok({ url: await ctx.ntFileApi.getVideoUrl(payload.resource_id, appid === 1415) });
|
|
48195
48203
|
else {
|
|
48196
48204
|
ctx.logger.warn(`GetResourceTempUrl: not yet supported appid: ${appid}`);
|
|
48197
48205
|
return Ok({ url: "" });
|
|
@@ -48238,34 +48246,30 @@ var FriendApi = [
|
|
|
48238
48246
|
defineApi("delete_friend", DeleteFriendInput, zod_default.object({}), async (ctx, payload) => {
|
|
48239
48247
|
const uid = await ctx.ntUserApi.getUidByUin(payload.user_id.toString());
|
|
48240
48248
|
if (!uid) return Failed(-404, "User not found");
|
|
48241
|
-
|
|
48242
|
-
if (result.result !== 0) return Failed(-500, result.errMsg);
|
|
48249
|
+
await ctx.ntFriendApi.deleteFriend(uid);
|
|
48243
48250
|
return Ok({});
|
|
48244
48251
|
}),
|
|
48245
48252
|
defineApi("get_friend_requests", GetFriendRequestsInput, GetFriendRequestsOutput, async (ctx, payload) => {
|
|
48246
48253
|
if (payload.is_filtered) {
|
|
48247
|
-
const result = await ctx.ntFriendApi.
|
|
48248
|
-
return Ok({ requests: await Promise.all(result.
|
|
48249
|
-
|
|
48250
|
-
|
|
48251
|
-
|
|
48252
|
-
|
|
48253
|
-
|
|
48254
|
-
|
|
48255
|
-
|
|
48256
|
-
|
|
48257
|
-
|
|
48258
|
-
|
|
48259
|
-
};
|
|
48260
|
-
})) });
|
|
48254
|
+
const result = await ctx.ntFriendApi.getDoubtFriendRequests(payload.limit);
|
|
48255
|
+
return Ok({ requests: await Promise.all(result.map(async (e) => ({
|
|
48256
|
+
time: e.timestamp,
|
|
48257
|
+
initiator_id: Number(await ctx.ntUserApi.getUinByUid(e.sourceUid)),
|
|
48258
|
+
initiator_uid: e.sourceUid,
|
|
48259
|
+
target_user_id: Number(selfInfo.uin),
|
|
48260
|
+
target_user_uid: selfInfo.uid,
|
|
48261
|
+
state: "pending",
|
|
48262
|
+
comment: e.comment,
|
|
48263
|
+
via: e.source,
|
|
48264
|
+
is_filtered: true
|
|
48265
|
+
}))) });
|
|
48261
48266
|
} else {
|
|
48262
|
-
|
|
48263
|
-
|
|
48264
|
-
return Ok({ requests: await Promise.all(buddyReqs.map(async (e) => {
|
|
48267
|
+
const result = await ctx.ntFriendApi.getFriendRequests(payload.limit);
|
|
48268
|
+
return Ok({ requests: await Promise.all(result.map(async (e) => {
|
|
48265
48269
|
const friendId = Number(await ctx.ntUserApi.getUinByUid(e.friendUid));
|
|
48266
48270
|
const selfId = Number(selfInfo.uin);
|
|
48267
48271
|
return {
|
|
48268
|
-
time:
|
|
48272
|
+
time: e.timestamp,
|
|
48269
48273
|
initiator_id: e.isInitiator ? selfId : friendId,
|
|
48270
48274
|
initiator_uid: e.isInitiator ? selfInfo.uid : e.friendUid,
|
|
48271
48275
|
target_user_id: e.isInitiator ? friendId : selfId,
|
|
@@ -48273,30 +48277,27 @@ var FriendApi = [
|
|
|
48273
48277
|
state: {
|
|
48274
48278
|
[BuddyReqType.PeerInitiator]: "pending",
|
|
48275
48279
|
[BuddyReqType.MeInitiatorWaitPeerConfirm]: "pending",
|
|
48276
|
-
[BuddyReqType.PeerAgreed]: "accepted",
|
|
48277
48280
|
[BuddyReqType.MeAgreed]: "accepted",
|
|
48281
|
+
[BuddyReqType.MeAgreedAndAdded]: "accepted",
|
|
48282
|
+
[BuddyReqType.PeerAgreed]: "accepted",
|
|
48283
|
+
[BuddyReqType.PeerAgreedAndAdded]: "accepted",
|
|
48278
48284
|
[BuddyReqType.PeerRefused]: "rejected",
|
|
48279
48285
|
[BuddyReqType.MeRefused]: "rejected"
|
|
48280
|
-
}[e.
|
|
48281
|
-
comment: e.
|
|
48282
|
-
via: e.
|
|
48283
|
-
is_filtered:
|
|
48286
|
+
}[e.state] ?? "pending",
|
|
48287
|
+
comment: e.comment,
|
|
48288
|
+
via: e.source,
|
|
48289
|
+
is_filtered: false
|
|
48284
48290
|
};
|
|
48285
48291
|
})) });
|
|
48286
48292
|
}
|
|
48287
48293
|
}),
|
|
48288
48294
|
defineApi("accept_friend_request", AcceptFriendRequestInput, zod_default.object({}), async (ctx, payload) => {
|
|
48289
|
-
|
|
48290
|
-
|
|
48291
|
-
else result = await ctx.ntFriendApi.handleFriendRequest(payload.initiator_uid, "0", true);
|
|
48292
|
-
if (result.result !== 0) return Failed(-500, result.errMsg);
|
|
48295
|
+
if (payload.is_filtered) await ctx.ntFriendApi.approvalDoubtFriendRequest(payload.initiator_uid);
|
|
48296
|
+
else await ctx.ntFriendApi.approvalFriendRequest(payload.initiator_uid, true);
|
|
48293
48297
|
return Ok({});
|
|
48294
48298
|
}),
|
|
48295
48299
|
defineApi("reject_friend_request", RejectFriendRequestInput, zod_default.object({}), async (ctx, payload) => {
|
|
48296
|
-
if (!payload.is_filtered)
|
|
48297
|
-
const result = await ctx.ntFriendApi.handleFriendRequest(payload.initiator_uid, "0", false);
|
|
48298
|
-
if (result.result !== 0) return Failed(-500, result.errMsg);
|
|
48299
|
-
}
|
|
48300
|
+
if (!payload.is_filtered) await ctx.ntFriendApi.approvalFriendRequest(payload.initiator_uid, false);
|
|
48300
48301
|
return Ok({});
|
|
48301
48302
|
})
|
|
48302
48303
|
];
|
|
@@ -52257,16 +52258,14 @@ var Store = class extends Service {
|
|
|
52257
52258
|
uniqueMsgId: "string(64)",
|
|
52258
52259
|
peerUid: "string(24)"
|
|
52259
52260
|
}, { primary: "shortId" });
|
|
52260
|
-
this.ctx.model.extend("
|
|
52261
|
+
this.ctx.model.extend("file", {
|
|
52261
52262
|
fileName: "string",
|
|
52262
52263
|
fileSize: "string",
|
|
52263
52264
|
fileUuid: "string(128)",
|
|
52264
|
-
msgId: "string(24)",
|
|
52265
52265
|
msgTime: "unsigned(10)",
|
|
52266
|
-
peerUid: "string(24)",
|
|
52267
52266
|
chatType: "unsigned",
|
|
52268
|
-
|
|
52269
|
-
|
|
52267
|
+
elementType: "unsigned",
|
|
52268
|
+
md5HexStr: "string(32)"
|
|
52270
52269
|
}, {
|
|
52271
52270
|
primary: "fileUuid",
|
|
52272
52271
|
indexes: ["fileName"]
|
|
@@ -52348,15 +52347,15 @@ var Store = class extends Service {
|
|
|
52348
52347
|
return this.cache.getValue(cacheKey);
|
|
52349
52348
|
}
|
|
52350
52349
|
async addFileCache(data) {
|
|
52351
|
-
const existingFile = await this.ctx.database.get("
|
|
52350
|
+
const existingFile = await this.ctx.database.get("file", { fileUuid: data.fileUuid });
|
|
52352
52351
|
if (existingFile.length) return existingFile;
|
|
52353
|
-
this.ctx.database.upsert("
|
|
52352
|
+
this.ctx.database.upsert("file", [data], "fileUuid").then().catch((e) => this.ctx.logger.error("addFileCache database error:", e));
|
|
52354
52353
|
}
|
|
52355
52354
|
getFileCacheByName(fileName) {
|
|
52356
|
-
return this.ctx.database.get("
|
|
52355
|
+
return this.ctx.database.get("file", { fileName }, { sort: { msgTime: "desc" } });
|
|
52357
52356
|
}
|
|
52358
52357
|
getFileCacheById(fileUuid) {
|
|
52359
|
-
return this.ctx.database.get("
|
|
52358
|
+
return this.ctx.database.get("file", { fileUuid });
|
|
52360
52359
|
}
|
|
52361
52360
|
async addMsgCache(msg) {
|
|
52362
52361
|
const expire = this.config.msgCacheExpire;
|
|
@@ -52652,36 +52651,24 @@ var NTQQFileApi = class extends Service {
|
|
|
52652
52651
|
this.ctx = ctx;
|
|
52653
52652
|
this.rkeyManager = new RkeyManager(ctx, "https://llob.linyuchen.net/rkey");
|
|
52654
52653
|
}
|
|
52655
|
-
async
|
|
52656
|
-
if (isGroup)
|
|
52657
|
-
|
|
52654
|
+
async getVideoUrl(fileUuid, isGroup) {
|
|
52655
|
+
if (isGroup) {
|
|
52656
|
+
const { download } = await this.ctx.pmhq.getGroupVideoUrl(fileUuid);
|
|
52657
|
+
return `https://${download.info.domain}${download.info.urlPath}${download.rKeyParam}`;
|
|
52658
|
+
} else {
|
|
52659
|
+
const { download } = await this.ctx.pmhq.getPrivateVideoUrl(fileUuid);
|
|
52660
|
+
return `https://${download.info.domain}${download.info.urlPath}${download.rKeyParam}`;
|
|
52661
|
+
}
|
|
52658
52662
|
}
|
|
52659
52663
|
async getPttUrl(fileUuid, isGroup) {
|
|
52660
|
-
if (isGroup)
|
|
52661
|
-
|
|
52662
|
-
|
|
52663
|
-
|
|
52664
|
-
|
|
52665
|
-
|
|
52666
|
-
peer,
|
|
52667
|
-
msgId,
|
|
52668
|
-
elementId,
|
|
52669
|
-
0,
|
|
52670
|
-
{
|
|
52671
|
-
downSourceType: 1,
|
|
52672
|
-
triggerType: 0
|
|
52673
|
-
}
|
|
52674
|
-
]);
|
|
52675
|
-
if (data.result !== 0) this.ctx.logger.warn("getVideoUrl", data);
|
|
52676
|
-
return data.urlResult.domainUrl[0]?.url ?? "";
|
|
52677
|
-
} catch (e) {
|
|
52678
|
-
this.ctx.logger.warn("getVideoUrl error", e);
|
|
52679
|
-
return "";
|
|
52664
|
+
if (isGroup) {
|
|
52665
|
+
const { download } = await this.ctx.pmhq.getGroupPttUrl(fileUuid);
|
|
52666
|
+
return `https://${download.info.domain}${download.info.urlPath}${download.rKeyParam}`;
|
|
52667
|
+
} else {
|
|
52668
|
+
const { download } = await this.ctx.pmhq.getPrivatePttUrl(fileUuid);
|
|
52669
|
+
return `https://${download.info.domain}${download.info.urlPath}${download.rKeyParam}`;
|
|
52680
52670
|
}
|
|
52681
52671
|
}
|
|
52682
|
-
async getFileType(filePath) {
|
|
52683
|
-
return await getFileType(filePath);
|
|
52684
|
-
}
|
|
52685
52672
|
async getRichMediaFilePath(md5HexStr, fileName, elementType, elementSubType = 0) {
|
|
52686
52673
|
return await this.ctx.pmhq.invoke(NTMethod.MEDIA_FILE_PATH, [{
|
|
52687
52674
|
md5HexStr,
|
|
@@ -52699,7 +52686,7 @@ var NTQQFileApi = class extends Service {
|
|
|
52699
52686
|
const fileMd5 = await getMd5HexFromFile(filePath);
|
|
52700
52687
|
let fileName = path.basename(filePath);
|
|
52701
52688
|
if (!fileName.includes(".")) {
|
|
52702
|
-
const ext = (await
|
|
52689
|
+
const ext = (await getFileType(filePath))?.ext;
|
|
52703
52690
|
fileName += ext ? "." + ext : "";
|
|
52704
52691
|
}
|
|
52705
52692
|
const mediaPath = await this.getRichMediaFilePath(fileMd5, fileName, elementType, elementSubType);
|
|
@@ -52710,37 +52697,8 @@ var NTQQFileApi = class extends Service {
|
|
|
52710
52697
|
path: mediaPath
|
|
52711
52698
|
};
|
|
52712
52699
|
}
|
|
52713
|
-
async
|
|
52714
|
-
|
|
52715
|
-
else return sourcePath;
|
|
52716
|
-
return (await this.ctx.pmhq.invoke("nodeIKernelMsgService/downloadRichMedia", [{
|
|
52717
|
-
fileModelId: "0",
|
|
52718
|
-
downloadSourceType: 0,
|
|
52719
|
-
triggerType: 1,
|
|
52720
|
-
msgId,
|
|
52721
|
-
chatType,
|
|
52722
|
-
peerUid,
|
|
52723
|
-
elementId,
|
|
52724
|
-
thumbSize: 0,
|
|
52725
|
-
downloadType: 1,
|
|
52726
|
-
filePath: thumbPath
|
|
52727
|
-
}], {
|
|
52728
|
-
resultCmd: ReceiveCmdS.MEDIA_DOWNLOAD_COMPLETE,
|
|
52729
|
-
resultCb: (payload) => payload.msgId === msgId,
|
|
52730
|
-
timeout
|
|
52731
|
-
})).filePath;
|
|
52732
|
-
}
|
|
52733
|
-
async getImageSize(filePath) {
|
|
52734
|
-
const fileType = await getFileType(filePath);
|
|
52735
|
-
const size = await getImageSize(filePath);
|
|
52736
|
-
return {
|
|
52737
|
-
type: fileType.ext,
|
|
52738
|
-
...size
|
|
52739
|
-
};
|
|
52740
|
-
}
|
|
52741
|
-
async getImageUrl(element) {
|
|
52742
|
-
const url = element.originImageUrl;
|
|
52743
|
-
const md5HexStr = element.md5HexStr;
|
|
52700
|
+
async getImageUrl(originImageUrl, md5HexStr) {
|
|
52701
|
+
const url = originImageUrl;
|
|
52744
52702
|
if (url) {
|
|
52745
52703
|
const parsedUrl = new URL(IMAGE_HTTP_HOST + url);
|
|
52746
52704
|
const imageAppid = parsedUrl.searchParams.get("appid");
|
|
@@ -52754,31 +52712,10 @@ var NTQQFileApi = class extends Service {
|
|
|
52754
52712
|
else return IMAGE_HTTP_HOST + url;
|
|
52755
52713
|
} else return `${IMAGE_HTTP_HOST}/gchatpic_new/0/0-0-${md5HexStr.toUpperCase()}/0`;
|
|
52756
52714
|
}
|
|
52757
|
-
async
|
|
52758
|
-
|
|
52759
|
-
|
|
52760
|
-
|
|
52761
|
-
""
|
|
52762
|
-
], {
|
|
52763
|
-
resultCmd: ReceiveCmdS.MEDIA_DOWNLOAD_COMPLETE,
|
|
52764
|
-
resultCb: (payload) => payload.fileModelId === fileModelId,
|
|
52765
|
-
timeout
|
|
52766
|
-
})).filePath;
|
|
52767
|
-
}
|
|
52768
|
-
async ocrImage(path) {
|
|
52769
|
-
return await this.ctx.pmhq.invoke("nodeIKernelNodeMiscService/wantWinScreenOCR", [path], { timeout: 2 * Time.minute });
|
|
52770
|
-
}
|
|
52771
|
-
async uploadRMFileWithoutMsg(filePath, bizType, peerUid) {
|
|
52772
|
-
return await this.ctx.pmhq.invoke("nodeIKernelRichMediaService/uploadRMFileWithoutMsg", [{
|
|
52773
|
-
filePath,
|
|
52774
|
-
bizType,
|
|
52775
|
-
peerUid,
|
|
52776
|
-
useNTV2: true
|
|
52777
|
-
}], {
|
|
52778
|
-
resultCmd: ReceiveCmdS.MEDIA_UPLOAD_COMPLETE,
|
|
52779
|
-
resultCb: (payload) => payload.filePath === filePath,
|
|
52780
|
-
timeout: 20 * Time.second
|
|
52781
|
-
});
|
|
52715
|
+
async ocrImage(imageUrl) {
|
|
52716
|
+
const res = await this.ctx.pmhq.imageOcr(imageUrl);
|
|
52717
|
+
if (res.retCode) throw new Error(res.wording);
|
|
52718
|
+
return res.ocrRspBody;
|
|
52782
52719
|
}
|
|
52783
52720
|
async uploadFlashFile(title, filePaths) {
|
|
52784
52721
|
return await this.ctx.pmhq.invoke("nodeIKernelFlashTransferService/createFlashTransferUploadTask", [(/* @__PURE__ */ new Date()).getTime(), {
|
|
@@ -53111,38 +53048,61 @@ var NTQQFileApi = class extends Service {
|
|
|
53111
53048
|
crcMedia: result.crcMedia
|
|
53112
53049
|
};
|
|
53113
53050
|
}
|
|
53114
|
-
|
|
53115
|
-
|
|
53116
|
-
|
|
53117
|
-
|
|
53118
|
-
|
|
53119
|
-
|
|
53120
|
-
|
|
53121
|
-
|
|
53122
|
-
|
|
53123
|
-
|
|
53124
|
-
|
|
53125
|
-
|
|
53126
|
-
|
|
53127
|
-
|
|
53128
|
-
|
|
53129
|
-
|
|
53130
|
-
|
|
53131
|
-
|
|
53132
|
-
|
|
53133
|
-
|
|
53134
|
-
|
|
53135
|
-
|
|
53136
|
-
|
|
53137
|
-
|
|
53138
|
-
|
|
53139
|
-
|
|
53051
|
+
async uploadGroupImage(groupCode, filePath) {
|
|
53052
|
+
const result = await this.ctx.pmhq.getGroupImageUploadInfo(groupCode, filePath);
|
|
53053
|
+
const highwaySession = await this.ctx.pmhq.getHighwaySession();
|
|
53054
|
+
const maxBlockSize = 1024 * 1024;
|
|
53055
|
+
if (result.ext.uKey) {
|
|
53056
|
+
const { index } = result.ext.msgInfoBody[0];
|
|
53057
|
+
const trans = {
|
|
53058
|
+
uin: selfInfo.uin,
|
|
53059
|
+
cmd: 1004,
|
|
53060
|
+
readable: createReadStream(filePath, { highWaterMark: maxBlockSize }),
|
|
53061
|
+
sum: Buffer.from(index.info.md5HexStr, "hex"),
|
|
53062
|
+
size: index.info.fileSize,
|
|
53063
|
+
ticket: highwaySession.sigSession,
|
|
53064
|
+
ext: Media.NTV2RichMediaHighwayExt.encode(result.ext),
|
|
53065
|
+
server: highwaySession.highwayHostAndPorts[1][0].host,
|
|
53066
|
+
port: highwaySession.highwayHostAndPorts[1][0].port
|
|
53067
|
+
};
|
|
53068
|
+
try {
|
|
53069
|
+
await new HighwayTcpSession(trans).upload();
|
|
53070
|
+
} catch {
|
|
53071
|
+
await new HighwayHttpSession(trans).upload();
|
|
53072
|
+
}
|
|
53073
|
+
}
|
|
53074
|
+
return {
|
|
53075
|
+
msgInfo: result.info,
|
|
53076
|
+
compat: result.compat
|
|
53077
|
+
};
|
|
53140
53078
|
}
|
|
53141
|
-
async
|
|
53142
|
-
|
|
53143
|
-
|
|
53144
|
-
|
|
53145
|
-
|
|
53079
|
+
async uploadC2CImage(peerUid, filePath) {
|
|
53080
|
+
const result = await this.ctx.pmhq.getC2CImageUploadInfo(peerUid, filePath);
|
|
53081
|
+
const highwaySession = await this.ctx.pmhq.getHighwaySession();
|
|
53082
|
+
const maxBlockSize = 1024 * 1024;
|
|
53083
|
+
if (result.ext.uKey) {
|
|
53084
|
+
const { index } = result.ext.msgInfoBody[0];
|
|
53085
|
+
const trans = {
|
|
53086
|
+
uin: selfInfo.uin,
|
|
53087
|
+
cmd: 1003,
|
|
53088
|
+
readable: createReadStream(filePath, { highWaterMark: maxBlockSize }),
|
|
53089
|
+
sum: Buffer.from(index.info.md5HexStr, "hex"),
|
|
53090
|
+
size: index.info.fileSize,
|
|
53091
|
+
ticket: highwaySession.sigSession,
|
|
53092
|
+
ext: Media.NTV2RichMediaHighwayExt.encode(result.ext),
|
|
53093
|
+
server: highwaySession.highwayHostAndPorts[1][0].host,
|
|
53094
|
+
port: highwaySession.highwayHostAndPorts[1][0].port
|
|
53095
|
+
};
|
|
53096
|
+
try {
|
|
53097
|
+
await new HighwayTcpSession(trans).upload();
|
|
53098
|
+
} catch {
|
|
53099
|
+
await new HighwayHttpSession(trans).upload();
|
|
53100
|
+
}
|
|
53101
|
+
}
|
|
53102
|
+
return {
|
|
53103
|
+
msgInfo: result.info,
|
|
53104
|
+
compat: result.compat
|
|
53105
|
+
};
|
|
53146
53106
|
}
|
|
53147
53107
|
};
|
|
53148
53108
|
//#endregion
|
|
@@ -53153,77 +53113,109 @@ var NTQQFriendApi = class extends Service {
|
|
|
53153
53113
|
"ntSystemApi",
|
|
53154
53114
|
"pmhq"
|
|
53155
53115
|
];
|
|
53116
|
+
friendsCache = [];
|
|
53117
|
+
categoriesCache = /* @__PURE__ */ new Map();
|
|
53156
53118
|
constructor(ctx) {
|
|
53157
53119
|
super(ctx, "ntFriendApi");
|
|
53158
53120
|
this.ctx = ctx;
|
|
53159
53121
|
}
|
|
53160
|
-
|
|
53161
|
-
|
|
53162
|
-
|
|
53163
|
-
|
|
53164
|
-
|
|
53165
|
-
|
|
53166
|
-
|
|
53122
|
+
async getFriendList(forceUpdate) {
|
|
53123
|
+
if (forceUpdate || this.friendsCache.length === 0) {
|
|
53124
|
+
const res = await this.ctx.pmhq.fetchFriends();
|
|
53125
|
+
this.friendsCache = res.friendList.map((friend) => {
|
|
53126
|
+
const biz = friend.subBiz.get(1);
|
|
53127
|
+
let statusId = biz.numData.get(27372);
|
|
53128
|
+
if (statusId >= 268435456) statusId -= 268435456;
|
|
53129
|
+
if (statusId > 14878464) statusId -= 14878464;
|
|
53130
|
+
if (statusId === 0) statusId = 2;
|
|
53131
|
+
return {
|
|
53132
|
+
uid: friend.uid,
|
|
53133
|
+
uin: friend.uin,
|
|
53134
|
+
categoryId: friend.categoryId,
|
|
53135
|
+
nick: biz.data.get(20002).toString(),
|
|
53136
|
+
longNick: biz.data.get(102).toString(),
|
|
53137
|
+
remark: biz.data.get(103).toString(),
|
|
53138
|
+
qid: biz.data.get(27394).toString(),
|
|
53139
|
+
age: biz.numData.get(20037),
|
|
53140
|
+
sex: biz.numData.get(20009),
|
|
53141
|
+
birthdayYear: biz.data.get(20031)[0] << 8 | biz.data.get(20031)[1],
|
|
53142
|
+
birthdayMonth: biz.data.get(20031)[2],
|
|
53143
|
+
birthdayDay: biz.data.get(20031)[3],
|
|
53144
|
+
status: statusId * 10
|
|
53145
|
+
};
|
|
53146
|
+
});
|
|
53147
|
+
this.categoriesCache.clear();
|
|
53148
|
+
for (const cat of res.category) this.categoriesCache.set(cat.categoryId, cat);
|
|
53149
|
+
}
|
|
53150
|
+
return {
|
|
53151
|
+
friends: this.friendsCache,
|
|
53152
|
+
categories: this.categoriesCache
|
|
53153
|
+
};
|
|
53167
53154
|
}
|
|
53168
|
-
async
|
|
53169
|
-
|
|
53155
|
+
async getFriendInfoByUin(uin, forceUpdate) {
|
|
53156
|
+
const result = await this.getFriendList(forceUpdate);
|
|
53157
|
+
let categories = result.categories;
|
|
53158
|
+
let friend = result.friends.find((e) => e.uin === uin);
|
|
53159
|
+
if (!friend) {
|
|
53160
|
+
const result = await this.getFriendList(true);
|
|
53161
|
+
categories = result.categories;
|
|
53162
|
+
friend = result.friends.find((e) => e.uin === uin);
|
|
53163
|
+
}
|
|
53164
|
+
if (!friend) return;
|
|
53165
|
+
const category = categories.get(friend.categoryId);
|
|
53166
|
+
return {
|
|
53167
|
+
friend,
|
|
53168
|
+
category
|
|
53169
|
+
};
|
|
53170
53170
|
}
|
|
53171
|
-
async
|
|
53172
|
-
const
|
|
53173
|
-
let result;
|
|
53174
|
-
|
|
53175
|
-
|
|
53176
|
-
|
|
53177
|
-
|
|
53178
|
-
|
|
53179
|
-
|
|
53180
|
-
return
|
|
53171
|
+
async getFriendInfoByUid(uid, forceUpdate) {
|
|
53172
|
+
const result = await this.getFriendList(forceUpdate);
|
|
53173
|
+
let categories = result.categories;
|
|
53174
|
+
let friend = result.friends.find((e) => e.uid === uid);
|
|
53175
|
+
if (!friend) {
|
|
53176
|
+
const result = await this.getFriendList(true);
|
|
53177
|
+
categories = result.categories;
|
|
53178
|
+
friend = result.friends.find((e) => e.uid === uid);
|
|
53179
|
+
}
|
|
53180
|
+
if (!friend) return;
|
|
53181
|
+
const category = categories.get(friend.categoryId);
|
|
53182
|
+
return {
|
|
53183
|
+
friend,
|
|
53184
|
+
category
|
|
53185
|
+
};
|
|
53181
53186
|
}
|
|
53182
|
-
async
|
|
53183
|
-
return await this.
|
|
53187
|
+
async isFriend(uid) {
|
|
53188
|
+
return await this.getFriendInfoByUid(uid, false) !== void 0;
|
|
53184
53189
|
}
|
|
53185
|
-
async
|
|
53186
|
-
|
|
53190
|
+
async getFriendRecommendContactArk(uin) {
|
|
53191
|
+
const { ark } = await this.ctx.pmhq.getFriendRecommendContactArk(uin);
|
|
53192
|
+
return ark;
|
|
53187
53193
|
}
|
|
53188
|
-
async
|
|
53189
|
-
return await this.ctx.pmhq.
|
|
53190
|
-
uid,
|
|
53191
|
-
remark
|
|
53192
|
-
}]);
|
|
53194
|
+
async setFriendRemark(uid, remark = "") {
|
|
53195
|
+
return await this.ctx.pmhq.setFriendRemark(uid, remark);
|
|
53193
53196
|
}
|
|
53194
|
-
async
|
|
53195
|
-
return await this.ctx.pmhq.
|
|
53196
|
-
friendUid,
|
|
53197
|
-
tempBlock: false,
|
|
53198
|
-
tempBothDel: true
|
|
53199
|
-
}]);
|
|
53197
|
+
async deleteFriend(targetUid, block = false, bothDelete = true) {
|
|
53198
|
+
return await this.ctx.pmhq.deleteFriend(targetUid, block, bothDelete);
|
|
53200
53199
|
}
|
|
53201
|
-
async
|
|
53202
|
-
return await this.ctx.pmhq.
|
|
53200
|
+
async setFriendCategory(uid, categoryId) {
|
|
53201
|
+
return await this.ctx.pmhq.setFriendCategory(uid, categoryId);
|
|
53203
53202
|
}
|
|
53204
53203
|
async clearBuddyReqUnreadCnt() {
|
|
53205
53204
|
return await this.ctx.pmhq.invoke("nodeIKernelBuddyService/clearBuddyReqUnreadCnt", []);
|
|
53206
53205
|
}
|
|
53207
|
-
async
|
|
53208
|
-
const
|
|
53209
|
-
return
|
|
53210
|
-
reqId,
|
|
53211
|
-
reqNum,
|
|
53212
|
-
""
|
|
53213
|
-
], {
|
|
53214
|
-
resultCmd: "nodeIKernelBuddyListener/onDoubtBuddyReqChange",
|
|
53215
|
-
resultCb: (payload) => payload.reqId === reqId
|
|
53216
|
-
});
|
|
53206
|
+
async getFriendRequests(limit) {
|
|
53207
|
+
const { info } = await this.ctx.pmhq.fetchFriendRequests(selfInfo.uid, limit);
|
|
53208
|
+
return info.requests;
|
|
53217
53209
|
}
|
|
53218
|
-
async
|
|
53219
|
-
|
|
53220
|
-
|
|
53221
|
-
"",
|
|
53222
|
-
""
|
|
53223
|
-
]);
|
|
53210
|
+
async getDoubtFriendRequests(limit) {
|
|
53211
|
+
const { info } = await this.ctx.pmhq.fetchFilteredFriendRequests(limit);
|
|
53212
|
+
return info.requests;
|
|
53224
53213
|
}
|
|
53225
|
-
async
|
|
53226
|
-
|
|
53214
|
+
async approvalFriendRequest(friendUid, accept) {
|
|
53215
|
+
await this.ctx.pmhq.setFriendRequest(friendUid, accept ? 3 : 5);
|
|
53216
|
+
}
|
|
53217
|
+
async approvalDoubtFriendRequest(requestUid) {
|
|
53218
|
+
return await this.ctx.pmhq.setFilteredFriendRequestReq(selfInfo.uid, requestUid);
|
|
53227
53219
|
}
|
|
53228
53220
|
async getCategoryById(categoryId) {
|
|
53229
53221
|
return await this.ctx.pmhq.invoke("nodeIKernelBuddyService/getCategoryById", [categoryId]);
|
|
@@ -53936,6 +53928,9 @@ var NTQQMsgApi = class extends Service {
|
|
|
53936
53928
|
toUid
|
|
53937
53929
|
]);
|
|
53938
53930
|
}
|
|
53931
|
+
async getPins() {
|
|
53932
|
+
return await this.ctx.pmhq.fetchPins();
|
|
53933
|
+
}
|
|
53939
53934
|
};
|
|
53940
53935
|
//#endregion
|
|
53941
53936
|
//#region src/common/utils/request.ts
|
|
@@ -54351,7 +54346,7 @@ var NTQQWebApi = class extends Service {
|
|
|
54351
54346
|
const iBatchID = Math.floor(Date.now() / 1e3);
|
|
54352
54347
|
for (let i = 0; i < filePathList.length; i++) {
|
|
54353
54348
|
const filePath = filePathList[i];
|
|
54354
|
-
const fileBuffer = await
|
|
54349
|
+
const fileBuffer = await fsPromise.readFile(filePath);
|
|
54355
54350
|
const fileSize = fileBuffer.length;
|
|
54356
54351
|
const fileType = await fileTypeFromBuffer(fileBuffer);
|
|
54357
54352
|
const timestamp = Math.floor(Date.now() / 1e3);
|
|
@@ -54536,7 +54531,7 @@ var NTQQWebApi = class extends Service {
|
|
|
54536
54531
|
}
|
|
54537
54532
|
if (sVid) {
|
|
54538
54533
|
const filePath = await createThumb(this.ctx, filePathList[i]);
|
|
54539
|
-
const fileBuffer = await
|
|
54534
|
+
const fileBuffer = await fsPromise.readFile(filePath);
|
|
54540
54535
|
const fileSize = fileBuffer.length;
|
|
54541
54536
|
const timestamp = Math.floor(Date.now() / 1e3);
|
|
54542
54537
|
const checksum = getMd5HexFromBuffer(fileBuffer);
|
|
@@ -56028,7 +56023,7 @@ var Config = class extends Service {
|
|
|
56028
56023
|
this.logger.info("配置文件位于", this.configPath);
|
|
56029
56024
|
this.config = this.get();
|
|
56030
56025
|
if (this.configPath) {
|
|
56031
|
-
fs$
|
|
56026
|
+
fs$1.watchFile(this.configPath, {
|
|
56032
56027
|
persistent: true,
|
|
56033
56028
|
interval: 1e3
|
|
56034
56029
|
}, () => {
|
|
@@ -56046,7 +56041,7 @@ var Config = class extends Service {
|
|
|
56046
56041
|
}
|
|
56047
56042
|
getDefaultConfig() {
|
|
56048
56043
|
const _defaultConfig = { ...defaultConfig };
|
|
56049
|
-
const defaultConfigFromFile = fs$
|
|
56044
|
+
const defaultConfigFromFile = fs$1.readFileSync(this.defaultConfigPath, "utf-8");
|
|
56050
56045
|
try {
|
|
56051
56046
|
const parsedDefaultConfig = import_dist.default.parse(defaultConfigFromFile);
|
|
56052
56047
|
Object.assign(_defaultConfig, parsedDefaultConfig);
|
|
@@ -56057,12 +56052,12 @@ var Config = class extends Service {
|
|
|
56057
56052
|
}
|
|
56058
56053
|
reloadConfig() {
|
|
56059
56054
|
if (!this.configPath) return this.getDefaultConfig();
|
|
56060
|
-
if (!fs$
|
|
56055
|
+
if (!fs$1.existsSync(this.configPath)) {
|
|
56061
56056
|
this.config = this.getDefaultConfig();
|
|
56062
56057
|
this.set(this.config);
|
|
56063
56058
|
return this.config;
|
|
56064
56059
|
} else {
|
|
56065
|
-
const data = fs$
|
|
56060
|
+
const data = fs$1.readFileSync(this.configPath, "utf-8");
|
|
56066
56061
|
let jsonData = defaultConfig;
|
|
56067
56062
|
try {
|
|
56068
56063
|
jsonData = import_dist.default.parse(data);
|
|
@@ -56088,7 +56083,7 @@ var Config = class extends Service {
|
|
|
56088
56083
|
writeConfig(config) {
|
|
56089
56084
|
if (!this.configPath) return;
|
|
56090
56085
|
this.watch = false;
|
|
56091
|
-
fs$
|
|
56086
|
+
fs$1.writeFileSync(this.configPath, JSON.stringify(config, null, 2), "utf-8");
|
|
56092
56087
|
setTimeout(() => {
|
|
56093
56088
|
this.watch = true;
|
|
56094
56089
|
}, 1500);
|
|
@@ -56194,13 +56189,13 @@ var WebUITokenUtil = class {
|
|
|
56194
56189
|
}
|
|
56195
56190
|
getToken() {
|
|
56196
56191
|
if (!this.token) {
|
|
56197
|
-
if (fs$
|
|
56192
|
+
if (fs$1.existsSync(this.tokenPath)) this.token = fs$1.readFileSync(this.tokenPath, "utf-8").trim();
|
|
56198
56193
|
}
|
|
56199
56194
|
return this.token;
|
|
56200
56195
|
}
|
|
56201
56196
|
setToken(token) {
|
|
56202
56197
|
this.token = token.trim();
|
|
56203
|
-
fs$
|
|
56198
|
+
fs$1.writeFileSync(this.tokenPath, token, "utf-8");
|
|
56204
56199
|
}
|
|
56205
56200
|
};
|
|
56206
56201
|
var webuiTokenUtil = new WebUITokenUtil(path.join(DATA_DIR, "webui_token.txt"));
|
|
@@ -56422,7 +56417,7 @@ function createDashboardRoutes(ctx) {
|
|
|
56422
56417
|
success: false,
|
|
56423
56418
|
message: "服务尚未就绪,请等待登录完成"
|
|
56424
56419
|
}, 503);
|
|
56425
|
-
const friends = await ctx.ntFriendApi.
|
|
56420
|
+
const friends = await ctx.ntFriendApi.getFriendList(false);
|
|
56426
56421
|
const groups = await ctx.ntGroupApi.getGroups(false);
|
|
56427
56422
|
const qqInfo = await ctx.pmhq.getProcessInfo();
|
|
56428
56423
|
const qqMemory = qqInfo?.memory?.rss || 0;
|
|
@@ -56439,7 +56434,7 @@ function createDashboardRoutes(ctx) {
|
|
|
56439
56434
|
return c.json({
|
|
56440
56435
|
success: true,
|
|
56441
56436
|
data: {
|
|
56442
|
-
friendCount: friends.length,
|
|
56437
|
+
friendCount: friends.friends.length,
|
|
56443
56438
|
groupCount: groups.length,
|
|
56444
56439
|
messageReceived: app.messageReceivedCount,
|
|
56445
56440
|
messageSent: app.messageSentCount,
|
|
@@ -57192,20 +57187,20 @@ function createNotificationRoutes(ctx) {
|
|
|
57192
57187
|
});
|
|
57193
57188
|
router.get("/notifications/friend", async (c) => {
|
|
57194
57189
|
try {
|
|
57195
|
-
const buddyReqs = (
|
|
57190
|
+
const buddyReqs = (await ctx.ntFriendApi.getFriendRequests(50)).filter((reqItem) => !reqItem.isInitiator);
|
|
57196
57191
|
const enriched = await Promise.all(buddyReqs.map(async (reqItem) => {
|
|
57197
|
-
const uin =
|
|
57192
|
+
const uin = await ctx.ntUserApi.getUinByUid(reqItem.friendUid).catch(() => "");
|
|
57193
|
+
const nick = await ctx.ntUserApi.getUserSimpleInfo(reqItem.friendUid).then((e) => e.coreInfo.nick).catch(() => "");
|
|
57198
57194
|
return {
|
|
57199
57195
|
friendUid: reqItem.friendUid,
|
|
57200
57196
|
friendUin: uin,
|
|
57201
|
-
friendNick:
|
|
57202
|
-
|
|
57203
|
-
|
|
57204
|
-
|
|
57205
|
-
|
|
57206
|
-
|
|
57207
|
-
|
|
57208
|
-
flag: `${reqItem.friendUid}|${reqItem.reqTime}`
|
|
57197
|
+
friendNick: nick,
|
|
57198
|
+
reqTime: reqItem.timestamp.toString(),
|
|
57199
|
+
extWords: reqItem.comment,
|
|
57200
|
+
isDecide: ![BuddyReqType.PeerInitiator, BuddyReqType.MeInitiatorWaitPeerConfirm].includes(reqItem.state),
|
|
57201
|
+
reqType: reqItem.state,
|
|
57202
|
+
addSource: reqItem.source,
|
|
57203
|
+
flag: reqItem.friendUid
|
|
57209
57204
|
};
|
|
57210
57205
|
}));
|
|
57211
57206
|
return c.json({
|
|
@@ -57223,18 +57218,15 @@ function createNotificationRoutes(ctx) {
|
|
|
57223
57218
|
});
|
|
57224
57219
|
router.get("/notifications/friend/doubt", async (c) => {
|
|
57225
57220
|
try {
|
|
57226
|
-
const enriched = (
|
|
57227
|
-
uid: item.
|
|
57228
|
-
nick: item.
|
|
57229
|
-
|
|
57230
|
-
|
|
57231
|
-
reqTime: item.reqTime,
|
|
57232
|
-
msg: item.msg,
|
|
57221
|
+
const enriched = (await ctx.ntFriendApi.getDoubtFriendRequests(50)).map((item) => ({
|
|
57222
|
+
uid: item.sourceUid,
|
|
57223
|
+
nick: item.sourceNickname,
|
|
57224
|
+
reqTime: item.timestamp.toString(),
|
|
57225
|
+
msg: item.comment,
|
|
57233
57226
|
source: item.source,
|
|
57234
|
-
reason: item.
|
|
57227
|
+
reason: item.warningInfo,
|
|
57235
57228
|
groupCode: item.groupCode,
|
|
57236
|
-
|
|
57237
|
-
flag: `doubt|${item.uid}|${item.reqTime}`
|
|
57229
|
+
flag: item.sourceUid
|
|
57238
57230
|
}));
|
|
57239
57231
|
return c.json({
|
|
57240
57232
|
success: true,
|
|
@@ -57256,7 +57248,7 @@ function createNotificationRoutes(ctx) {
|
|
|
57256
57248
|
success: false,
|
|
57257
57249
|
message: "缺少必要参数"
|
|
57258
57250
|
}, 400);
|
|
57259
|
-
await ctx.ntFriendApi.
|
|
57251
|
+
await ctx.ntFriendApi.approvalDoubtFriendRequest(uid);
|
|
57260
57252
|
return c.json({ success: true });
|
|
57261
57253
|
} catch (e) {
|
|
57262
57254
|
ctx.logger.error("处理被过滤好友申请失败:", e);
|
|
@@ -57293,12 +57285,7 @@ function createNotificationRoutes(ctx) {
|
|
|
57293
57285
|
success: false,
|
|
57294
57286
|
message: "缺少必要参数"
|
|
57295
57287
|
}, 400);
|
|
57296
|
-
|
|
57297
|
-
if (!friendUid) return c.json({
|
|
57298
|
-
success: false,
|
|
57299
|
-
message: "无效的 flag 参数"
|
|
57300
|
-
}, 400);
|
|
57301
|
-
await ctx.ntFriendApi.handleFriendRequest(friendUid, reqTime || "0", action === "approve");
|
|
57288
|
+
await ctx.ntFriendApi.approvalFriendRequest(flag, action === "approve");
|
|
57302
57289
|
return c.json({ success: true });
|
|
57303
57290
|
} catch (e) {
|
|
57304
57291
|
ctx.logger.error("处理好友申请失败:", e);
|
|
@@ -57497,6 +57484,65 @@ function createEmailRoutes(ctx) {
|
|
|
57497
57484
|
return router;
|
|
57498
57485
|
}
|
|
57499
57486
|
//#endregion
|
|
57487
|
+
//#region node_modules/@hono/node-server/dist/utils/stream.mjs
|
|
57488
|
+
var pr54206Applied = () => {
|
|
57489
|
+
const [major, minor] = versions.node.split(".").map((component) => parseInt(component));
|
|
57490
|
+
return major >= 23 || major === 22 && minor >= 7 || major === 20 && minor >= 18;
|
|
57491
|
+
};
|
|
57492
|
+
var useReadableToWeb = pr54206Applied();
|
|
57493
|
+
var createStreamBody = (stream, useNativeReadableToWeb = useReadableToWeb) => {
|
|
57494
|
+
if (useNativeReadableToWeb) return Readable.toWeb(stream);
|
|
57495
|
+
let controller;
|
|
57496
|
+
let settled = false;
|
|
57497
|
+
const cleanup = () => {
|
|
57498
|
+
stream.off("data", onData);
|
|
57499
|
+
stream.off("error", onError);
|
|
57500
|
+
stream.off("end", onTerminate);
|
|
57501
|
+
stream.off("close", onTerminate);
|
|
57502
|
+
};
|
|
57503
|
+
const settle = (callback) => {
|
|
57504
|
+
if (settled) return;
|
|
57505
|
+
settled = true;
|
|
57506
|
+
cleanup();
|
|
57507
|
+
callback?.();
|
|
57508
|
+
};
|
|
57509
|
+
const onData = (chunk) => {
|
|
57510
|
+
if (settled || !controller) return;
|
|
57511
|
+
controller.enqueue(chunk);
|
|
57512
|
+
if ((controller.desiredSize ?? 0) <= 0) stream.pause();
|
|
57513
|
+
};
|
|
57514
|
+
const onError = (error) => {
|
|
57515
|
+
settle(() => {
|
|
57516
|
+
controller?.error(error);
|
|
57517
|
+
});
|
|
57518
|
+
};
|
|
57519
|
+
const onTerminate = () => {
|
|
57520
|
+
settle(() => {
|
|
57521
|
+
controller?.close();
|
|
57522
|
+
});
|
|
57523
|
+
};
|
|
57524
|
+
return new ReadableStream({
|
|
57525
|
+
start(streamController) {
|
|
57526
|
+
controller = streamController;
|
|
57527
|
+
stream.on("data", onData);
|
|
57528
|
+
stream.on("error", onError);
|
|
57529
|
+
stream.on("end", onTerminate);
|
|
57530
|
+
stream.on("close", onTerminate);
|
|
57531
|
+
stream.pause();
|
|
57532
|
+
},
|
|
57533
|
+
pull() {
|
|
57534
|
+
if (!settled) stream.resume();
|
|
57535
|
+
},
|
|
57536
|
+
cancel() {
|
|
57537
|
+
settle();
|
|
57538
|
+
const ignoreError = () => {};
|
|
57539
|
+
stream.on("error", ignoreError);
|
|
57540
|
+
stream.once("close", () => stream.off("error", ignoreError));
|
|
57541
|
+
stream.destroy();
|
|
57542
|
+
}
|
|
57543
|
+
});
|
|
57544
|
+
};
|
|
57545
|
+
//#endregion
|
|
57500
57546
|
//#region node_modules/hono/dist/utils/mime.js
|
|
57501
57547
|
var getMimeType = (filename, mimes = baseMimes) => {
|
|
57502
57548
|
const match = filename.match(/\.([a-zA-Z0-9]+?)$/);
|
|
@@ -57572,30 +57618,6 @@ var ENCODINGS = {
|
|
|
57572
57618
|
gzip: ".gz"
|
|
57573
57619
|
};
|
|
57574
57620
|
var ENCODINGS_ORDERED_KEYS = Object.keys(ENCODINGS);
|
|
57575
|
-
var pr54206Applied = () => {
|
|
57576
|
-
const [major, minor] = versions.node.split(".").map((component) => parseInt(component));
|
|
57577
|
-
return major >= 23 || major === 22 && minor >= 7 || major === 20 && minor >= 18;
|
|
57578
|
-
};
|
|
57579
|
-
var useReadableToWeb = pr54206Applied();
|
|
57580
|
-
var createStreamBody = (stream) => {
|
|
57581
|
-
if (useReadableToWeb) return Readable.toWeb(stream);
|
|
57582
|
-
return new ReadableStream({
|
|
57583
|
-
start(controller) {
|
|
57584
|
-
stream.on("data", (chunk) => {
|
|
57585
|
-
controller.enqueue(chunk);
|
|
57586
|
-
});
|
|
57587
|
-
stream.on("error", (err) => {
|
|
57588
|
-
controller.error(err);
|
|
57589
|
-
});
|
|
57590
|
-
stream.on("end", () => {
|
|
57591
|
-
controller.close();
|
|
57592
|
-
});
|
|
57593
|
-
},
|
|
57594
|
-
cancel() {
|
|
57595
|
-
stream.destroy();
|
|
57596
|
-
}
|
|
57597
|
-
});
|
|
57598
|
-
};
|
|
57599
57621
|
var getStats = (path) => {
|
|
57600
57622
|
let stats;
|
|
57601
57623
|
try {
|
|
@@ -57662,6 +57684,7 @@ var serveStatic = (options = { root: "" }) => {
|
|
|
57662
57684
|
let result;
|
|
57663
57685
|
const size = stats.size;
|
|
57664
57686
|
const range = c.req.header("range") || "";
|
|
57687
|
+
c.header("Last-Modified", stats.mtime.toUTCString());
|
|
57665
57688
|
if (c.req.method == "HEAD" || c.req.method == "OPTIONS") {
|
|
57666
57689
|
c.header("Content-Length", size.toString());
|
|
57667
57690
|
c.status(200);
|
|
@@ -57671,7 +57694,6 @@ var serveStatic = (options = { root: "" }) => {
|
|
|
57671
57694
|
result = c.body(createStreamBody(createReadStream(path)), 200);
|
|
57672
57695
|
} else {
|
|
57673
57696
|
c.header("Accept-Ranges", "bytes");
|
|
57674
|
-
c.header("Date", stats.birthtime.toUTCString());
|
|
57675
57697
|
const parts = range.replace(/bytes=/, "").split("-", 2);
|
|
57676
57698
|
const start = parseInt(parts[0], 10) || 0;
|
|
57677
57699
|
let end = parseInt(parts[1], 10) || size - 1;
|
|
@@ -57844,13 +57866,12 @@ var WebuiServer = class extends Service {
|
|
|
57844
57866
|
friendUid: req.friendUid,
|
|
57845
57867
|
friendUin: uin,
|
|
57846
57868
|
friendNick: req.friendNick,
|
|
57847
|
-
friendAvatarUrl: req.friendAvatarUrl,
|
|
57848
57869
|
reqTime: req.reqTime,
|
|
57849
57870
|
extWords: req.extWords,
|
|
57850
57871
|
isDecide: req.isDecide,
|
|
57851
57872
|
reqType: req.reqType,
|
|
57852
57873
|
addSource: req.addSource || "",
|
|
57853
|
-
flag:
|
|
57874
|
+
flag: req.friendUid
|
|
57854
57875
|
}
|
|
57855
57876
|
});
|
|
57856
57877
|
} catch (e) {
|
|
@@ -58475,7 +58496,7 @@ var require_fetch = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
58475
58496
|
var require_shared = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
58476
58497
|
var urllib$2 = __require("url");
|
|
58477
58498
|
var util$1 = __require("util");
|
|
58478
|
-
var fs$
|
|
58499
|
+
var fs$4 = __require("fs");
|
|
58479
58500
|
var nmfetch = require_fetch();
|
|
58480
58501
|
var dns$1 = __require("dns");
|
|
58481
58502
|
var net$4 = __require("net");
|
|
@@ -58811,7 +58832,7 @@ var require_shared = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
58811
58832
|
const parsedDataUri = module.exports.parseDataURI(content.path || content.href);
|
|
58812
58833
|
if (!parsedDataUri || !parsedDataUri.data) return callback(null, Buffer.from(0));
|
|
58813
58834
|
return callback(null, parsedDataUri.data);
|
|
58814
|
-
} else if (content.path) return resolveStream(fs$
|
|
58835
|
+
} else if (content.path) return resolveStream(fs$4.createReadStream(content.path), callback);
|
|
58815
58836
|
}
|
|
58816
58837
|
if (typeof data[key].content === "string" && ![
|
|
58817
58838
|
"utf8",
|
|
@@ -62751,7 +62772,7 @@ var require_le_unix = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
62751
62772
|
//#region node_modules/nodemailer/lib/mime-node/index.js
|
|
62752
62773
|
var require_mime_node = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
62753
62774
|
var crypto$8 = __require("crypto");
|
|
62754
|
-
var fs$
|
|
62775
|
+
var fs$3 = __require("fs");
|
|
62755
62776
|
var punycode = require_punycode();
|
|
62756
62777
|
var { PassThrough: PassThrough$2 } = __require("stream");
|
|
62757
62778
|
var shared = require_shared();
|
|
@@ -63460,7 +63481,7 @@ var require_mime_node = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
63460
63481
|
});
|
|
63461
63482
|
return contentStream;
|
|
63462
63483
|
}
|
|
63463
|
-
return fs$
|
|
63484
|
+
return fs$3.createReadStream(content.path);
|
|
63464
63485
|
}
|
|
63465
63486
|
if (content && typeof content.href === "string") {
|
|
63466
63487
|
if (this.disableUrlAccess) {
|
|
@@ -64299,7 +64320,7 @@ var require_dkim = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
64299
64320
|
var RelaxedBody = require_relaxed_body();
|
|
64300
64321
|
var sign = require_sign();
|
|
64301
64322
|
var { PassThrough: PassThrough$1 } = __require("stream");
|
|
64302
|
-
var fs$
|
|
64323
|
+
var fs$2 = __require("fs");
|
|
64303
64324
|
var path$2 = __require("path");
|
|
64304
64325
|
var crypto$5 = __require("crypto");
|
|
64305
64326
|
var DKIM_ALGO = "sha256";
|
|
@@ -64332,10 +64353,10 @@ var require_dkim = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
64332
64353
|
}
|
|
64333
64354
|
cleanup() {
|
|
64334
64355
|
if (!this.cache || !this.cachePath) return;
|
|
64335
|
-
fs$
|
|
64356
|
+
fs$2.unlink(this.cachePath, () => false);
|
|
64336
64357
|
}
|
|
64337
64358
|
createReadCache() {
|
|
64338
|
-
this.cache = fs$
|
|
64359
|
+
this.cache = fs$2.createReadStream(this.cachePath);
|
|
64339
64360
|
this.cache.once("error", (err) => {
|
|
64340
64361
|
this.cleanup();
|
|
64341
64362
|
this.output.emit("error", err);
|
|
@@ -64381,7 +64402,7 @@ var require_dkim = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
64381
64402
|
}
|
|
64382
64403
|
createWriteCache() {
|
|
64383
64404
|
this.output.usingCache = true;
|
|
64384
|
-
this.cache = fs$
|
|
64405
|
+
this.cache = fs$2.createWriteStream(this.cachePath);
|
|
64385
64406
|
this.cache.once("error", (err) => {
|
|
64386
64407
|
this.cleanup();
|
|
64387
64408
|
this.relaxedBody.unpipe(this.cache);
|
|
@@ -69662,6 +69683,153 @@ function FriendMixin(Base) {
|
|
|
69662
69683
|
url: `https://${download.downloadDns}/ftn_handler/${download.downloadUrl.toString("hex")}/?fname=${encodeURIComponent(fileName)}`
|
|
69663
69684
|
};
|
|
69664
69685
|
}
|
|
69686
|
+
async setFriendRequest(targetUid, accept) {
|
|
69687
|
+
const body = Oidb.SetFriendRequestReq.encode({
|
|
69688
|
+
targetUid,
|
|
69689
|
+
accept
|
|
69690
|
+
});
|
|
69691
|
+
const data = Oidb.Base.encode({
|
|
69692
|
+
command: 2909,
|
|
69693
|
+
subCommand: 44,
|
|
69694
|
+
body
|
|
69695
|
+
});
|
|
69696
|
+
await this.httpSendPB("OidbSvcTrpcTcp.0xb5d_44", data);
|
|
69697
|
+
}
|
|
69698
|
+
async setFilteredFriendRequestReq(selfUid, requestUid) {
|
|
69699
|
+
const body = Oidb.SetFilteredFriendRequestReq.encode({
|
|
69700
|
+
selfUid,
|
|
69701
|
+
requestUid
|
|
69702
|
+
});
|
|
69703
|
+
const data = Oidb.Base.encode({
|
|
69704
|
+
command: 3442,
|
|
69705
|
+
subCommand: 0,
|
|
69706
|
+
body
|
|
69707
|
+
});
|
|
69708
|
+
await this.httpSendPB("OidbSvcTrpcTcp.0xd72_0", data);
|
|
69709
|
+
}
|
|
69710
|
+
async fetchFriends() {
|
|
69711
|
+
const body = Oidb.IncPullReq.encode({
|
|
69712
|
+
reqCount: 500,
|
|
69713
|
+
flag: 1,
|
|
69714
|
+
requestBiz: [{
|
|
69715
|
+
bizType: 1,
|
|
69716
|
+
bizData: { extBusi: [
|
|
69717
|
+
102,
|
|
69718
|
+
103,
|
|
69719
|
+
20002,
|
|
69720
|
+
20009,
|
|
69721
|
+
20031,
|
|
69722
|
+
20037,
|
|
69723
|
+
27372,
|
|
69724
|
+
27394
|
|
69725
|
+
] }
|
|
69726
|
+
}]
|
|
69727
|
+
});
|
|
69728
|
+
const data = Oidb.Base.encode({
|
|
69729
|
+
command: 4052,
|
|
69730
|
+
subCommand: 1,
|
|
69731
|
+
body
|
|
69732
|
+
});
|
|
69733
|
+
const res = await this.httpSendPB("OidbSvcTrpcTcp.0xfd4_1", data);
|
|
69734
|
+
const oidbRespBody = Oidb.Base.decode(Buffer.from(res.pb, "hex")).body;
|
|
69735
|
+
return Oidb.IncPullResp.decode(oidbRespBody);
|
|
69736
|
+
}
|
|
69737
|
+
async getFriendRecommendContactArk(uin) {
|
|
69738
|
+
const body = Oidb.GetFriendRecommendContactArkReq.encode({
|
|
69739
|
+
uin,
|
|
69740
|
+
phoneNumber: "-",
|
|
69741
|
+
jumpUrl: `mqqapi://card/show_pslcard?src_type=internal&source=sharecard&version=1&uin=${uin}`
|
|
69742
|
+
});
|
|
69743
|
+
const data = Oidb.Base.encode({
|
|
69744
|
+
command: 4790,
|
|
69745
|
+
subCommand: 0,
|
|
69746
|
+
body
|
|
69747
|
+
});
|
|
69748
|
+
const res = await this.httpSendPB("OidbSvcTrpcTcp.0x12b6_0", data);
|
|
69749
|
+
const oidbRespBody = Oidb.Base.decode(Buffer.from(res.pb, "hex")).body;
|
|
69750
|
+
return Oidb.GetFriendRecommendContactArkResp.decode(oidbRespBody);
|
|
69751
|
+
}
|
|
69752
|
+
async setFriendRemark(uid, remark) {
|
|
69753
|
+
const body = Oidb.SetFriendRemarkReq.encode({
|
|
69754
|
+
uid,
|
|
69755
|
+
remark
|
|
69756
|
+
});
|
|
69757
|
+
const data = Oidb.Base.encode({
|
|
69758
|
+
command: 4300,
|
|
69759
|
+
subCommand: 1,
|
|
69760
|
+
body
|
|
69761
|
+
});
|
|
69762
|
+
await this.httpSendPB("OidbSvcTrpcTcp.0x10cc_1", data);
|
|
69763
|
+
}
|
|
69764
|
+
async deleteFriend(targetUid, block, bothDelete) {
|
|
69765
|
+
const body = Oidb.DeleteFriendReq.encode({ field1: {
|
|
69766
|
+
targetUid,
|
|
69767
|
+
field2: {
|
|
69768
|
+
field1: 130,
|
|
69769
|
+
field2: 109,
|
|
69770
|
+
field3: {
|
|
69771
|
+
field1: 8,
|
|
69772
|
+
field2: 8,
|
|
69773
|
+
field3: 50
|
|
69774
|
+
}
|
|
69775
|
+
},
|
|
69776
|
+
block,
|
|
69777
|
+
bothDelete
|
|
69778
|
+
} });
|
|
69779
|
+
const data = Oidb.Base.encode({
|
|
69780
|
+
command: 4715,
|
|
69781
|
+
subCommand: 0,
|
|
69782
|
+
body
|
|
69783
|
+
});
|
|
69784
|
+
await this.httpSendPB("OidbSvcTrpcTcp.0x126b_0", data);
|
|
69785
|
+
}
|
|
69786
|
+
async setFriendCategory(uid, categoryId) {
|
|
69787
|
+
const body = Oidb.SetFriendCategoryReq.encode({
|
|
69788
|
+
uid,
|
|
69789
|
+
categoryId
|
|
69790
|
+
});
|
|
69791
|
+
const data = Oidb.Base.encode({
|
|
69792
|
+
command: 4331,
|
|
69793
|
+
subCommand: 1,
|
|
69794
|
+
body
|
|
69795
|
+
});
|
|
69796
|
+
await this.httpSendPB("OidbSvcTrpcTcp.0x10eb_1", data);
|
|
69797
|
+
}
|
|
69798
|
+
async fetchFriendRequests(selfUid, reqNum) {
|
|
69799
|
+
const body = Oidb.FetchFriendRequestsReq.encode({
|
|
69800
|
+
version: 1,
|
|
69801
|
+
type: 6,
|
|
69802
|
+
selfUid,
|
|
69803
|
+
startIndex: 0,
|
|
69804
|
+
reqNum,
|
|
69805
|
+
getFlag: 2,
|
|
69806
|
+
startTime: 0,
|
|
69807
|
+
needCommFriend: 1,
|
|
69808
|
+
field22: 1
|
|
69809
|
+
});
|
|
69810
|
+
const data = Oidb.Base.encode({
|
|
69811
|
+
command: 1487,
|
|
69812
|
+
subCommand: 11,
|
|
69813
|
+
body
|
|
69814
|
+
});
|
|
69815
|
+
const res = await this.httpSendPB("OidbSvcTrpcTcp.0x5cf_11", data);
|
|
69816
|
+
const oidbRespBody = Oidb.Base.decode(Buffer.from(res.pb, "hex")).body;
|
|
69817
|
+
return Oidb.FetchFriendRequestsResp.decode(oidbRespBody);
|
|
69818
|
+
}
|
|
69819
|
+
async fetchFilteredFriendRequests(count) {
|
|
69820
|
+
const body = Oidb.FetchFilteredFriendRequestsReq.encode({
|
|
69821
|
+
field1: 1,
|
|
69822
|
+
field2: { count }
|
|
69823
|
+
});
|
|
69824
|
+
const data = Oidb.Base.encode({
|
|
69825
|
+
command: 3433,
|
|
69826
|
+
subCommand: 0,
|
|
69827
|
+
body
|
|
69828
|
+
});
|
|
69829
|
+
const res = await this.httpSendPB("OidbSvcTrpcTcp.0xd69_0", data);
|
|
69830
|
+
const oidbRespBody = Oidb.Base.decode(Buffer.from(res.pb, "hex")).body;
|
|
69831
|
+
return Oidb.FetchFilteredFriendRequestsResp.decode(oidbRespBody);
|
|
69832
|
+
}
|
|
69665
69833
|
};
|
|
69666
69834
|
}
|
|
69667
69835
|
//#endregion
|
|
@@ -69873,7 +70041,7 @@ var NTV2RichMedia;
|
|
|
69873
70041
|
network: convertIPv4(subFileInfo.ipv4s),
|
|
69874
70042
|
msgInfoBody: upload.msgInfo.msgInfoBody,
|
|
69875
70043
|
blockSize,
|
|
69876
|
-
hash: { fileSha1: [] }
|
|
70044
|
+
hash: { fileSha1: [Buffer.alloc(0)] }
|
|
69877
70045
|
};
|
|
69878
70046
|
else return {
|
|
69879
70047
|
fileUuid: index.fileUuid,
|
|
@@ -69881,7 +70049,7 @@ var NTV2RichMedia;
|
|
|
69881
70049
|
network: convertIPv4(upload.ipv4s),
|
|
69882
70050
|
msgInfoBody: upload.msgInfo.msgInfoBody,
|
|
69883
70051
|
blockSize,
|
|
69884
|
-
hash: { fileSha1: [] }
|
|
70052
|
+
hash: { fileSha1: [Buffer.alloc(0)] }
|
|
69885
70053
|
};
|
|
69886
70054
|
}
|
|
69887
70055
|
_NTV2RichMedia.generateExt = generateExt;
|
|
@@ -70001,8 +70169,7 @@ function MediaMixin(Base) {
|
|
|
70001
70169
|
});
|
|
70002
70170
|
const res = await this.httpSendPB("OidbSvcTrpcTcp.0x126d_200", data);
|
|
70003
70171
|
const oidbRespBody = Oidb.Base.decode(Buffer.from(res.pb, "hex")).body;
|
|
70004
|
-
|
|
70005
|
-
return `https://${download?.info?.domain}${download?.info?.urlPath}${download?.rKeyParam}`;
|
|
70172
|
+
return Media.NTV2RichMediaResp.decode(oidbRespBody);
|
|
70006
70173
|
}
|
|
70007
70174
|
async getGroupPttUrl(fileUuid) {
|
|
70008
70175
|
const body = Media.NTV2RichMediaReq.encode({
|
|
@@ -70035,8 +70202,7 @@ function MediaMixin(Base) {
|
|
|
70035
70202
|
});
|
|
70036
70203
|
const res = await this.httpSendPB("OidbSvcTrpcTcp.0x126e_200", data);
|
|
70037
70204
|
const oidbRespBody = Oidb.Base.decode(Buffer.from(res.pb, "hex")).body;
|
|
70038
|
-
|
|
70039
|
-
return `https://${download.info.domain}${download.info.urlPath}${download.rKeyParam}`;
|
|
70205
|
+
return Media.NTV2RichMediaResp.decode(oidbRespBody);
|
|
70040
70206
|
}
|
|
70041
70207
|
async getGroupVideoUrl(fileUuid) {
|
|
70042
70208
|
const body = Media.NTV2RichMediaReq.encode({
|
|
@@ -70069,8 +70235,7 @@ function MediaMixin(Base) {
|
|
|
70069
70235
|
});
|
|
70070
70236
|
const res = await this.httpSendPB("OidbSvcTrpcTcp.0x11ea_200", data);
|
|
70071
70237
|
const oidbRespBody = Oidb.Base.decode(Buffer.from(res.pb, "hex")).body;
|
|
70072
|
-
|
|
70073
|
-
return `https://${download.info.domain}${download.info.urlPath}${download.rKeyParam}`;
|
|
70238
|
+
return Media.NTV2RichMediaResp.decode(oidbRespBody);
|
|
70074
70239
|
}
|
|
70075
70240
|
async getPrivateVideoUrl(fileUuid) {
|
|
70076
70241
|
const body = Media.NTV2RichMediaReq.encode({
|
|
@@ -70106,8 +70271,7 @@ function MediaMixin(Base) {
|
|
|
70106
70271
|
});
|
|
70107
70272
|
const res = await this.httpSendPB("OidbSvcTrpcTcp.0x11e9_200", data);
|
|
70108
70273
|
const oidbRespBody = Oidb.Base.decode(Buffer.from(res.pb, "hex")).body;
|
|
70109
|
-
|
|
70110
|
-
return `https://${download.info.domain}${download.info.urlPath}${download.rKeyParam}`;
|
|
70274
|
+
return Media.NTV2RichMediaResp.decode(oidbRespBody);
|
|
70111
70275
|
}
|
|
70112
70276
|
async getHighwaySession() {
|
|
70113
70277
|
const data = Media.HighwaySessionReq.encode({ reqBody: {
|
|
@@ -70291,6 +70455,152 @@ function MediaMixin(Base) {
|
|
|
70291
70455
|
sha3CheckSum
|
|
70292
70456
|
};
|
|
70293
70457
|
}
|
|
70458
|
+
async getGroupImageUploadInfo(groupCode, filePath) {
|
|
70459
|
+
const peer = {
|
|
70460
|
+
chatType: ChatType.Group,
|
|
70461
|
+
peerUid: groupCode,
|
|
70462
|
+
guildId: ""
|
|
70463
|
+
};
|
|
70464
|
+
const body = await NTV2RichMedia.buildUploadReq(peer, {
|
|
70465
|
+
type: "image",
|
|
70466
|
+
filePath
|
|
70467
|
+
}, { pic: {
|
|
70468
|
+
summary: "[图片]",
|
|
70469
|
+
bytesPbReserveC2c: Buffer.from([
|
|
70470
|
+
8,
|
|
70471
|
+
0,
|
|
70472
|
+
24,
|
|
70473
|
+
0,
|
|
70474
|
+
32,
|
|
70475
|
+
0,
|
|
70476
|
+
74,
|
|
70477
|
+
0,
|
|
70478
|
+
80,
|
|
70479
|
+
0,
|
|
70480
|
+
98,
|
|
70481
|
+
0,
|
|
70482
|
+
146,
|
|
70483
|
+
1,
|
|
70484
|
+
0,
|
|
70485
|
+
154,
|
|
70486
|
+
1,
|
|
70487
|
+
0,
|
|
70488
|
+
170,
|
|
70489
|
+
1,
|
|
70490
|
+
12,
|
|
70491
|
+
8,
|
|
70492
|
+
0,
|
|
70493
|
+
18,
|
|
70494
|
+
0,
|
|
70495
|
+
24,
|
|
70496
|
+
0,
|
|
70497
|
+
32,
|
|
70498
|
+
0,
|
|
70499
|
+
40,
|
|
70500
|
+
0,
|
|
70501
|
+
58,
|
|
70502
|
+
0
|
|
70503
|
+
])
|
|
70504
|
+
} });
|
|
70505
|
+
const data = Oidb.Base.encode({
|
|
70506
|
+
command: 4548,
|
|
70507
|
+
subCommand: 100,
|
|
70508
|
+
body
|
|
70509
|
+
});
|
|
70510
|
+
const res = await this.httpSendPB("OidbSvcTrpcTcp.0x11c4_100", data);
|
|
70511
|
+
const oidbRespBody = Oidb.Base.decode(Buffer.from(res.pb, "hex")).body;
|
|
70512
|
+
const { upload } = Media.NTV2RichMediaResp.decode(oidbRespBody);
|
|
70513
|
+
return {
|
|
70514
|
+
info: upload.msgInfo,
|
|
70515
|
+
compat: upload.compatQMsg,
|
|
70516
|
+
ext: NTV2RichMedia.generateExt(upload)
|
|
70517
|
+
};
|
|
70518
|
+
}
|
|
70519
|
+
async getC2CImageUploadInfo(peerUid, filePath) {
|
|
70520
|
+
const peer = {
|
|
70521
|
+
chatType: ChatType.C2C,
|
|
70522
|
+
peerUid,
|
|
70523
|
+
guildId: ""
|
|
70524
|
+
};
|
|
70525
|
+
const body = await NTV2RichMedia.buildUploadReq(peer, {
|
|
70526
|
+
type: "image",
|
|
70527
|
+
filePath
|
|
70528
|
+
}, { pic: {
|
|
70529
|
+
summary: "[图片]",
|
|
70530
|
+
bytesPbReserveC2c: Buffer.from([
|
|
70531
|
+
8,
|
|
70532
|
+
0,
|
|
70533
|
+
24,
|
|
70534
|
+
0,
|
|
70535
|
+
32,
|
|
70536
|
+
0,
|
|
70537
|
+
74,
|
|
70538
|
+
0,
|
|
70539
|
+
80,
|
|
70540
|
+
0,
|
|
70541
|
+
98,
|
|
70542
|
+
0,
|
|
70543
|
+
146,
|
|
70544
|
+
1,
|
|
70545
|
+
0,
|
|
70546
|
+
154,
|
|
70547
|
+
1,
|
|
70548
|
+
0,
|
|
70549
|
+
170,
|
|
70550
|
+
1,
|
|
70551
|
+
12,
|
|
70552
|
+
8,
|
|
70553
|
+
0,
|
|
70554
|
+
18,
|
|
70555
|
+
0,
|
|
70556
|
+
24,
|
|
70557
|
+
0,
|
|
70558
|
+
32,
|
|
70559
|
+
0,
|
|
70560
|
+
40,
|
|
70561
|
+
0,
|
|
70562
|
+
58,
|
|
70563
|
+
0
|
|
70564
|
+
])
|
|
70565
|
+
} });
|
|
70566
|
+
const data = Oidb.Base.encode({
|
|
70567
|
+
command: 4549,
|
|
70568
|
+
subCommand: 100,
|
|
70569
|
+
body
|
|
70570
|
+
});
|
|
70571
|
+
const res = await this.httpSendPB("OidbSvcTrpcTcp.0x11c5_100", data);
|
|
70572
|
+
const oidbRespBody = Oidb.Base.decode(Buffer.from(res.pb, "hex")).body;
|
|
70573
|
+
const { upload } = Media.NTV2RichMediaResp.decode(oidbRespBody);
|
|
70574
|
+
return {
|
|
70575
|
+
info: upload.msgInfo,
|
|
70576
|
+
compat: upload.compatQMsg,
|
|
70577
|
+
ext: NTV2RichMedia.generateExt(upload)
|
|
70578
|
+
};
|
|
70579
|
+
}
|
|
70580
|
+
async imageOcr(imageUrl) {
|
|
70581
|
+
const body = Oidb.ImageOcrReq.encode({
|
|
70582
|
+
version: 1,
|
|
70583
|
+
client: 0,
|
|
70584
|
+
entrance: 1,
|
|
70585
|
+
ocrReqBody: {
|
|
70586
|
+
imageUrl,
|
|
70587
|
+
originMd5: "",
|
|
70588
|
+
afterCompressMd5: "",
|
|
70589
|
+
afterCompressFileSize: "",
|
|
70590
|
+
afterCompressWeight: "",
|
|
70591
|
+
afterCompressHeight: "",
|
|
70592
|
+
isCut: false
|
|
70593
|
+
}
|
|
70594
|
+
});
|
|
70595
|
+
const data = Oidb.Base.encode({
|
|
70596
|
+
command: 3591,
|
|
70597
|
+
subCommand: 0,
|
|
70598
|
+
body
|
|
70599
|
+
});
|
|
70600
|
+
const res = await this.httpSendPB("OidbSvcTrpcTcp.0xe07_0", data);
|
|
70601
|
+
const oidbRespBody = Oidb.Base.decode(Buffer.from(res.pb, "hex")).body;
|
|
70602
|
+
return Oidb.ImageOcrResp.decode(oidbRespBody);
|
|
70603
|
+
}
|
|
70294
70604
|
};
|
|
70295
70605
|
}
|
|
70296
70606
|
//#endregion
|
|
@@ -70455,6 +70765,22 @@ function UserMixin(Base) {
|
|
|
70455
70765
|
};
|
|
70456
70766
|
}
|
|
70457
70767
|
//#endregion
|
|
70768
|
+
//#region src/main/pmhq/mixins/system.ts
|
|
70769
|
+
function SystemMixin(Base) {
|
|
70770
|
+
return class extends Base {
|
|
70771
|
+
async fetchPins() {
|
|
70772
|
+
const data = Oidb.Base.encode({
|
|
70773
|
+
command: 4787,
|
|
70774
|
+
subCommand: 0,
|
|
70775
|
+
body: Buffer.alloc(0)
|
|
70776
|
+
});
|
|
70777
|
+
const res = await this.httpSendPB("OidbSvcTrpcTcp.0x12b3_0", data);
|
|
70778
|
+
const oidbRespBody = Oidb.Base.decode(Buffer.from(res.pb, "hex")).body;
|
|
70779
|
+
return Oidb.FetchPinsResp.decode(oidbRespBody);
|
|
70780
|
+
}
|
|
70781
|
+
};
|
|
70782
|
+
}
|
|
70783
|
+
//#endregion
|
|
70458
70784
|
//#region src/main/pmhq/index.ts
|
|
70459
70785
|
function applyMixins(Base, mixins) {
|
|
70460
70786
|
return mixins.reduce((acc, mixin) => mixin(acc), Base);
|
|
@@ -70464,7 +70790,8 @@ var PMHQ = applyMixins(PMHQBase, [
|
|
|
70464
70790
|
FriendMixin,
|
|
70465
70791
|
MediaMixin,
|
|
70466
70792
|
MessageMixin,
|
|
70467
|
-
UserMixin
|
|
70793
|
+
UserMixin,
|
|
70794
|
+
SystemMixin
|
|
70468
70795
|
]);
|
|
70469
70796
|
//#endregion
|
|
70470
70797
|
//#region node_modules/@cordisjs/plugin-timer/lib/index.js
|
|
@@ -70613,7 +70940,6 @@ async function onLoad() {
|
|
|
70613
70940
|
ctx.plugin(Config);
|
|
70614
70941
|
ctx.plugin(PMHQ);
|
|
70615
70942
|
ctx.plugin(NTQQFileApi);
|
|
70616
|
-
ctx.plugin(NTQQFileCacheApi);
|
|
70617
70943
|
ctx.plugin(NTQQFriendApi);
|
|
70618
70944
|
ctx.plugin(NTQQGroupApi);
|
|
70619
70945
|
ctx.plugin(NTLoginApi);
|