fix(images): cache Telegram photos by unique_id and pass base64 to LLM commands

Stop reading image files inside gemini/mistral commands; use pre-encoded image data from message parts

Rework loadImagesIfExists / loadImagesFromFileIds to return cached file_unique_ids and download only missing sizes

Encode cached images to base64 when assembling the reply chain

Make getPhotoMaxSize synchronous (returns PhotoSize), and map to URL only when needed

Await MessageStore.put / UserStore.put and prefetch single-image downloads on message receipt
This commit is contained in:
2026-01-29 20:58:08 +03:00
parent 4945db86c0
commit 9e30086af2
5 changed files with 59 additions and 33 deletions
+1 -3
View File
@@ -13,7 +13,6 @@ import {
oldReplyToMessage,
startIntervalEditor
} from "../util/utils";
import fs from "node:fs";
export class GeminiChat extends ChatCommand {
command = "gemini";
@@ -66,10 +65,9 @@ export class GeminiChat extends ChatCommand {
const images = messageParts[0].images;
images.forEach(image => {
const base64Image = Buffer.from(fs.readFileSync(image)).toString("base64");
input.push({
type: "image",
data: base64Image,
data: image,
mime_type: "image/png"
});
});