plugins
This commit is contained in:
@ -1,32 +1,112 @@
|
||||
module.exports = {
|
||||
'help': {
|
||||
desc: `Print the allowed commands.`,
|
||||
async function(from){
|
||||
console.log('called help', from)
|
||||
let intro = [
|
||||
'I am a bot owned and operated by',
|
||||
'wmantly <wmantly@gmail.com>',
|
||||
'You have access to the following commands:'
|
||||
]
|
||||
await this.whisper(from, ...intro, ...this.__reduceCommands(from).map(command =>
|
||||
`${command} -- ${this.commands[command].desc || ''}`
|
||||
));
|
||||
}
|
||||
desc: `Print the allowed commands.`,
|
||||
async function(from){
|
||||
console.log('called help', from)
|
||||
let intro = [
|
||||
'I am a bot owned and operated by',
|
||||
'wmantly <wmantly@gmail.com>',
|
||||
'You have access to the following commands:'
|
||||
]
|
||||
await this.whisper(from, ...intro, ...this.__reduceCommands(from).map(command =>
|
||||
`${command} -- ${this.commands[command].desc || ''}`
|
||||
));
|
||||
}
|
||||
},
|
||||
'say': {
|
||||
desc: `Make the bot say stuff in chat`,
|
||||
allowed: ['wmantly', 'useless666', 'tux4242', 'pi_chef', '1_cut',],
|
||||
allowed: ['wmantly', 'useless666', 'tux4242',],
|
||||
ignoreLock: true,
|
||||
async function(from, ...messages){
|
||||
await this.say((messages || []).join(' '));
|
||||
}
|
||||
async function(from, ...messages){
|
||||
await this.say((messages || []).join(' '));
|
||||
}
|
||||
|
||||
},
|
||||
'plugins': {
|
||||
desc: 'List the plugins',
|
||||
allowed: ['wmantly', 'useless666', 'tux4242',],
|
||||
ignoreLock: true,
|
||||
async function(from, botName){
|
||||
if(botName){
|
||||
if(botName in this.constructor.bots){
|
||||
this.whisper(from, `${Object.keys(this.constructor.bots[botName].plunginsLoaded)}`)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
'unload': {
|
||||
desc: `Make bot unload plugin`,
|
||||
allowed: ['wmantly', 'useless666', 'tux4242',],
|
||||
ignoreLock: true,
|
||||
async function(from, botName, plugin) {
|
||||
this.whisper(from, `Unloading ${plugin}`);
|
||||
if(botName in this.constructor.bots){
|
||||
let bot = this.constructor.bots[botName];
|
||||
let status = await bot.pluginUnload(plugin);
|
||||
return this.whisper(from, `plugin status ${status}`);
|
||||
}
|
||||
|
||||
this.whisper(from, '?')
|
||||
}
|
||||
},
|
||||
'load': {
|
||||
desc: `Make bot load/unload plugin`,
|
||||
allowed: ['wmantly', 'useless666', 'tux4242',],
|
||||
ignoreLock: true,
|
||||
async function(from, botName, plugin) {
|
||||
this.whisper(from, `Loading ${plugin}`);
|
||||
if(botName in this.constructor.bots){
|
||||
let bot = this.constructor.bots[botName];
|
||||
let status = await bot.pluginLoad(plugin);
|
||||
return this.whisper(from, `plugin status ${status}`);
|
||||
}
|
||||
|
||||
this.whisper(from, '?')
|
||||
}
|
||||
},
|
||||
'guardian': {
|
||||
desc:'',
|
||||
allowed: ['wmantly', 'useless666', 'tux4242',],
|
||||
ignoreLock: true,
|
||||
async function(from, botName, action) {
|
||||
this.whisper(from, `Loading ${plugin}`);
|
||||
if(botName in this.constructor.bots){
|
||||
let bot = this.constructor.bots[botName];
|
||||
let status = await bot.pluginLoad(plugin);
|
||||
return this.whisper(from, `plugin status ${status}`);
|
||||
}
|
||||
|
||||
this.whisper(from, '?')
|
||||
}
|
||||
},
|
||||
'ai': {
|
||||
desc: `Make bot load/unload plugin`,
|
||||
allowed: ['wmantly', 'useless666', 'tux4242',],
|
||||
ignoreLock: true,
|
||||
async function(from, botName, personality, ...custom) {
|
||||
if(botName in this.constructor.bots ){
|
||||
let bot = this.constructor.bots[botName];
|
||||
if(bot.isReady){
|
||||
let status = await bot.pluginLoad('Ai', {
|
||||
promptName: personality,
|
||||
prompCustom: custom,
|
||||
});
|
||||
|
||||
return this.whisper(from, `plugin status ${status}`);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
this.whisper(from, '?')
|
||||
}
|
||||
},
|
||||
|
||||
'logon': {
|
||||
desc: `Have bot log on for 10 seconds'`,
|
||||
allowed: ['wmantly', 'useless666', 'tux4242', 'pi_chef', '1_cut',],
|
||||
ignoreLock: true,
|
||||
async function(from, botName){
|
||||
async function(from, botName, time){
|
||||
this.__unLockCommand();
|
||||
|
||||
if(botName in this.constructor.bots){
|
||||
@ -35,11 +115,11 @@ module.exports = {
|
||||
if(!bot.isReady){
|
||||
try{
|
||||
await bot.connect();
|
||||
var clear = setTimeout(()=> bot.quit(), 10000);
|
||||
var clear = setTimeout(()=> bot.quit(), time ? parseInt(time)*1000 : 10000);
|
||||
bot.whisper(from, 'I am ready')
|
||||
}catch(error){
|
||||
console.log('inv error connecting to bot');
|
||||
this.whisper('Bot is not available right now, try again in 30 seconds.');
|
||||
this.whisper(from, 'Bot is not available right now, try again in 30 seconds.');
|
||||
}
|
||||
}else{
|
||||
await this.whisper(from, `Bot ${bot.bot.entity.username} Already online`);
|
||||
|
@ -98,12 +98,18 @@ module.exports = {
|
||||
console.log('inv error connecting to bot');
|
||||
this.whisper('Bot is not available right now, try again in 30 seconds.');
|
||||
}
|
||||
var clear = setTimeout(()=> bot.quit(), 10000);
|
||||
var clear = setTimeout(()=>{
|
||||
bot.pluginUnload('Tp');
|
||||
bot.quit()
|
||||
}, 10000);
|
||||
}
|
||||
await bot.pluginLoad('Tp');
|
||||
await bot.bot.chat(`/invite ${from}`);
|
||||
await bot.whisper(from, `accept invite from ${bot.bot.entity.username} within 10 seconds...`);
|
||||
bot.on('message', (message) =>{
|
||||
bot.on('message', async (message) =>{
|
||||
if(message.toString() === `${from} teleported to you.`){
|
||||
await bot.pluginUnload('Tp');
|
||||
|
||||
if(clear){
|
||||
clearTimeout(clear);
|
||||
bot.quit();
|
||||
|
@ -8,81 +8,81 @@ const customerSlots = [5, 6, 7, 8, 14, 15, 16, 17, 23, 24, 25, 26];
|
||||
|
||||
|
||||
function findChestBySign(bot, text){
|
||||
let sign = bot.bot.findBlock({
|
||||
useExtraInfo: true,
|
||||
maxDistance: 32,
|
||||
matching: (block)=> {
|
||||
if(block.name.includes('sign') && block.signText.includes(text)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
});
|
||||
let sign = bot.bot.findBlock({
|
||||
useExtraInfo: true,
|
||||
maxDistance: 32,
|
||||
matching: (block)=> {
|
||||
if(block.name.includes('sign') && block.signText.includes(text)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return bot.bot.findBlock({
|
||||
point: sign.position,
|
||||
// maxDistance: 1,
|
||||
useExtraInfo: true,
|
||||
matching: block => block.name === 'chest'
|
||||
});
|
||||
return bot.bot.findBlock({
|
||||
point: sign.position,
|
||||
// maxDistance: 1,
|
||||
useExtraInfo: true,
|
||||
matching: block => block.name === 'chest'
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
'.trade': {
|
||||
desc: 'Bot will take trade requests',
|
||||
async function(from){
|
||||
/*
|
||||
todo
|
||||
'.trade': {
|
||||
desc: 'Bot will take trade requests',
|
||||
async function(from){
|
||||
/*
|
||||
todo
|
||||
|
||||
* Do... something if the users chest is full
|
||||
* Do... something if the users chest is full
|
||||
|
||||
*/
|
||||
*/
|
||||
|
||||
// Make the user has a chest then can add too.
|
||||
let chestBlock = findChestBySign(this, from);
|
||||
if(!chestBlock) return this.whisper(from, `You aren't allowed to trade with me...`);
|
||||
// Make the user has a chest then can add too.
|
||||
let chestBlock = findChestBySign(this, from);
|
||||
if(!chestBlock) return this.whisper(from, `You aren't allowed to trade with me...`);
|
||||
|
||||
await this.say('/trade accept');
|
||||
let window = await this.once('windowOpen');
|
||||
await this.say('/trade accept');
|
||||
let window = await this.once('windowOpen');
|
||||
|
||||
// If the process is taking to long, just stop
|
||||
let timeoutCheck = setTimeout(()=>{
|
||||
this.bot.closeWindow('window');
|
||||
this.bot.removeAllListeners('windowOpen');
|
||||
this.whisper(from, `I have things to do, I cant wait on you all day!`)
|
||||
}, 120000);
|
||||
// If the process is taking to long, just stop
|
||||
let timeoutCheck = setTimeout(()=>{
|
||||
this.bot.closeWindow('window');
|
||||
this.bot.removeAllListeners('windowOpen');
|
||||
this.whisper(from, `I have things to do, I cant wait on you all day!`)
|
||||
}, 120000);
|
||||
|
||||
// Check to see if the remote user has agreed to the trade.
|
||||
let confirmationCheck = setInterval(async ()=>{
|
||||
if(window.containerItems().filter(item => item?.slot == 53)[0].name == 'lime_dye'){
|
||||
this.bot.moveSlotItem(37, 37);
|
||||
}
|
||||
}, 500);
|
||||
// Check to see if the remote user has agreed to the trade.
|
||||
let confirmationCheck = setInterval(async ()=>{
|
||||
if(window.containerItems().filter(item => item?.slot == 53)[0].name == 'lime_dye'){
|
||||
this.bot.moveSlotItem(37, 37);
|
||||
}
|
||||
}, 500);
|
||||
|
||||
// Clean up when the trade is done
|
||||
await this.once('windowClose');
|
||||
clearInterval(confirmationCheck);
|
||||
// Clean up when the trade is done
|
||||
await this.once('windowClose');
|
||||
clearInterval(confirmationCheck);
|
||||
|
||||
// If the trade took so long it timed out, just kill the whole thing.
|
||||
if(timeoutCheck._destroyed) return;
|
||||
clearTimeout(timeoutCheck)
|
||||
// If the trade took so long it timed out, just kill the whole thing.
|
||||
if(timeoutCheck._destroyed) return;
|
||||
clearTimeout(timeoutCheck)
|
||||
|
||||
// Give MC a moment
|
||||
// await sleep(1000);
|
||||
// Give MC a moment
|
||||
// await sleep(1000);
|
||||
|
||||
let goBack = await this.goToReturn({where: chestBlock, reTry: true})
|
||||
let goBack = await this.goToReturn({where: chestBlock, reTry: true})
|
||||
|
||||
let isPutAway = await this.dumpToChest(chestBlock)
|
||||
let isPutAway = await this.dumpToChest(chestBlock)
|
||||
|
||||
await goBack();
|
||||
await goBack();
|
||||
|
||||
await this.whisper(from, `I put ${isPutAway ? 'all' : 'some'} items in your chest.`);
|
||||
}
|
||||
},
|
||||
'test': {
|
||||
desc: 'go away',
|
||||
allowed: ['useless666'],
|
||||
async function(from){
|
||||
let chestBlock = findChestBySign(this, from);
|
||||
}
|
||||
}
|
||||
await this.whisper(from, `I put ${isPutAway ? 'all' : 'some'} items in your chest.`);
|
||||
}
|
||||
},
|
||||
'test': {
|
||||
desc: 'go away',
|
||||
allowed: ['useless666'],
|
||||
async function(from){
|
||||
let chestBlock = findChestBySign(this, from);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user