koishi-plugin-aka-ai-generator 0.4.1 → 0.4.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 +27 -35
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -1357,22 +1357,18 @@ function apply(ctx, config) {
1357
1357
  return { images: [], text: imgParam.trim() };
1358
1358
  }
1359
1359
  await session.send("请输入画面描述");
1360
- while (true) {
1361
- const msg = await session.prompt(3e4);
1362
- if (!msg) return { error: "等待超时" };
1363
- const elements = import_koishi.h.parse(msg);
1364
- const images = import_koishi.h.select(elements, "img");
1365
- if (images.length > 0) {
1366
- await session.send("检测到图片,请发送文字描述");
1367
- continue;
1368
- }
1369
- const text = import_koishi.h.select(elements, "text").map((e) => e.attrs.content).join(" ").trim();
1370
- if (!text) {
1371
- await session.send("未检测到描述,请重新发送");
1372
- continue;
1373
- }
1374
- return { images: [], text };
1360
+ const msg = await session.prompt(3e4);
1361
+ if (!msg) return { error: "等待超时" };
1362
+ const elements = import_koishi.h.parse(msg);
1363
+ const images = import_koishi.h.select(elements, "img");
1364
+ if (images.length > 0) {
1365
+ return { error: "检测到图片,本功能仅支持文字输入" };
1366
+ }
1367
+ const text = import_koishi.h.select(elements, "text").map((e) => e.attrs.content).join(" ").trim();
1368
+ if (!text) {
1369
+ return { error: "未检测到描述,操作已取消" };
1375
1370
  }
1371
+ return { images: [], text };
1376
1372
  }
1377
1373
  if (imgParam) {
1378
1374
  if (typeof imgParam === "object" && imgParam.attrs?.src) {
@@ -1427,8 +1423,7 @@ function apply(ctx, config) {
1427
1423
  }
1428
1424
  if (text) {
1429
1425
  if (collectedImages.length === 0) {
1430
- await session.send("未检测到图片,请先发送图片");
1431
- continue;
1426
+ return { error: "未检测到图片,请重新发起指令并发送图片" };
1432
1427
  }
1433
1428
  collectedText = text;
1434
1429
  break;
@@ -1486,23 +1481,20 @@ function apply(ctx, config) {
1486
1481
  finalPrompt = finalPrompt.trim();
1487
1482
  if (!finalPrompt) {
1488
1483
  await session.send("请发送画面描述");
1489
- while (true) {
1490
- const promptMsg = await session.prompt(3e4);
1491
- if (!promptMsg) {
1492
- return "未检测到描述,请重新发送";
1493
- }
1494
- const elements = import_koishi.h.parse(promptMsg);
1495
- const images = import_koishi.h.select(elements, "img");
1496
- if (images.length > 0) {
1497
- await session.send("检测到图片,请发送文字描述");
1498
- continue;
1499
- }
1500
- const text = import_koishi.h.select(elements, "text").map((e) => e.attrs.content).join(" ").trim();
1501
- if (text) {
1502
- finalPrompt = text;
1503
- break;
1504
- }
1505
- await session.send("未检测到有效文字描述,请重新发送");
1484
+ const promptMsg = await session.prompt(3e4);
1485
+ if (!promptMsg) {
1486
+ return "未检测到描述,操作已取消";
1487
+ }
1488
+ const elements = import_koishi.h.parse(promptMsg);
1489
+ const images = import_koishi.h.select(elements, "img");
1490
+ if (images.length > 0) {
1491
+ return "检测到图片,本功能仅支持文字输入";
1492
+ }
1493
+ const text = import_koishi.h.select(elements, "text").map((e) => e.attrs.content).join(" ").trim();
1494
+ if (text) {
1495
+ finalPrompt = text;
1496
+ } else {
1497
+ return "未检测到有效文字描述,操作已取消";
1506
1498
  }
1507
1499
  }
1508
1500
  const providerType = requestContext?.provider || config.provider;
@@ -1670,7 +1662,7 @@ ${infoParts.join("\n")}`;
1670
1662
  prompt = text;
1671
1663
  break;
1672
1664
  }
1673
- return "未检测到有效内容,请重新发送";
1665
+ return "未检测到有效内容,操作已取消";
1674
1666
  }
1675
1667
  if (collectedImages.length < 2) {
1676
1668
  return "需要至少两张图片进行合成,请重新发送";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-aka-ai-generator",
3
3
  "description": "自用AI生成插件(GPTGod & Yunwu)",
4
- "version": "0.4.1",
4
+ "version": "0.4.2",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [