37 lines
879 B
JavaScript
37 lines
879 B
JavaScript
const RandomBot = require('./RandomBot');
|
|
const LLMBot = require('./LLMBot');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
class BotFactory {
|
|
static createBot(type) {
|
|
switch (type.toLowerCase()) {
|
|
case 'random':
|
|
return new RandomBot();
|
|
case 'llm':
|
|
return new LLMBot();
|
|
default:
|
|
throw new Error(`Unknown bot type: ${type}`);
|
|
}
|
|
}
|
|
|
|
static generateBotName() {
|
|
const names = fs.readFileSync(path.join(__dirname, 'bot_names.txt'), 'utf8')
|
|
.split('\n')
|
|
.map(name => name.trim())
|
|
.filter(name => name.length > 0);
|
|
|
|
if (names.length === 0) {
|
|
return 'DefaultBot'; // Fallback if no names are found
|
|
}
|
|
|
|
const randomIndex = Math.floor(Math.random() * names.length);
|
|
return names[randomIndex];
|
|
}
|
|
|
|
static getAvailableBotTypes() {
|
|
return ['random'];
|
|
}
|
|
}
|
|
|
|
module.exports = BotFactory; |