diff --git a/handlers/openAI.js b/handlers/openAI.js index 0fb862f..4590724 100644 --- a/handlers/openAI.js +++ b/handlers/openAI.js @@ -5,7 +5,7 @@ const moment = require("moment/moment"); class OpenAI { async askOpenAI (target, text, username, bot) { - const response = await OpenAIService.askAssistant(text) + const response = await OpenAIService.askAssistant(text, username) if (response) { bot.say(target, `@${username} ${response}`) } diff --git a/lib/messenger.js b/lib/messenger.js index ec33ba3..fd13d86 100644 --- a/lib/messenger.js +++ b/lib/messenger.js @@ -68,7 +68,9 @@ class Messenger { async handleText (target, context, msg, self) { if (self) { return; } // Ignore messages from the bot - await Logger.logChatMessage(context['room-id'], context['username'], msg) + if (context['username'].toLowerCase() !== config.twitch.username.toLowerCase()) + await Logger.logChatMessage(context['room-id'], context['username'], msg) + const text = msg.trim(); const textSplit = text.split(' ') @@ -182,11 +184,11 @@ class Messenger { return handlers.events.sendTarracoMangaEvent() // OPEN AI - if (textSplit.length > 1 && inputParser.isAskingOpenAI(textSplit[0]) && this._isNotCooldown('openai',10)) { + if (textSplit.length > 1 && inputParser.isAskingOpenAI(textSplit[0]) && this._isNotCooldown('openai',15)) { return handlers.openAI.askOpenAI(target, textSplit.slice(1).join(' '), context['display-name'], this.bot) } - if (textSplit.length > 1 && inputParser.isAskingBotOpenAI(text) && this._isNotCooldown('openai',10)) { + if (textSplit.length > 1 && inputParser.isAskingBotOpenAI(text) && this._isNotCooldown('openai',15)) { const regex = new RegExp(`@?${config.twitch.username}`, 'gi') const textWithoutMention = text.replace(regex, '').trim() return handlers.openAI.askOpenAI(target, textWithoutMention, context['display-name'], this.bot) diff --git a/services/openAI.js b/services/openAI.js index c713f07..7b2a9c1 100644 --- a/services/openAI.js +++ b/services/openAI.js @@ -79,7 +79,7 @@ async function uploadFileToVectorStore(json, formattedDate, origin) { -async function askAssistant(message) { +async function askAssistant(message, username) { let result try { // Create a thread @@ -93,6 +93,9 @@ async function askAssistant(message) { { role: "user", content: "dime en 200 caracteres " + message, + metadata: { + nick: username, + } } );