using a template for tasks
All checks were successful
Deploy Cletus Bot / deploy (push) Successful in 24s
All checks were successful
Deploy Cletus Bot / deploy (push) Successful in 24s
This commit is contained in:
parent
643e039bd8
commit
ee1b3504ac
1 changed files with 12 additions and 1 deletions
|
|
@ -47,7 +47,18 @@ module.exports = async function HandleChat() {
|
||||||
|
|
||||||
if (!fs.existsSync(taskPath)) {
|
if (!fs.existsSync(taskPath)) {
|
||||||
bot.chat(`I don’t know how to ${aiTask.replace(/-/g, ' ')} yet, learning now...`);
|
bot.chat(`I don’t 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 {
|
try {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue