using a template for tasks
All checks were successful
Deploy Cletus Bot / deploy (push) Successful in 24s

This commit is contained in:
roberts 2025-05-10 20:16:41 -05:00
parent 643e039bd8
commit ee1b3504ac

View file

@ -47,7 +47,18 @@ module.exports = async function HandleChat() {
if (!fs.existsSync(taskPath)) {
bot.chat(`I dont know how to ${aiTask.replace(/-/g, ' ')} yet, learning now...`);
await generateAndSaveTask(aiTask, config.ai);
// Use template to generate the file
const templatePath = path.join(__dirname, '../bot-tasks/TaskTemplate.js');
if (fs.existsSync(templatePath)) {
let template = fs.readFileSync(templatePath, 'utf8');
template = template.replace(/task-template/g, aiTask);
fs.writeFileSync(taskPath, template);
console.log(`[AI] Task file generated from template: ${taskPath}`);
} else {
bot.chat(`Template not found. Cannot learn the task.`);
return;
}
}
try {