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.
Files changed (2) hide show
  1. package/lib/index.js +6 -21
  2. 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 originalContent = content.join(" ") || "";
528
- if (session.content) {
529
- originalContent = session.content;
527
+ let inputParts = [];
528
+ if (content.length > 0) {
529
+ inputParts = content;
530
530
  }
531
- if (session.quote?.content) {
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
- const replyResult = await extractMediaContent(reply);
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
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-best-cave",
3
3
  "description": "最好的 cave 插件,可开关的审核系统,可引用添加,支持图文混合内容,可查阅投稿列表,完美复刻你的 .cave 体验!",
4
- "version": "1.1.1",
4
+ "version": "1.1.2",
5
5
  "contributors": [
6
6
  "Yis_Rime <yis_rime@outlook.com>"
7
7
  ],