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.
- package/lib/index.js +27 -35
- 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
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
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 "需要至少两张图片进行合成,请重新发送";
|