forked from wmantly/mc-bot-town
329 lines
9.7 KiB
JavaScript
329 lines
9.7 KiB
JavaScript
'use strict';
|
|
|
|
const axios = require('axios');
|
|
const {sleep} = require('../utils');
|
|
const conf = require('../conf');
|
|
|
|
const {bot, henry, owen, linda, jimin, nova} = require('./mc-bot');
|
|
const pink_quotes = require('../model/pink_quotes')
|
|
|
|
let townMemebers = [
|
|
'wmantly', 'useless666', 'tux4242',
|
|
'VinceNL',
|
|
'Ethan63020', 'Ethan63021',
|
|
'pi_chef',
|
|
'EXLAlphaWolf', 'Sillychubbs',
|
|
'BearSkates420', 'hloop',
|
|
'ogeiDNight', 'BobinaBlu', 'Roby_G_27',
|
|
'kawiimeowz', 'RaindropCake24', 'KimiKava',
|
|
'Keebyys',
|
|
'YTMatze', 'mytzor',
|
|
'jj_disaster', 'Cuttaway',
|
|
'sonic_joe',
|
|
]
|
|
|
|
|
|
let ballOptions = [
|
|
"It is certain.",
|
|
"It is decidedly so.",
|
|
"Without a doubt.",
|
|
"Yes definitely.",
|
|
"You may rely on it.",
|
|
"As I see it, yes.",
|
|
"Most likely.",
|
|
"Outlook good.",
|
|
"Yes.",
|
|
"Signs point to yes.",
|
|
"Reply hazy, try again.",
|
|
"Ask again later.",
|
|
"Better not tell you now.",
|
|
"Cannot predict now.",
|
|
"Concentrate and ask again.",
|
|
"Don't count on it.",
|
|
"My reply is no.",
|
|
"My sources say no.",
|
|
"Outlook not so good.",
|
|
"Very doubtful.",
|
|
];
|
|
|
|
bot.addCommand('inv', {
|
|
desc: `Have bot invite you to its position.`,
|
|
allowed: townMemebers,
|
|
async function(from){
|
|
await this.say(`/invite ${from}`);
|
|
}
|
|
});
|
|
|
|
bot.addCommand('inv-nd', {
|
|
desc: `Get an invite to New Detroit.`,
|
|
ignoreLock: true,
|
|
allowed: townMemebers,
|
|
async function(from){
|
|
this.__unLockCommand();
|
|
await nova.connect();
|
|
await nova.bot.chat(`/invite ${from}`);
|
|
await this.whisper(from, `accept invite from ${nova.bot.entity.username} in 10 seconds...`)
|
|
let clear = setTimeout(()=>nova.quit(), 10000)
|
|
nova.on('message', (message) =>{
|
|
console.log(message.toString())
|
|
if(message.toString() === `${from} teleported to you.`){
|
|
nova.quit();
|
|
}
|
|
})
|
|
}
|
|
});
|
|
|
|
bot.addCommand('inv-sb', {
|
|
desc: `Get an invite to the Sky Base.`,
|
|
ignoreLock: true,
|
|
allowed: ['wmantly', 'useless666', 'tux4242', 'owenshorts', 'VinceNL', 'Ethan63020', 'Ethan63021'],
|
|
async function(from){
|
|
this.__unLockCommand();
|
|
await owen.connect();
|
|
await owen.bot.chat(`/invite ${from}`);
|
|
await this.whisper(from, `accept invite from ${owen.bot.entity.username} in 10 seconds...`)
|
|
let clear = setTimeout(()=>owen.quit(), 10000)
|
|
owen.on('message', (message) =>{
|
|
console.log(message.toString())
|
|
if(message.toString() === `${from} teleported to you.`){
|
|
owen.quit();
|
|
}
|
|
});
|
|
}
|
|
});
|
|
|
|
bot.addCommand('inv-german', {
|
|
desc: `Get an invite you Germans.`,
|
|
ignoreLock: true,
|
|
allowed: ['wmantly', 'useless666', 'tux4242', 'owenshorts', 'VinceNL', 'Ethan63020', 'Ethan63021', 'pi_chef'],
|
|
async function(from){
|
|
this.__unLockCommand();
|
|
await linda.connect();
|
|
await linda.bot.chat(`/invite ${from}`);
|
|
await this.whisper(from, `accept invite from ${linda.bot.entity.username} in 10 seconds...`)
|
|
let clear = setTimeout(()=>linda.quit(), 10000)
|
|
linda.on('message', (message) =>{
|
|
console.log(message.toString())
|
|
if(message.toString() === `${from} teleported to you.`){
|
|
linda.quit();
|
|
}
|
|
});
|
|
}
|
|
});
|
|
|
|
bot.addCommand('inv-fo', {
|
|
desc: `Get an invite to the Farming outpost.`,
|
|
ignoreLock: true,
|
|
allowed: ['wmantly', 'useless666', 'tux4242', 'pi_chef'],
|
|
async function(from){
|
|
this.__unLockCommand();
|
|
await jimin.connect();
|
|
await jimin.bot.chat(`/invite ${from}`);
|
|
await this.whisper(from, `accept invite from ${jimin.bot.entity.username} in 10 seconds...`)
|
|
let clear = setTimeout(()=>jimin.quit(), 10000)
|
|
jimin.on('message', (message) =>{
|
|
console.log(message.toString())
|
|
if(message.toString() === `${from} teleported to you.`){
|
|
jimin.quit();
|
|
}
|
|
});
|
|
}
|
|
});
|
|
|
|
bot.addCommand('inv-fo', {
|
|
desc: `Get an invite to the Farming outpost.`,
|
|
ignoreLock: true,
|
|
allowed: ['wmantly', 'useless666', 'tux4242', 'pi_chef'],
|
|
async function(from){
|
|
this.__unLockCommand();
|
|
await jimin.connect();
|
|
await jimin.bot.chat(`/invite ${from}`);
|
|
await this.whisper(from, `accept invite from ${jimin.bot.entity.username} in 10 seconds...`)
|
|
let clear = setTimeout(()=>jimin.quit(), 10000)
|
|
jimin.on('message', (message) =>{
|
|
console.log(message.toString())
|
|
if(message.toString() === `${from} teleported to you.`){
|
|
jimin.quit();
|
|
}
|
|
});
|
|
}
|
|
});
|
|
|
|
bot.addCommand('inv-fo2', {
|
|
desc: `Get an invite to the Farming outpost 2.`,
|
|
ignoreLock: true,
|
|
allowed: ['wmantly', 'useless666', 'tux4242', 'pi_chef'],
|
|
async function(from){
|
|
this.__unLockCommand();
|
|
await henry.connect();
|
|
await henry.bot.chat(`/invite ${from}`);
|
|
await this.whisper(from, `accept invite from ${henry.bot.entity.username} in 10 seconds...`)
|
|
let clear = setTimeout(()=>henry.quit(), 10000)
|
|
henry.on('message', (message) =>{
|
|
console.log(message.toString())
|
|
if(message.toString() === `${from} teleported to you.`){
|
|
henry.quit();
|
|
}
|
|
});
|
|
}
|
|
});
|
|
|
|
|
|
bot.addCommand('.invite', {
|
|
desc: `The bot will /accept an /invite from you.`,
|
|
allowed: ['wmantly', 'useless666', 'tux4242', 'owenshorts', 'BobinaBlu'],
|
|
async function(from){
|
|
await this.whisper('Coming');
|
|
await this.say(`/accept`);
|
|
}
|
|
});
|
|
|
|
bot.addCommand('say', {
|
|
desc: `Make bot say stuff.`,
|
|
allowed: ['wmantlys', 'useless666', 'tux4242'],
|
|
ignoreLock: true,
|
|
async function(from, ...messages){
|
|
await this.say((messages || []).join(' '));
|
|
}
|
|
});
|
|
|
|
bot.addCommand("joke", {
|
|
desc: "Tells a random joke.",
|
|
async function(from){
|
|
await this.say('> Let me think...');
|
|
let res = await axios.get('https://v2.jokeapi.dev/joke/Any?type=single')
|
|
await this.say(...res.data.joke.split('\n').map(e => `> ${e}`));
|
|
},
|
|
});
|
|
|
|
bot.addCommand("quote", {
|
|
desc: 'Say an inspirational quote.',
|
|
async function(from){
|
|
await this.say('> Right away!');
|
|
let res = await axios.get('https://zenquotes.io/api/random')
|
|
await this.say(`> ${res.data[0].q} -- ${res.data[0].a}`);
|
|
}
|
|
});
|
|
|
|
bot.addCommand('west-quote', {
|
|
desc: `Say a random Kanye West quote.`,
|
|
async function(from) {
|
|
await this.say('> And here we go!');
|
|
let res = await axios.get('https://api.kanye.rest/');
|
|
await this.say(`> ${res.data.quote} -- Kanye West`);
|
|
}
|
|
});
|
|
|
|
bot.addCommand('pink-quote', {
|
|
desc: `Say a random Pink Floyd quote.`,
|
|
async function(from) {
|
|
await this.say(
|
|
`> Rock 'n' Roll`,
|
|
`> ${pink_quotes[Math.floor(Math.random()*pink_quotes.length)]} -- Pink Floyd`
|
|
);
|
|
}
|
|
});
|
|
|
|
bot.addCommand("fact", {
|
|
desc: `Say a random fact.`,
|
|
async function(from){
|
|
await this.say('> The internet says this is true?');
|
|
let res = await axios.get('https://uselessfacts.jsph.pl/random.json?language=en')
|
|
await this.say(
|
|
`> ${res.data.text}`,
|
|
`> source: ${res.data.source}`
|
|
);
|
|
}
|
|
});
|
|
|
|
bot.addCommand("advice", {
|
|
desc: `Say some random advice.`,
|
|
async function(from){
|
|
await this.say('> Try this:');
|
|
let res = await axios.get('https://api.adviceslip.com/advice');
|
|
await this.say(`> ${res.data.slip.advice}`);
|
|
}
|
|
});
|
|
|
|
bot.addCommand('idea', {
|
|
desc: `Say a random start up idea.`,
|
|
async function(from){
|
|
await this.say('> How about?');
|
|
let res = await axios.get('https://itsthisforthis.com/api.php?text')
|
|
await this.say(`> ${res.data}`);
|
|
}
|
|
});
|
|
|
|
bot.addCommand('discord', {
|
|
desc: `Say the CJ discord invite link.`,
|
|
async function(from) {
|
|
await this.say('https://discord.gg/hyby9m8');
|
|
}
|
|
});
|
|
|
|
bot.addCommand('8ball',{
|
|
desc: `magic 8 Ball pick.`,
|
|
async function(from){
|
|
await this.say(
|
|
`> The 8 Ball says...`,
|
|
`> ${ballOptions[Math.floor(Math.random()*ballOptions.length)]}`
|
|
);
|
|
}
|
|
});
|
|
|
|
bot.addCommand('dice',{
|
|
desc: `Roll a die. You can state the max size on the dice. Default is 6.`,
|
|
async function(from, size){
|
|
size = size || 6;
|
|
if(!Number.isInteger(Number(size))){
|
|
this.whisper(from, `${size} is not a whole number...`)
|
|
return ;
|
|
}
|
|
await this.say(
|
|
`> Rolling a dice for ${from}`,
|
|
`> ${Math.floor(Math.random()*size)+1}`
|
|
);
|
|
}
|
|
});
|
|
|
|
bot.addCommand('random-player', {
|
|
desc: `Return a random online player.`,
|
|
async function(from){
|
|
let players = bot.getPlayers()
|
|
|
|
delete players[bot.bot.entity.username]
|
|
|
|
let keys = Object.keys(players);
|
|
let player = players[keys[ keys.length * Math.random() << 0]];
|
|
|
|
await this.say(`> I pick [${player.lvl}]${player.username}`)
|
|
}
|
|
});
|
|
|
|
bot.addCommand('flip', {
|
|
desc: `Flip a coin.`,
|
|
async function(from){
|
|
await this.say(
|
|
`> Flipping a coin for ${from}`,
|
|
`> ${!!(Math.floor(Math.random() * (3000 - 1500) + 1500)%2) ? "Heads" : "Tails"}`
|
|
);
|
|
}
|
|
});
|
|
|
|
bot.addCommand('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 || ''}`
|
|
));
|
|
}
|
|
});
|
|
|
|
module.exports = {bot};
|