show used images in CLI and bot; caption cmdline in bot
This commit is contained in:
parent
546102205e
commit
04ba5b7e4e
3 changed files with 30 additions and 3 deletions
|
@ -22,6 +22,10 @@ export class ProxyImage implements CollageImage {
|
|||
}
|
||||
}
|
||||
|
||||
public get path(): string | null {
|
||||
return this.filepath;
|
||||
}
|
||||
|
||||
public get image(): Image {
|
||||
if (!this._image) {
|
||||
const image = canvasKit.MakeImageFromEncoded(
|
||||
|
|
|
@ -94,6 +94,7 @@ if (modeKey === "recursive") {
|
|||
images,
|
||||
);
|
||||
mode.place(context, images, segments);
|
||||
console.log(`Used: ${images.slice(0, segments.length).map((img) => img.path).join(", ")}`)
|
||||
}
|
||||
|
||||
const output = args["output"];
|
||||
|
|
|
@ -26,7 +26,7 @@ class KollagenBot:
|
|||
) -> None:
|
||||
self.logger = logging.getLogger("kollagen")
|
||||
self.kollagen_path = kollagen_path
|
||||
self.base_dir = base_dir
|
||||
self.base_dir = os.path.abspath(base_dir) if base_dir else None
|
||||
|
||||
self._init_parser()
|
||||
|
||||
|
@ -174,14 +174,36 @@ class KollagenBot:
|
|||
"-o",
|
||||
ntf.name,
|
||||
]
|
||||
|
||||
self.logger.debug(f"Running: " + str(shell_cmd_line))
|
||||
subprocess.run(
|
||||
result = subprocess.run(
|
||||
shell_cmd_line,
|
||||
check=True,
|
||||
capture_output=True,
|
||||
)
|
||||
ntf.seek(0)
|
||||
update.message.reply_photo(ntf)
|
||||
|
||||
used_line = next(
|
||||
(
|
||||
line
|
||||
for line in result.stdout.decode("utf-8").splitlines()
|
||||
if line.startswith("Used: ")
|
||||
),
|
||||
"",
|
||||
).replace(f"{self.base_dir}/" if self.base_dir else "", "")
|
||||
|
||||
caption = ""
|
||||
caption += (
|
||||
f"`{' '.join(['/generate', *cmd_line])}`\n" if len(cmd_line) else ""
|
||||
)
|
||||
caption += used_line.replace("_", "\\_")
|
||||
caption = caption[:200]
|
||||
|
||||
update.message.reply_photo(
|
||||
ntf,
|
||||
caption=caption,
|
||||
parse_mode=ParseMode.MARKDOWN,
|
||||
)
|
||||
return True
|
||||
|
||||
def tg_help(self, update: Update, context: CallbackContext):
|
||||
|
|
Loading…
Reference in a new issue