diff --git a/src/modules/ai/ai.ts b/src/modules/ai/ai.ts index 078a540..6d8aa95 100644 --- a/src/modules/ai/ai.ts +++ b/src/modules/ai/ai.ts @@ -51,8 +51,14 @@ const onAI = async ( let personality = config.app.ai.personalities[state.personality.index]; - const useSmartModel = - text.startsWith("!aipro") && checkRoles(["MODERATOR", "ADMIN"], sender); + const useSmartModel = text.startsWith("!aipro"); + const hasProRoles = checkRoles(["MODERATOR", "ADMIN"], sender); + if (useSmartModel && !hasProRoles) { + client.sendTextMessage( + roomId, + "You are not allowed to use smart model", + ); + } let textMod = text.replace("!aipro", "").replace("!ai", "").trim(); let instructions = { @@ -80,7 +86,7 @@ const onAI = async ( roomId: roomId, sender: sender, }, - useSmartModel, + useSmartModel && hasProRoles, instructions, `${username}: ${textMod}`, `${repliedUsername}: ${repliedMessage}`, @@ -109,9 +115,14 @@ const onAI = async ( const onImageGen = async (text: string, roomId: string, sender: string) => { const user = getUserById(sender); - const useSmartModel = - text.startsWith("!imgpro") && - checkRoles(["MODERATOR", "ADMIN"], sender); + const useSmartModel = text.startsWith("!imgpro"); + const hasProRoles = checkRoles(["MODERATOR", "ADMIN"], sender); + if (useSmartModel && !hasProRoles) { + client.sendTextMessage( + roomId, + "You are not allowed to use smart model", + ); + } let textMod = text .replace("!imgpro", "") @@ -124,7 +135,10 @@ const onImageGen = async (text: string, roomId: string, sender: string) => { }); }); - const responseAI = await getImageGemini(textMod, useSmartModel); + const responseAI = await getImageGemini( + textMod, + useSmartModel && hasProRoles, + ); user.aiCost += responseAI.tokens * prices.image; if (!responseAI.image || responseAI.image.length < 10) {