koishi-plugin-best-cave 1.1.1 → 1.1.2
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 +6 -21
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -524,34 +524,19 @@ ${caveContent}`;
|
|
|
524
524
|
__name(processDelete, "processDelete");
|
|
525
525
|
async function processAdd() {
|
|
526
526
|
try {
|
|
527
|
-
let
|
|
528
|
-
if (
|
|
529
|
-
|
|
527
|
+
let inputParts = [];
|
|
528
|
+
if (content.length > 0) {
|
|
529
|
+
inputParts = content;
|
|
530
530
|
}
|
|
531
|
-
if (
|
|
532
|
-
originalContent = originalContent ? `${originalContent}
|
|
533
|
-
${session.quote.content}` : session.quote.content;
|
|
534
|
-
}
|
|
535
|
-
const prefixes = Array.isArray(session.app.config.prefix) ? session.app.config.prefix : [session.app.config.prefix];
|
|
536
|
-
const nicknames = Array.isArray(session.app.config.nickname) ? session.app.config.nickname : session.app.config.nickname ? [session.app.config.nickname] : [];
|
|
537
|
-
const allTriggers = [...prefixes, ...nicknames];
|
|
538
|
-
const triggerPattern = allTriggers.map((t) => t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
|
|
539
|
-
const commandPattern = new RegExp(`^(?:${triggerPattern}).*?-a\\s*`);
|
|
540
|
-
originalContent = originalContent.replace(commandPattern, "");
|
|
541
|
-
let { imageUrls, imageElements, videoUrls, videoElements, textParts } = await extractMediaContent(originalContent);
|
|
542
|
-
if (textParts.length === 0 && imageUrls.length === 0 && videoUrls.length === 0) {
|
|
531
|
+
if (!inputParts.length) {
|
|
543
532
|
await sendMessage(session, "commands.cave.add.noContent", [], true);
|
|
544
533
|
const reply = await session.prompt({ timeout: 6e4 });
|
|
545
534
|
if (!reply || reply.trim() === "") {
|
|
546
535
|
return sendMessage(session, "commands.cave.add.operationTimeout", [], true);
|
|
547
536
|
}
|
|
548
|
-
|
|
549
|
-
imageUrls = replyResult.imageUrls;
|
|
550
|
-
imageElements = replyResult.imageElements;
|
|
551
|
-
videoUrls = replyResult.videoUrls;
|
|
552
|
-
videoElements = replyResult.videoElements;
|
|
553
|
-
textParts = replyResult.textParts;
|
|
537
|
+
inputParts = [reply];
|
|
554
538
|
}
|
|
539
|
+
let { imageUrls, imageElements, videoUrls, videoElements, textParts } = await extractMediaContent(inputParts.join("\n"));
|
|
555
540
|
if (videoUrls.length > 0 && !config.allowVideo) {
|
|
556
541
|
return sendMessage(session, "commands.cave.add.videoDisabled", [], true);
|
|
557
542
|
}
|