koishi-plugin-aka-ai-generator 0.2.2 → 0.2.3
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 +26 -11
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -672,15 +672,23 @@ function apply(ctx, config) {
|
|
|
672
672
|
}
|
|
673
673
|
__name(buildModelMappingIndex, "buildModelMappingIndex");
|
|
674
674
|
function parseStyleCommandModifiers(argv, imgParam) {
|
|
675
|
-
const
|
|
676
|
-
|
|
677
|
-
if (
|
|
678
|
-
const
|
|
679
|
-
|
|
680
|
-
}
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
675
|
+
const session = argv.session;
|
|
676
|
+
let rawText = "";
|
|
677
|
+
if (session?.content) {
|
|
678
|
+
const elements = import_koishi.h.parse(session.content);
|
|
679
|
+
rawText = import_koishi.h.select(elements, "text").map((e) => e.attrs.content).join(" ");
|
|
680
|
+
}
|
|
681
|
+
const argsList = rawText ? rawText.split(/\s+/).filter(Boolean) : [...argv.args || []].map((arg) => typeof arg === "string" ? arg.trim() : "").filter(Boolean);
|
|
682
|
+
if (!rawText) {
|
|
683
|
+
const restStr = typeof argv.rest === "string" ? argv.rest.trim() : "";
|
|
684
|
+
if (restStr) {
|
|
685
|
+
const restParts = restStr.split(/\s+/).filter(Boolean);
|
|
686
|
+
argsList.push(...restParts);
|
|
687
|
+
}
|
|
688
|
+
if (imgParam && typeof imgParam === "string" && !imgParam.startsWith("http") && !imgParam.startsWith("data:")) {
|
|
689
|
+
const imgParts = imgParam.split(/\s+/).filter(Boolean);
|
|
690
|
+
argsList.push(...imgParts);
|
|
691
|
+
}
|
|
684
692
|
}
|
|
685
693
|
if (!argsList.length) return {};
|
|
686
694
|
const modifiers = { customAdditions: [] };
|
|
@@ -702,8 +710,15 @@ function apply(ctx, config) {
|
|
|
702
710
|
if (lower === "-add") {
|
|
703
711
|
index++;
|
|
704
712
|
const additionTokens = [];
|
|
705
|
-
while (index < argsList.length
|
|
706
|
-
|
|
713
|
+
while (index < argsList.length) {
|
|
714
|
+
const nextToken = argsList[index];
|
|
715
|
+
if (nextToken.startsWith("-")) {
|
|
716
|
+
const key = normalizeSuffix(nextToken);
|
|
717
|
+
if (key && modelMappingIndex.has(key)) break;
|
|
718
|
+
if (nextToken.toLowerCase().startsWith("-prompt:")) break;
|
|
719
|
+
if (nextToken.toLowerCase() === "-add") break;
|
|
720
|
+
}
|
|
721
|
+
additionTokens.push(nextToken);
|
|
707
722
|
index++;
|
|
708
723
|
}
|
|
709
724
|
if (additionTokens.length) {
|