refactor(bot): centralize runtime state; support albums + safer vision handling
- make MessageStore.put() return StoredMessage and allow collectReplyChainText() to work with StoredMessage - move muted users + answers loading into Environment (add Answers model + GEMINI_IMAGE_MODEL) - extract message handling into processNewMessage() and add media-group (album) caching/downloading by unique_file_id - for Ollama: check model capabilities before sending images; use replyToMessage helper consistently - add /geminiGenImage command stub for Gemini image generation
This commit is contained in:
@@ -7,6 +7,7 @@ import {
|
||||
escapeMarkdownV2Text,
|
||||
logError,
|
||||
oldReplyToMessage,
|
||||
photoPathByUniqueId,
|
||||
startIntervalEditor
|
||||
} from "../util/utils";
|
||||
import {Environment} from "../common/environment";
|
||||
@@ -33,7 +34,8 @@ export class MistralChat extends ChatCommand {
|
||||
|
||||
const chatId = msg.chat.id;
|
||||
|
||||
const messageParts = await collectReplyChainText(msg);
|
||||
const storedMsg = await MessageStore.get(chatId, msg.message_id);
|
||||
const messageParts = await collectReplyChainText(storedMsg);
|
||||
console.log("MESSAGE PARTS", messageParts);
|
||||
|
||||
const chatMessages = messageParts.map(part => {
|
||||
@@ -43,8 +45,8 @@ export class MistralChat extends ChatCommand {
|
||||
text: (Environment.USE_NAMES_IN_PROMPT && !part.bot ? `MESSAGE FROM USER "${part.name}":\n` : "") + part.content,
|
||||
});
|
||||
|
||||
if (part.images && part.images.length > 0) {
|
||||
const base64Image = Buffer.from(fs.readFileSync(part.images[0])).toString("base64");
|
||||
for (const image of part.images) {
|
||||
const base64Image = Buffer.from(fs.readFileSync(photoPathByUniqueId(image))).toString("base64");
|
||||
content.push({
|
||||
type: "image_url",
|
||||
imageUrl: "data:image/jpeg;base64," + base64Image
|
||||
|
||||
Reference in New Issue
Block a user