Limit Search Results to 5

This commit is contained in:
Raven 2024-08-03 16:27:17 -04:00
parent e25557190c
commit ae82fda49f

View File

@ -425,14 +425,20 @@ app.post('/api/v1/chat', async (req, res) => {
}
const searchRegex = /\b[Ss]earch\s+(.+)\b/;
const searchMatch = userMessage.match(searchRegex);
const searchMatch = userMessage.match(searchRegex);
if (searchMatch) {
if (searchMatch) {
const searchQuery = searchMatch[1];
console.log(`${getTimestamp()} [INFO] Detected search query in user message: ${searchQuery}`);
const options = {
query: searchQuery,
limit: 5,
disableConsole: true
};
try {
googleIt({ 'query': searchQuery }).then(async results => {
googleIt(options).then(async results => {
let searchResponse = `Search Query: ${searchQuery}\n`;
searchResponse += `Top Google search results:\n`;
@ -470,7 +476,7 @@ if (searchMatch) {
error: err.message
});
}
}
}
// End Plugins ---