liangzimixin 0.3.62 → 0.3.63
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/dist/index.cjs +46 -1
- package/dist/setup-entry.cjs +46 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -18432,10 +18432,31 @@ async function resolveAndUploadMedia(params) {
|
|
|
18432
18432
|
const fileType = detectFileType(fileName);
|
|
18433
18433
|
const mimeType = inferMimeType(fileName);
|
|
18434
18434
|
const ext = path2.extname(fileName).replace(".", "").toLowerCase();
|
|
18435
|
+
const MIN_IMAGE_SIZE = 100;
|
|
18436
|
+
if (fileType === "image" && buffer.length < MIN_IMAGE_SIZE) {
|
|
18437
|
+
log5.error("media:invalid image \u2014 \u6587\u4EF6\u8FC7\u5C0F\uFF0C\u4E0D\u662F\u5408\u6CD5\u56FE\u7247", {
|
|
18438
|
+
fileName,
|
|
18439
|
+
fileSize: buffer.length,
|
|
18440
|
+
minRequired: MIN_IMAGE_SIZE
|
|
18441
|
+
});
|
|
18442
|
+
throw new FileServiceError({
|
|
18443
|
+
message: `\u56FE\u7247\u6587\u4EF6\u65E0\u6548: ${fileName} \u4EC5 ${buffer.length} \u5B57\u8282\uFF0C\u8FDC\u5C0F\u4E8E\u5408\u6CD5\u56FE\u7247\u7684\u6700\u5C0F\u5927\u5C0F (${MIN_IMAGE_SIZE} \u5B57\u8282)`,
|
|
18444
|
+
code: -1,
|
|
18445
|
+
operationContext: `resolveAndUploadMedia:imageValidation(${fileName})`
|
|
18446
|
+
});
|
|
18447
|
+
}
|
|
18435
18448
|
let imageDimensions;
|
|
18436
18449
|
if (fileType === "image") {
|
|
18437
18450
|
imageDimensions = getImageDimensions(buffer);
|
|
18438
|
-
|
|
18451
|
+
if (!imageDimensions) {
|
|
18452
|
+
log5.warn("media:imageDimensions failed \u2014 \u65E0\u6CD5\u89E3\u6790\u56FE\u7247\u5BBD\u9AD8\uFF0C\u6587\u4EF6\u53EF\u80FD\u635F\u574F", {
|
|
18453
|
+
fileName,
|
|
18454
|
+
fileSize: buffer.length,
|
|
18455
|
+
headerHex: buffer.subarray(0, Math.min(16, buffer.length)).toString("hex")
|
|
18456
|
+
});
|
|
18457
|
+
} else {
|
|
18458
|
+
log5.info("media:imageDimensions", { fileName, ...imageDimensions });
|
|
18459
|
+
}
|
|
18439
18460
|
}
|
|
18440
18461
|
log5.info("media:fileType", { fileName, fileType, mimeType, ext });
|
|
18441
18462
|
const originalFileSize = buffer.length;
|
|
@@ -19173,11 +19194,13 @@ var InboundPipeline = class {
|
|
|
19173
19194
|
const cmdPayload = buildInboundPayload(msg, { text: context.text }, this.deps.pluginConfig);
|
|
19174
19195
|
const cmdCtx = core.channel.reply.finalizeInboundContext(cmdPayload);
|
|
19175
19196
|
const cmdSkipEncrypt = this.deps.pluginConfig.credentials.encryptionMode === "quantum_only" ? false : true;
|
|
19197
|
+
let deliverCalled = false;
|
|
19176
19198
|
await core.channel.reply.dispatchReplyWithBufferedBlockDispatcher({
|
|
19177
19199
|
ctx: cmdCtx,
|
|
19178
19200
|
cfg: this.deps.sdkConfig,
|
|
19179
19201
|
dispatcherOptions: {
|
|
19180
19202
|
deliver: async (payload2) => {
|
|
19203
|
+
deliverCalled = true;
|
|
19181
19204
|
log15.info("\u{1F527} \u547D\u4EE4 deliver \u56DE\u8C03\u6536\u5230", {
|
|
19182
19205
|
messageId: msg.messageId,
|
|
19183
19206
|
hasText: Boolean(payload2.text),
|
|
@@ -19201,11 +19224,33 @@ var InboundPipeline = class {
|
|
|
19201
19224
|
},
|
|
19202
19225
|
replyOptions: {}
|
|
19203
19226
|
});
|
|
19227
|
+
if (!deliverCalled) {
|
|
19228
|
+
const command = context.text.trim();
|
|
19229
|
+
const fallbackMessages = {
|
|
19230
|
+
"/new": "\u2705 \u4F1A\u8BDD\u5DF2\u91CD\u7F6E\uFF0C\u53EF\u4EE5\u5F00\u59CB\u65B0\u7684\u5BF9\u8BDD\u4E86\u3002",
|
|
19231
|
+
"/reset": "\u2705 \u4F1A\u8BDD\u5DF2\u91CD\u7F6E\uFF0C\u53EF\u4EE5\u5F00\u59CB\u65B0\u7684\u5BF9\u8BDD\u4E86\u3002"
|
|
19232
|
+
};
|
|
19233
|
+
const fallbackText = fallbackMessages[command] ?? `\u2705 \u547D\u4EE4 \`${command}\` \u5DF2\u6267\u884C\u3002`;
|
|
19234
|
+
log15.info("\u{1F4E8} SDK \u672A\u56DE\u8C03 deliver\uFF0C\u53D1\u9001\u56DE\u9000\u786E\u8BA4\u6D88\u606F", {
|
|
19235
|
+
messageId: msg.messageId,
|
|
19236
|
+
command
|
|
19237
|
+
});
|
|
19238
|
+
await this.deps.messagePipe.sendMessage({
|
|
19239
|
+
chatId: msg.chatId,
|
|
19240
|
+
senderId: msg.senderId,
|
|
19241
|
+
msgType: "markdown",
|
|
19242
|
+
content: JSON.stringify({ content: fallbackText }),
|
|
19243
|
+
skipEncrypt: cmdSkipEncrypt
|
|
19244
|
+
}).catch((err) => {
|
|
19245
|
+
log15.warn("\u26A0\uFE0F \u56DE\u9000\u786E\u8BA4\u6D88\u606F\u53D1\u9001\u5931\u8D25", { error: err.message });
|
|
19246
|
+
});
|
|
19247
|
+
}
|
|
19204
19248
|
clearInboundEncryptionStatus(msg.chatId, msg.messageId);
|
|
19205
19249
|
const durationMs2 = Date.now() - startMs;
|
|
19206
19250
|
log15.info("\u2705 \u7CFB\u7EDF\u547D\u4EE4\u5904\u7406\u5B8C\u6210", {
|
|
19207
19251
|
messageId: msg.messageId,
|
|
19208
19252
|
command: context.text.trim(),
|
|
19253
|
+
deliverCalled,
|
|
19209
19254
|
\u8017\u65F6ms: durationMs2
|
|
19210
19255
|
});
|
|
19211
19256
|
return;
|
package/dist/setup-entry.cjs
CHANGED
|
@@ -4505,10 +4505,31 @@ async function resolveAndUploadMedia(params) {
|
|
|
4505
4505
|
const fileType = detectFileType(fileName);
|
|
4506
4506
|
const mimeType = inferMimeType(fileName);
|
|
4507
4507
|
const ext = path2.extname(fileName).replace(".", "").toLowerCase();
|
|
4508
|
+
const MIN_IMAGE_SIZE = 100;
|
|
4509
|
+
if (fileType === "image" && buffer.length < MIN_IMAGE_SIZE) {
|
|
4510
|
+
log5.error("media:invalid image \u2014 \u6587\u4EF6\u8FC7\u5C0F\uFF0C\u4E0D\u662F\u5408\u6CD5\u56FE\u7247", {
|
|
4511
|
+
fileName,
|
|
4512
|
+
fileSize: buffer.length,
|
|
4513
|
+
minRequired: MIN_IMAGE_SIZE
|
|
4514
|
+
});
|
|
4515
|
+
throw new FileServiceError({
|
|
4516
|
+
message: `\u56FE\u7247\u6587\u4EF6\u65E0\u6548: ${fileName} \u4EC5 ${buffer.length} \u5B57\u8282\uFF0C\u8FDC\u5C0F\u4E8E\u5408\u6CD5\u56FE\u7247\u7684\u6700\u5C0F\u5927\u5C0F (${MIN_IMAGE_SIZE} \u5B57\u8282)`,
|
|
4517
|
+
code: -1,
|
|
4518
|
+
operationContext: `resolveAndUploadMedia:imageValidation(${fileName})`
|
|
4519
|
+
});
|
|
4520
|
+
}
|
|
4508
4521
|
let imageDimensions;
|
|
4509
4522
|
if (fileType === "image") {
|
|
4510
4523
|
imageDimensions = getImageDimensions(buffer);
|
|
4511
|
-
|
|
4524
|
+
if (!imageDimensions) {
|
|
4525
|
+
log5.warn("media:imageDimensions failed \u2014 \u65E0\u6CD5\u89E3\u6790\u56FE\u7247\u5BBD\u9AD8\uFF0C\u6587\u4EF6\u53EF\u80FD\u635F\u574F", {
|
|
4526
|
+
fileName,
|
|
4527
|
+
fileSize: buffer.length,
|
|
4528
|
+
headerHex: buffer.subarray(0, Math.min(16, buffer.length)).toString("hex")
|
|
4529
|
+
});
|
|
4530
|
+
} else {
|
|
4531
|
+
log5.info("media:imageDimensions", { fileName, ...imageDimensions });
|
|
4532
|
+
}
|
|
4512
4533
|
}
|
|
4513
4534
|
log5.info("media:fileType", { fileName, fileType, mimeType, ext });
|
|
4514
4535
|
const originalFileSize = buffer.length;
|
|
@@ -21471,11 +21492,13 @@ var InboundPipeline = class {
|
|
|
21471
21492
|
const cmdPayload = buildInboundPayload(msg, { text: context.text }, this.deps.pluginConfig);
|
|
21472
21493
|
const cmdCtx = core.channel.reply.finalizeInboundContext(cmdPayload);
|
|
21473
21494
|
const cmdSkipEncrypt = this.deps.pluginConfig.credentials.encryptionMode === "quantum_only" ? false : true;
|
|
21495
|
+
let deliverCalled = false;
|
|
21474
21496
|
await core.channel.reply.dispatchReplyWithBufferedBlockDispatcher({
|
|
21475
21497
|
ctx: cmdCtx,
|
|
21476
21498
|
cfg: this.deps.sdkConfig,
|
|
21477
21499
|
dispatcherOptions: {
|
|
21478
21500
|
deliver: async (payload2) => {
|
|
21501
|
+
deliverCalled = true;
|
|
21479
21502
|
log28.info("\u{1F527} \u547D\u4EE4 deliver \u56DE\u8C03\u6536\u5230", {
|
|
21480
21503
|
messageId: msg.messageId,
|
|
21481
21504
|
hasText: Boolean(payload2.text),
|
|
@@ -21499,11 +21522,33 @@ var InboundPipeline = class {
|
|
|
21499
21522
|
},
|
|
21500
21523
|
replyOptions: {}
|
|
21501
21524
|
});
|
|
21525
|
+
if (!deliverCalled) {
|
|
21526
|
+
const command = context.text.trim();
|
|
21527
|
+
const fallbackMessages = {
|
|
21528
|
+
"/new": "\u2705 \u4F1A\u8BDD\u5DF2\u91CD\u7F6E\uFF0C\u53EF\u4EE5\u5F00\u59CB\u65B0\u7684\u5BF9\u8BDD\u4E86\u3002",
|
|
21529
|
+
"/reset": "\u2705 \u4F1A\u8BDD\u5DF2\u91CD\u7F6E\uFF0C\u53EF\u4EE5\u5F00\u59CB\u65B0\u7684\u5BF9\u8BDD\u4E86\u3002"
|
|
21530
|
+
};
|
|
21531
|
+
const fallbackText = fallbackMessages[command] ?? `\u2705 \u547D\u4EE4 \`${command}\` \u5DF2\u6267\u884C\u3002`;
|
|
21532
|
+
log28.info("\u{1F4E8} SDK \u672A\u56DE\u8C03 deliver\uFF0C\u53D1\u9001\u56DE\u9000\u786E\u8BA4\u6D88\u606F", {
|
|
21533
|
+
messageId: msg.messageId,
|
|
21534
|
+
command
|
|
21535
|
+
});
|
|
21536
|
+
await this.deps.messagePipe.sendMessage({
|
|
21537
|
+
chatId: msg.chatId,
|
|
21538
|
+
senderId: msg.senderId,
|
|
21539
|
+
msgType: "markdown",
|
|
21540
|
+
content: JSON.stringify({ content: fallbackText }),
|
|
21541
|
+
skipEncrypt: cmdSkipEncrypt
|
|
21542
|
+
}).catch((err) => {
|
|
21543
|
+
log28.warn("\u26A0\uFE0F \u56DE\u9000\u786E\u8BA4\u6D88\u606F\u53D1\u9001\u5931\u8D25", { error: err.message });
|
|
21544
|
+
});
|
|
21545
|
+
}
|
|
21502
21546
|
clearInboundEncryptionStatus(msg.chatId, msg.messageId);
|
|
21503
21547
|
const durationMs2 = Date.now() - startMs;
|
|
21504
21548
|
log28.info("\u2705 \u7CFB\u7EDF\u547D\u4EE4\u5904\u7406\u5B8C\u6210", {
|
|
21505
21549
|
messageId: msg.messageId,
|
|
21506
21550
|
command: context.text.trim(),
|
|
21551
|
+
deliverCalled,
|
|
21507
21552
|
\u8017\u65F6ms: durationMs2
|
|
21508
21553
|
});
|
|
21509
21554
|
return;
|