feat: parse seed on new txt2img request #20

Merged
pinks merged 1 commits from :main into main 2023-10-14 10:57:46 +00:00
2 changed files with 10 additions and 3 deletions

View File

@ -25,7 +25,7 @@ interface PngInfoExtra extends PngInfo {
upscale?: number;
}
export function parsePngInfo(pngInfo: string, baseParams?: Partial<PngInfo>): Partial<PngInfo> {
export function parsePngInfo(pngInfo: string, baseParams?: Partial<PngInfo>, shouldParseSeed?: boolean): Partial<PngInfo> {
const tags = pngInfo.split(/[,;]+|\.+\s|\n/u);
let part: "prompt" | "negative_prompt" | "params" = "prompt";
const params: Partial<PngInfoExtra> = {};
@ -99,7 +99,14 @@ export function parsePngInfo(pngInfo: string, baseParams?: Partial<PngInfo>): Pa
params.denoising_strength = denoisingStrength;
break;
}
case "seed":
case "seed": {
part = "params";
if (shouldParseSeed) {
const seed = Number(value.trim());
params.seed = seed;
break;
}
}
case "model":
case "modelhash":
case "modelname":

View File

@ -64,7 +64,7 @@ async function txt2img(ctx: ErisContext, match: string, includeRepliedTo: boolea
params = parsePngInfo(repliedToText, params);
}
params = parsePngInfo(match, params);
params = parsePngInfo(match, params, true);
if (!params.prompt) {
await ctx.reply(