From 57918dc71372d8dd8737cf92b26363a7d4ef91d0 Mon Sep 17 00:00:00 2001 From: nameless Date: Fri, 10 Nov 2023 02:42:54 +0000 Subject: [PATCH] feat: img2img seed --- bot/img2imgCommand.ts | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/bot/img2imgCommand.ts b/bot/img2imgCommand.ts index edca6d1..eabebbb 100644 --- a/bot/img2imgCommand.ts +++ b/bot/img2imgCommand.ts @@ -83,14 +83,24 @@ async function img2img( state.params.height = biggestPhoto.height; } + if (match) { + state.params = parsePngInfo(match, state.params, true); + } + const repliedToText = repliedToMsg?.text || repliedToMsg?.caption; - if (includeRepliedTo && repliedToText) { + const isReply = includeRepliedTo && repliedToText; + + if (isReply) { // TODO: remove bot command from replied to text state.params = parsePngInfo(repliedToText, state.params); } - - if (match) { - state.params = parsePngInfo(match, state.params); + if (isReply) { + const parsedInfo = parsePngInfo(repliedToText, undefined); + if (parsedInfo.prompt !== state?.params?.prompt) { + if (state?.params) { + state.params.seed = parsedInfo.seed ?? -1; + } + } } if (!state.fileId) {