koishi-plugin-aka-ai-generator 0.3.5 → 0.3.6

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 +34 -10
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -1249,12 +1249,22 @@ function apply(ctx, config) {
1249
1249
  return { images: [], text: imgParam.trim() };
1250
1250
  }
1251
1251
  await session.send("请输入画面描述");
1252
- const msg = await session.prompt(3e4);
1253
- if (!msg) return { error: "等待超时" };
1254
- const elements = import_koishi.h.parse(msg);
1255
- const text = import_koishi.h.select(elements, "text").map((e) => e.attrs.content).join(" ").trim();
1256
- if (!text) return { error: "未检测到描述" };
1257
- return { images: [], text };
1252
+ while (true) {
1253
+ const msg = await session.prompt(3e4);
1254
+ if (!msg) return { error: "等待超时" };
1255
+ const elements = import_koishi.h.parse(msg);
1256
+ const images = import_koishi.h.select(elements, "img");
1257
+ if (images.length > 0) {
1258
+ await session.send("检测到图片,请发送文字描述");
1259
+ continue;
1260
+ }
1261
+ const text = import_koishi.h.select(elements, "text").map((e) => e.attrs.content).join(" ").trim();
1262
+ if (!text) {
1263
+ await session.send("未检测到描述,请重新发送");
1264
+ continue;
1265
+ }
1266
+ return { images: [], text };
1267
+ }
1258
1268
  }
1259
1269
  if (imgParam) {
1260
1270
  if (typeof imgParam === "object" && imgParam.attrs?.src) {
@@ -1367,11 +1377,25 @@ function apply(ctx, config) {
1367
1377
  }
1368
1378
  finalPrompt = finalPrompt.trim();
1369
1379
  if (!finalPrompt) {
1370
- const promptInput = await getPromptInput(session, "请发送画面描述");
1371
- if (!promptInput) {
1372
- return "未检测到描述,请重新发送";
1380
+ await session.send("请发送画面描述");
1381
+ while (true) {
1382
+ const promptMsg = await session.prompt(3e4);
1383
+ if (!promptMsg) {
1384
+ return "未检测到描述,请重新发送";
1385
+ }
1386
+ const elements = import_koishi.h.parse(promptMsg);
1387
+ const images = import_koishi.h.select(elements, "img");
1388
+ if (images.length > 0) {
1389
+ await session.send("检测到图片,请发送文字描述");
1390
+ continue;
1391
+ }
1392
+ const text = import_koishi.h.select(elements, "text").map((e) => e.attrs.content).join(" ").trim();
1393
+ if (text) {
1394
+ finalPrompt = text;
1395
+ break;
1396
+ }
1397
+ await session.send("未检测到有效文字描述,请重新发送");
1373
1398
  }
1374
- finalPrompt = promptInput.trim();
1375
1399
  }
1376
1400
  const providerType = requestContext?.provider || config.provider;
1377
1401
  const providerModelId = requestContext?.modelId || (providerType === "yunwu" ? config.yunwuModelId : config.gptgodModelId);
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.3.5",
4
+ "version": "0.3.6",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [