Add support for replied messages

This commit is contained in:
Aslan 2025-12-29 00:33:52 +01:00
parent 6264567ec9
commit 791883f580
5 changed files with 46 additions and 8 deletions

View file

@ -28,7 +28,12 @@ const registerModuleAI = (
});
};
const onAI = async (text: string, roomId: string, sender: string) => {
const onAI = async (
text: string,
roomId: string,
sender: string,
repliedMessage?: string,
) => {
const user = getUserById(sender);
if (text.trim().length < 5) {
@ -66,9 +71,13 @@ const onAI = async (text: string, roomId: string, sender: string) => {
} as IAIInstructions;
const username = getUserName(user);
textMod = `${username}:\n${textMod}`;
textMod = `${username}: ${textMod}`;
const responseAI = await getTextGemini(instructions, textMod);
const responseAI = await getTextGemini(
instructions,
textMod,
repliedMessage,
);
user.aiCost += responseAI.tokens * prices.text;