multi bots online

This commit is contained in:
2023-05-08 10:58:05 -04:00
parent cbf7f78604
commit 0616ce2ea5
11 changed files with 1005 additions and 565 deletions

View File

@ -1,55 +1,48 @@
'use strict';
const {sleep} = require('../utils');
const conf = require('../conf');
const {CJbot} = require('../model/minecraft');
const inventoryViewer = require('mineflayer-web-inventory');
// const inventoryViewer = require('mineflayer-web-inventory');
const bot = new CJbot({
host: conf.mc.server,
...conf.mc.bots.art
});
const henry = new CJbot({
host: conf.mc.server,
autoConnect: false,
__autoReConnect: false,
...conf.mc.bots.henry
});
const nova = new CJbot({
host: conf.mc.server,
autoConnect: false,
__autoReConnect: false,
...conf.mc.bots.nova
});
const owen = new CJbot({
host: conf.mc.server,
autoConnect: false,
__autoReConnect: false,
...conf.mc.bots.owen
});
const linda = new CJbot({
host: conf.mc.server,
autoConnect: false,
__autoReConnect: false,
...conf.mc.bots.linda
});
const jimin = new CJbot({
host: conf.mc.server,
autoConnect: false,
__autoReConnect: false,
...conf.mc.bots.jimin
});
const ez = new CJbot({
host: conf.mc.server,
autoConnect: false,
__autoReConnect: false,
...conf.mc.bots.ez
});
const commands = require('./commands');
module.exports = {bot, henry, owen, linda, jimin, nova, ez};
for(let name in conf.mc.bots){
if(CJbot.bots[name]) continue;
let bot = new CJbot({name, host: conf.mc.host, ...conf.mc.bots[name]});
CJbot.bots[name] = bot;
for(let command of conf.mc.bots[name].commands || ['default']){
for(let [name, toAdd] of Object.entries(commands[command])){
bot.addCommand(name, toAdd)
}
}
}
(async ()=>{
try{
for(let name in CJbot.bots){
let bot = CJbot.bots[name];
if(bot.autoConnect){
console.log('Trying to connect', name)
console.log('Status for', name, await bot.connect());
await sleep(30000);
}
}
}catch(e){
console.log('!!!!!!!! error:', e)
}})()
// module.exports = {bot: ez, henry, owen, linda, jimin, nova, ez};