Add support for replied messages

This commit is contained in:
Aslan 2025-12-29 00:45:14 +01:00
parent a4ba2acfcc
commit ed1a5356f9
3 changed files with 11 additions and 3 deletions

View file

@ -33,6 +33,7 @@ const onAI = async (
roomId: string,
sender: string,
repliedMessage?: string,
repliedSender?: string,
) => {
const user = getUserById(sender);
@ -67,12 +68,15 @@ const onAI = async (
} as IAIInstructions;
const username = getUserName(user);
textMod = `${username}: ${textMod}`;
let repliedUsername = "";
if (repliedSender) {
getUserName(getUserById(repliedSender));
}
const responseAI = await getTextGemini(
instructions,
textMod,
repliedMessage,
`${username}: ${textMod}`,
`${repliedUsername}: ${repliedMessage}`,
);
user.aiCost += responseAI.tokens * prices.text;