@luckylillia-dev/plugin-milky 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +36 -24
- package/lib/index.js.map +3 -3
- package/package.json +10 -2
package/lib/index.js
CHANGED
|
@@ -27258,7 +27258,7 @@ var MilkyWebhookHandler = class {
|
|
|
27258
27258
|
// package.json
|
|
27259
27259
|
var package_default = {
|
|
27260
27260
|
name: "@luckylillia-dev/plugin-milky",
|
|
27261
|
-
version: "1.0.
|
|
27261
|
+
version: "1.0.1",
|
|
27262
27262
|
type: "module",
|
|
27263
27263
|
description: "Milky protocol adapter for LuckyLillia NTQQ",
|
|
27264
27264
|
main: "./lib/index.js",
|
|
@@ -27368,14 +27368,22 @@ var package_default = {
|
|
|
27368
27368
|
ntWebApi: "NTQQ Web \u63A5\u53E3"
|
|
27369
27369
|
}
|
|
27370
27370
|
},
|
|
27371
|
-
webui: "./lib/client/index.js"
|
|
27371
|
+
webui: "./lib/client/index.js",
|
|
27372
|
+
launch: [
|
|
27373
|
+
{ field: "http.host", arg: "--milky-host", env: "MILKY_HOST" },
|
|
27374
|
+
{ field: "http.port", arg: "--milky-port", env: "MILKY_PORT" },
|
|
27375
|
+
{ field: "http.prefix", arg: "--milky-prefix", env: "MILKY_PREFIX" },
|
|
27376
|
+
{ field: "http.accessToken", arg: "--milky-token", env: "MILKY_TOKEN" },
|
|
27377
|
+
{ field: "webhook.urls", arg: "--milky-webhook-url", env: "MILKY_WEBHOOK_URL" },
|
|
27378
|
+
{ field: "webhook.accessToken", arg: "--milky-webhook-token", env: "MILKY_WEBHOOK_TOKEN" }
|
|
27379
|
+
]
|
|
27372
27380
|
}
|
|
27373
27381
|
};
|
|
27374
27382
|
|
|
27375
27383
|
// src/version.ts
|
|
27376
27384
|
var version2 = package_default.version;
|
|
27377
27385
|
|
|
27378
|
-
// _integration/ntqq/lib/chunk-
|
|
27386
|
+
// _integration/ntqq/lib/chunk-ZRREWJ3L.js
|
|
27379
27387
|
import path from "node:path";
|
|
27380
27388
|
import { defaultFormatters } from "cordis";
|
|
27381
27389
|
|
|
@@ -28346,11 +28354,11 @@ function hasBuffer() {
|
|
|
28346
28354
|
}
|
|
28347
28355
|
if (!hasBuffer()) throw new Error("Buffer is not available in this environment. TypeProto requires Buffer API support.");
|
|
28348
28356
|
|
|
28349
|
-
// _integration/ntqq/lib/chunk-
|
|
28357
|
+
// _integration/ntqq/lib/chunk-ZRREWJ3L.js
|
|
28350
28358
|
import pathLib from "node:path";
|
|
28351
28359
|
import { stat, copyFile, unlink, mkdir } from "node:fs/promises";
|
|
28352
|
-
import
|
|
28353
|
-
import * as
|
|
28360
|
+
import fs3 from "node:fs";
|
|
28361
|
+
import * as fs2 from "node:fs";
|
|
28354
28362
|
import * as path2 from "node:path";
|
|
28355
28363
|
import { randomUUID, createHash } from "node:crypto";
|
|
28356
28364
|
import path4 from "node:path";
|
|
@@ -28362,11 +28370,15 @@ import { randomUUID as randomUUID3 } from "node:crypto";
|
|
|
28362
28370
|
import { isNullable, noop } from "cosmokit";
|
|
28363
28371
|
import { isNonNullable } from "cosmokit";
|
|
28364
28372
|
import { defineProperty } from "cosmokit";
|
|
28373
|
+
var PLUGIN_DATA_KEY = "@luckylillia-dev+plugin-nt-protocol";
|
|
28365
28374
|
var DATA_DIR = path.resolve("data");
|
|
28366
|
-
var TEMP_DIR = path.join(DATA_DIR, "temp");
|
|
28367
28375
|
var LOG_DIR = path.join(DATA_DIR, "logs");
|
|
28368
|
-
var dbDir = path.join(DATA_DIR, "database");
|
|
28369
28376
|
var STATE_DIR = path.join(DATA_DIR, "state");
|
|
28377
|
+
var hostDataDir = path.join(DATA_DIR, "plugin-data", PLUGIN_DATA_KEY);
|
|
28378
|
+
var tempDir = path.join(hostDataDir, "temp");
|
|
28379
|
+
function getTempDir() {
|
|
28380
|
+
return tempDir;
|
|
28381
|
+
}
|
|
28370
28382
|
defaultFormatters.h = (value) => Buffer.isBuffer(value) ? value.toString("hex") : value == null ? "" : String(value);
|
|
28371
28383
|
var DEBUG_ARGV = process.argv.includes("--debug");
|
|
28372
28384
|
var LEVELS = { error: 0, warn: 1, info: 2, debug: 3 };
|
|
@@ -36159,7 +36171,7 @@ var processQueue = async () => {
|
|
|
36159
36171
|
const promises2 = jobs.map(async ({ filePath, resolve: resolve3, reject }) => {
|
|
36160
36172
|
let handle;
|
|
36161
36173
|
try {
|
|
36162
|
-
handle = await
|
|
36174
|
+
handle = await fs2.promises.open(path2.resolve(filePath), "r");
|
|
36163
36175
|
} catch (err) {
|
|
36164
36176
|
return reject(err);
|
|
36165
36177
|
}
|
|
@@ -36190,7 +36202,7 @@ async function getImageSize3(path62) {
|
|
|
36190
36202
|
}
|
|
36191
36203
|
async function getMd5HexFromFile(filePath) {
|
|
36192
36204
|
const hash2 = createHash("md5");
|
|
36193
|
-
const stream2 =
|
|
36205
|
+
const stream2 = fs3.createReadStream(filePath);
|
|
36194
36206
|
for await (const chunk of stream2) {
|
|
36195
36207
|
hash2.update(chunk);
|
|
36196
36208
|
}
|
|
@@ -36459,7 +36471,7 @@ async function createThumb(ctx, videoFilePath) {
|
|
|
36459
36471
|
clearTimeout(timeout);
|
|
36460
36472
|
}
|
|
36461
36473
|
if (!thumbnail) ctx.logger.info("\u83B7\u53D6\u89C6\u9891\u5C01\u9762\u5931\u8D25\uFF0C\u4F7F\u7528\u9ED8\u8BA4\u5C01\u9762");
|
|
36462
|
-
const thumbPath = path4.join(
|
|
36474
|
+
const thumbPath = path4.join(getTempDir(), randomUUID2() + (thumbnail ? ".png" : ".jpg"));
|
|
36463
36475
|
await writeFile(thumbPath, thumbnail ?? defaultVideoThumb);
|
|
36464
36476
|
return thumbPath;
|
|
36465
36477
|
}
|
|
@@ -36492,7 +36504,7 @@ async function encodeSilk(ctx, filePath) {
|
|
|
36492
36504
|
return { converted: false, path: filePath, duration: duration3 };
|
|
36493
36505
|
}
|
|
36494
36506
|
const native = getSilkAddon(ctx);
|
|
36495
|
-
const output2 = path5.join(
|
|
36507
|
+
const output2 = path5.join(getTempDir(), randomUUID3() + ".silk");
|
|
36496
36508
|
ctx.logger.info(`\u8BED\u97F3\u6587\u4EF6 ${filePath} \u9700\u8981\u8F6C\u6362\u6210 SILK`);
|
|
36497
36509
|
try {
|
|
36498
36510
|
await native.transcodeAudio(filePath, output2, { format: "silk" });
|
|
@@ -36584,7 +36596,7 @@ var SendElement;
|
|
|
36584
36596
|
ctx.logger.info("\u83B7\u53D6\u89C6\u9891\u4FE1\u606F\u5931\u8D25", e);
|
|
36585
36597
|
}
|
|
36586
36598
|
const md5 = await getMd5HexFromFile(filePath);
|
|
36587
|
-
const thumbDir =
|
|
36599
|
+
const thumbDir = getTempDir();
|
|
36588
36600
|
const thumbFilePath = pathLib.join(thumbDir, `${md5}_0.png`);
|
|
36589
36601
|
await mkdir(thumbDir, { recursive: true });
|
|
36590
36602
|
if (diyThumbPath) {
|
|
@@ -37963,9 +37975,9 @@ var DeleteGroupFolderInput = external_exports.object({
|
|
|
37963
37975
|
import { mkdir as mkdir2 } from "node:fs/promises";
|
|
37964
37976
|
import { tmpdir } from "node:os";
|
|
37965
37977
|
import path3 from "node:path";
|
|
37966
|
-
var
|
|
37978
|
+
var TEMP_DIR = path3.join(tmpdir(), "lucky-lillia-milky");
|
|
37967
37979
|
async function prepareTempDir() {
|
|
37968
|
-
await mkdir2(
|
|
37980
|
+
await mkdir2(TEMP_DIR, { recursive: true });
|
|
37969
37981
|
}
|
|
37970
37982
|
|
|
37971
37983
|
// src/common/download.ts
|
|
@@ -38203,7 +38215,7 @@ var SetAvatar = defineApi(
|
|
|
38203
38215
|
external_exports.object({}),
|
|
38204
38216
|
async (ctx, payload) => {
|
|
38205
38217
|
const data = await resolveMilkyUri(payload.uri);
|
|
38206
|
-
const tempPath = path6.join(
|
|
38218
|
+
const tempPath = path6.join(TEMP_DIR, `avatar-${randomUUID4()}`);
|
|
38207
38219
|
await writeFile2(tempPath, data);
|
|
38208
38220
|
const result = await ctx.ntUserApi.setSelfAvatar(tempPath);
|
|
38209
38221
|
unlink2(tempPath).catch(noop2);
|
|
@@ -38366,7 +38378,7 @@ async function transformOutgoingMessage(ctx, segments, peerUid, isGroup, isInsid
|
|
|
38366
38378
|
));
|
|
38367
38379
|
} else if (segment.type === "image") {
|
|
38368
38380
|
const imageBuffer = await resolveMilkyUri(segment.data.uri);
|
|
38369
|
-
const tempPath = path7.join(
|
|
38381
|
+
const tempPath = path7.join(TEMP_DIR, `image-${randomUUID5()}`);
|
|
38370
38382
|
await writeFile3(tempPath, imageBuffer);
|
|
38371
38383
|
const subType = segment.data.sub_type === "sticker" ? 1 : 0;
|
|
38372
38384
|
const picElement = await SendElement.pic(ctx, tempPath, segment.data.summary ?? "", subType);
|
|
@@ -38374,19 +38386,19 @@ async function transformOutgoingMessage(ctx, segments, peerUid, isGroup, isInsid
|
|
|
38374
38386
|
deleteAfterSentFiles.push(tempPath);
|
|
38375
38387
|
} else if (segment.type === "record") {
|
|
38376
38388
|
const recordBuffer = await resolveMilkyUri(segment.data.uri);
|
|
38377
|
-
const tempPath = path7.join(
|
|
38389
|
+
const tempPath = path7.join(TEMP_DIR, `audio-${randomUUID5()}`);
|
|
38378
38390
|
await writeFile3(tempPath, recordBuffer);
|
|
38379
38391
|
deleteAfterSentFiles.push(tempPath);
|
|
38380
38392
|
const pttElement = await SendElement.ptt(ctx, tempPath);
|
|
38381
38393
|
elements.push(pttElement);
|
|
38382
38394
|
} else if (segment.type === "video") {
|
|
38383
38395
|
const videoBuffer = await resolveMilkyUri(segment.data.uri);
|
|
38384
|
-
const tempPath = path7.join(
|
|
38396
|
+
const tempPath = path7.join(TEMP_DIR, `video-${randomUUID5()}`);
|
|
38385
38397
|
await writeFile3(tempPath, videoBuffer);
|
|
38386
38398
|
let thumbTempPath = void 0;
|
|
38387
38399
|
if (segment.data.thumb_uri) {
|
|
38388
38400
|
const thumbBuffer = await resolveMilkyUri(segment.data.thumb_uri);
|
|
38389
|
-
thumbTempPath = path7.join(
|
|
38401
|
+
thumbTempPath = path7.join(TEMP_DIR, `thumb-${randomUUID5()}`);
|
|
38390
38402
|
await writeFile3(thumbTempPath, thumbBuffer);
|
|
38391
38403
|
deleteAfterSentFiles.push(thumbTempPath);
|
|
38392
38404
|
}
|
|
@@ -43307,7 +43319,7 @@ var SetGroupAvatar = defineApi(
|
|
|
43307
43319
|
external_exports.object({}),
|
|
43308
43320
|
async (ctx, payload) => {
|
|
43309
43321
|
const imageBuffer = await resolveMilkyUri(payload.image_uri);
|
|
43310
|
-
const tempPath = path8.join(
|
|
43322
|
+
const tempPath = path8.join(TEMP_DIR, `group-avatar-${randomUUID6()}`);
|
|
43311
43323
|
await writeFile4(tempPath, imageBuffer);
|
|
43312
43324
|
const result = await ctx.ntGroupApi.setGroupAvatar(payload.group_id.toString(), tempPath);
|
|
43313
43325
|
unlink4(tempPath).catch(noop3);
|
|
@@ -43454,7 +43466,7 @@ var SendGroupAnnouncement = defineApi(
|
|
|
43454
43466
|
let picInfo;
|
|
43455
43467
|
if (payload.image_uri) {
|
|
43456
43468
|
const imageBuffer = await resolveMilkyUri(payload.image_uri);
|
|
43457
|
-
const tempPath = path8.join(
|
|
43469
|
+
const tempPath = path8.join(TEMP_DIR, `group-announcement-${randomUUID6()}`);
|
|
43458
43470
|
await writeFile4(tempPath, imageBuffer);
|
|
43459
43471
|
const result2 = await ctx.ntWebApi.uploadGroupBulletinPic(payload.group_id, tempPath);
|
|
43460
43472
|
unlink4(tempPath).catch(noop3);
|
|
@@ -43811,7 +43823,7 @@ var UploadPrivateFile = defineApi(
|
|
|
43811
43823
|
UploadPrivateFileOutput,
|
|
43812
43824
|
async (ctx, payload) => {
|
|
43813
43825
|
const data = await resolveMilkyUri(payload.file_uri);
|
|
43814
|
-
const tempPath = path9.join(
|
|
43826
|
+
const tempPath = path9.join(TEMP_DIR, `file-${randomUUID7()}`);
|
|
43815
43827
|
await writeFile5(tempPath, data);
|
|
43816
43828
|
const uid = await ctx.ntUserApi.getUidByUin(payload.user_id);
|
|
43817
43829
|
if (!uid) {
|
|
@@ -43840,7 +43852,7 @@ var UploadGroupFile = defineApi(
|
|
|
43840
43852
|
UploadGroupFileOutput,
|
|
43841
43853
|
async (ctx, payload) => {
|
|
43842
43854
|
const data = await resolveMilkyUri(payload.file_uri);
|
|
43843
|
-
const tempPath = path9.join(
|
|
43855
|
+
const tempPath = path9.join(TEMP_DIR, `file-${randomUUID7()}`);
|
|
43844
43856
|
await writeFile5(tempPath, data);
|
|
43845
43857
|
const info = await ctx.ntFileApi.uploadGroupFile(payload.group_id, tempPath, payload.file_name, payload.parent_folder_id);
|
|
43846
43858
|
unlink5(tempPath).catch(noop4);
|