@@ -1,11 +1,10 @@
"use strict";
'use strict';

//todo: remove me?
// todo: remove me?

const fs = require('fs');

let exports = {
};
let exports = {};

const FILENAME = 'cuckbot-config.json';
const AUTHFILENAME = 'cuckbot-auth.json';
@@ -26,17 +25,19 @@ let reload = () => {

exports.reload = reload;

// noinspection Eslint
let parsed = JSON.parse(fs.readFileSync(AUTHFILENAME, 'utf8'));

exports.auth = {};

// noinspection Eslint
for (var key in parsed) {
exports.auth[key] = parsed[key];
}

exports.reload = reload;
} catch (e) {
if (e.code == 'ENOENT') {
if (e.code === 'ENOENT') {
// File doesn't exist
console.log(`Error: The file ${e.path} doesn't exist!`);
} else {
@@ -16,5 +16,15 @@
"thinky": "^2.3.6",
"url": "^0.11.0",
"ytdl-core": "^0.7.15"
},
"devDependencies": {
"eslint": "^3.5.0",
"eslint-config-airbnb": "^11.1.0",
"eslint-config-standard": "^6.0.1",
"eslint-plugin-import": "^1.15.0",
"eslint-plugin-jsx-a11y": "^2.2.2",
"eslint-plugin-promise": "^2.0.1",
"eslint-plugin-react": "^6.3.0",
"eslint-plugin-standard": "^2.0.0"
}
}
@@ -1,51 +1,51 @@
"use strict";
'use strict';

const dongerino = require("../resources/dongerinos.json").dongerino;
const dongerino = require('../resources/dongerinos.json').dongerino;

let asciiPictures = {
"salt": {
usage: "Displays salt ascii picture in chat",
delete: true,
type: "ascii",
process: (bot, msg) => {
let channel = msg.channel;
'salt': {
usage: 'Displays salt ascii picture in chat',
delete: true,
type: 'ascii',
process: (bot, msg) => {
let channel = msg.channel;

channel.sendMessage('\n\n▒▒▒▒▒▒▒▒▒▒▒▒▒▒▄▄██████▄\n' +
'▒▒▒▒▒▒▒▒▒▒▄▄████████████▄\n' +
'▒▒▒▒▒▒▄▄██████████████████\n' +
'▒▒▒▄████▀▀▀██▀██▌███▀▀▀████\n' +
'▒▒▐▀████▌▀██▌▀▐█▌████▌█████▌\n' +
'▒▒█▒▒▀██▀▀▐█▐█▌█▌▀▀██▌██████\n' +
'▒▒█▒▒▒▒████████████████████▌\n' +
'▒▒▒▌▒▒▒▒█████░░░░░░░██████▀\n' +
'▒▒▒▀▄▓▓▓▒███░░░░░░█████▀▀\n' +
'▒▒▒▒▀░▓▓▒▐█████████▀▀▒\n' +
'▒▒▒▒▒░░▒▒▐█████▀▀▒▒▒▒▒▒\n' +
'▒▒░░░░░▀▀▀▀▀▀▒▒▒▒▒▒▒▒▒\n');
}
},
"dongerino": {
usage: "Prints a random ascii dongerino in chat",
delete: true,
type: "ascii",
process: (bot, msg) => {
let channel = msg.channel;
channel.sendMessage('\n\n▒▒▒▒▒▒▒▒▒▒▒▒▒▒▄▄██████▄\n' +
'▒▒▒▒▒▒▒▒▒▒▄▄████████████▄\n' +
'▒▒▒▒▒▒▄▄██████████████████\n' +
'▒▒▒▄████▀▀▀██▀██▌███▀▀▀████\n' +
'▒▒▐▀████▌▀██▌▀▐█▌████▌█████▌\n' +
'▒▒█▒▒▀██▀▀▐█▐█▌█▌▀▀██▌██████\n' +
'▒▒█▒▒▒▒████████████████████▌\n' +
'▒▒▒▌▒▒▒▒█████░░░░░░░██████▀\n' +
'▒▒▒▀▄▓▓▓▒███░░░░░░█████▀▀\n' +
'▒▒▒▒▀░▓▓▒▐█████████▀▀▒\n' +
'▒▒▒▒▒░░▒▒▐█████▀▀▒▒▒▒▒▒\n' +
'▒▒░░░░░▀▀▀▀▀▀▒▒▒▒▒▒▒▒▒\n');
}
},
'dongerino': {
usage: 'Prints a random ascii dongerino in chat',
delete: true,
type: 'ascii',
process: (bot, msg) => {
let channel = msg.channel;

let number = Math.floor(Math.random() * (dongerino.length));
let number = Math.floor(Math.random() * (dongerino.length));

channel.sendMessage(dongerino[number]);
}
},
"lenny": {
usage: "Post lenny face meme in chat",
delete: false,
type: "image",
process: (bot, msg) => {
let channel = msg.channel;
channel.sendMessage(dongerino[number]);
}
},
'lenny': {
usage: 'Post lenny face meme in chat',
delete: false,
type: 'image',
process: (bot, msg) => {
let channel = msg.channel;

channel.sendMessage("( ͡° ͜ʖ ͡°)");
}
channel.sendMessage('( ͡° ͜ʖ ͡°)');
}
}
};

exports.asciiPictures = asciiPictures;
exports.asciiPictures = asciiPictures;

Large diffs are not rendered by default.

@@ -1,80 +1,80 @@
"use strict";
'use strict';

const CONSTANTS = require('../constants.js');
const woody = require('../resources/random.json').rapeywoody;

let sendFileToChannel = (channel, file) => {
channel.sendFile(file).catch(err => {
console.log(`Error sending file: ${file} to channel. Error: ${err}`);
});
channel.sendFile(file).catch(err => {
console.log(`Error sending file: ${file} to channel. Error: ${err}`);
});
};

let images = {
"feelsgoodman": {
usage: "Displays feelsgoodman meme in chat",
delete: true,
type: "image",
process: (bot, msg) => {
let channel = msg.channel;
'feelsgoodman': {
usage: 'Displays feelsgoodman meme in chat',
delete: true,
type: 'image',
process: (bot, msg) => {
let channel = msg.channel;

sendFileToChannel(channel, CONSTANTS.FEELSGOODMAN);
// channel.sendFile(CONSTANTS.FEELSGOODMAN).catch(err => {
// console.log('Error sending \'feelsgoodman meme\': ' + err);
// });
}
},
"feelsbadman": {
usage: "Displays feelsbadman meme in chat",
delete: true,
type: "image",
process: (bot, msg) => {
let channel = msg.channel;
sendFileToChannel(channel, CONSTANTS.FEELSGOODMAN);
// channel.sendFile(CONSTANTS.FEELSGOODMAN).catch(err => {
// console.log('Error sending \'feelsgoodman meme\': ' + err);
// });
}
},
'feelsbadman': {
usage: 'Displays feelsbadman meme in chat',
delete: true,
type: 'image',
process: (bot, msg) => {
let channel = msg.channel;

sendFileToChannel(channel, CONSTANTS.FEELSBADMAN);
}
},
"finishme": {
usage: "Displays White Creamy Finishing Sauce",
delete: true,
type: "image",
process: (bot, msg) => {
let channel = msg.channel;
sendFileToChannel(channel, CONSTANTS.FEELSBADMAN);
}
},
'finishme': {
usage: 'Displays White Creamy Finishing Sauce',
delete: true,
type: 'image',
process: (bot, msg) => {
let channel = msg.channel;

sendFileToChannel(channel, CONSTANTS.FINISHME);
}
},
"needful": {
usage: "Displays 'Do the needful' meme",
delete: true,
type: "image",
process: (bot, msg) => {
let channel = msg.channel;
sendFileToChannel(channel, CONSTANTS.FINISHME);
}
},
'needful': {
usage: 'Displays \'Do the needful\' meme',
delete: true,
type: 'image',
process: (bot, msg) => {
let channel = msg.channel;

sendFileToChannel(channel, CONSTANTS.NEEDFUL);
}
},
"woody": {
usage: "Displays random 'rapey woody' meme",
delete: true,
type: "image",
process: (bot, msg) => {
let channel = msg.channel;
sendFileToChannel(channel, CONSTANTS.NEEDFUL);
}
},
'woody': {
usage: 'Displays random \'rapey woody\' meme',
delete: true,
type: 'image',
process: (bot, msg) => {
let channel = msg.channel;

let number = Math.floor(Math.random() * (woody.length));
let number = Math.floor(Math.random() * (woody.length));

sendFileToChannel(channel, woody[number]);
}
},
"fishmonster": {
usage: "Post fishmonster Ted Cruz",
delete: true,
type: "image",
process: (bot, msg) => {
let channel = msg.channel;
sendFileToChannel(channel, woody[number]);
}
},
'fishmonster': {
usage: 'Post fishmonster Ted Cruz',
delete: true,
type: 'image',
process: (bot, msg) => {
let channel = msg.channel;

sendFileToChannel(channel, CONSTANTS.FISHMONSTER);
}
sendFileToChannel(channel, CONSTANTS.FISHMONSTER);
}
}
};
exports.images = images;

exports.images = images;
@@ -1,41 +1,39 @@
"use strict";
'use strict';

const thinky = require('../dbModels/thinky.js');
const CustomCommandModel = require('../dbModels/customCommand');
const Sounds = require('./sounds.js');
const Images = require('./images.js');
const Ascii = require('./asciiPictures.js');
const Utilities = require('./utilities.js');
const Urban = require('./urban.js');
const CustomCommands = require('./customCommands.js');
const util = require('util');

let loadDbCommands = () => {
CustomCommandModel.run({readMode: 'majority'}).then( (dbCommands) => {
let dbCmdObj = { };

for (let cmd of dbCommands) {
switch(cmd.commandType){
case 'image':
dbCmdObj[cmd.commandText.slice(1).toString()] = CustomCommands.customCommands["dbimagecommand"];
break;

case 'text':
dbCmdObj[cmd.commandText.slice(1).toString()] = CustomCommands.customCommands["dbtextcommand"];
break;

case 'sound':
dbCmdObj[cmd.commandText.slice(1).toString()] = CustomCommands.customCommands["dbsoundcommand"];
break;
}
}

const Commands = require('../bot.js').Commands;

Object.assign(Commands, Images.images, Sounds.sounds, Ascii.asciiPictures, Utilities.utilities, Urban.urban, CustomCommands.customCommands, dbCmdObj);
// console.log(`Commands: ${util.inspect(Commands)}`);
console.log("Cuckbot is ready!");
});
CustomCommandModel.run({readMode: 'majority'}).then((dbCommands) => {
let dbCmdObj = {};

for (let cmd of dbCommands) {
switch (cmd.commandType) {
case 'image':
dbCmdObj[cmd.commandText.slice(1).toString()] = CustomCommands.customCommands['dbimagecommand'];
break;

case 'text':
dbCmdObj[cmd.commandText.slice(1).toString()] = CustomCommands.customCommands['dbtextcommand'];
break;

case 'sound':
dbCmdObj[cmd.commandText.slice(1).toString()] = CustomCommands.customCommands['dbsoundcommand'];
break;
}
}

const Commands = require('../bot.js').Commands;

Object.assign(Commands, Images.images, Sounds.sounds, Ascii.asciiPictures, Utilities.utilities, Urban.urban, CustomCommands.customCommands, dbCmdObj);
// console.log(`Commands: ${util.inspect(Commands)}`);
console.log('Cuckbot is ready!');
});
};

exports.loadDbCommands = loadDbCommands;
exports.loadDbCommands = loadDbCommands;

Large diffs are not rendered by default.

@@ -1,32 +1,31 @@
"use strict";
'use strict';

const Promise = require('promise');
const agent = require('superagent-promise')(require('superagent'), Promise);
const util = require('util');

const urbanApi = "http://api.urbandictionary.com/v0/define?term=";
const urbanApi = 'http://api.urbandictionary.com/v0/define?term=';

let urban = {
"urban" : {
usage: "Searches Urban Dictionary for a user-provided search term",
delete: true,
type: "query",
cooldown: 5,
process: (bot, msg, suffix) => {
agent('GET', `${urbanApi}${suffix}`)
.then(json => {
let result = JSON.parse(json.res.text).list[0];
'urban': {
usage: 'Searches Urban Dictionary for a user-provided search term',
delete: true,
type: 'query',
cooldown: 5,
process: (bot, msg, suffix) => {
agent('GET', `${urbanApi}${suffix}`)
.then(json => {
let result = JSON.parse(json.res.text).list[0];

if (result === null) {
msg.channel.sendMessage(`\`\`\`\n${suffix} has no definition!\n\`\`\``);
return;
}

let response = `**${suffix}**\n\n\`\`\`\n${result.definition}\n\`\`\`\n\n**Example:** ${result.example}\n<${result.permalink}>`;
msg.channel.sendMessage(response);
});
if (result === null) {
msg.channel.sendMessage(`\`\`\`\n${suffix} has no definition!\n\`\`\``);
return;
}

let response = `**${suffix}**\n\n\`\`\`\n${result.definition}\n\`\`\`\n\n**Example:** ${result.example}\n<${result.permalink}>`;
msg.channel.sendMessage(response);
});
}
}
};

exports.urban = urban;
exports.urban = urban;
@@ -1,171 +1,176 @@
"use strict";
'use strict';

const thinky = require('../dbModels/thinky.js');
const CustomCommand = require('../dbModels/customCommand.js');
const util = require('util');
const admins = require('../admins.json');
const _ = require('lodash');

let buildHelpMessage = (imageCommands, textCommands, soundCommands) => {
let message = "Here\'s a list of my commands:\n\n" +
"Command prefix (trigger) character is **\'~\'**\n\n" +
"To create a custom command, use the following format:\n" +
"\`\`\`xl\n" +
"~createcommand ~[commandname]|[commandtype ex: image, text, sound]|[imageurl, responsetext, yturl]|[starttime (format: 00:00:00)]|[duration (07 (seconds))\n" +
"Examples:\n\nSound:\n~createcommand ~test|sound|https://www.youtube.com/watch?v=dQw4w9WgXcQ|00:00:43|07\n" +
"Image:\n~createcommand ~imagetest|image|http://i.imgur.com/kTRCbX0.gif\n" +
"\`\`\`\n\n" +
"To delete a command, use the following command\n" +
"\`\`\`xl\n" +
"~deletecommand ~[commandname]\n" +
"Example:\n\nto delete a command that is triggered by typing ~facepalm, type '~deletecommand ~facepalm'\n" +
"\`\`\`\n\n" +
"__**Sounds**__\n\n\`\`\`xl\n" +
"cena: BOO-DO-DO-DOOOOOO\n" +
"cenahorn: BOO-DO-DO-DOOOOOO (with airhorns)\n" +
"yeslawd: YES LAWD\n" +
"yesnigga: YES NIGGA\n" +
"watermalone: Random \'watermalone\' \n" +
"asslick\/dickpunch\/fuckenter: John Cena Quotes From \'Trainwreck\'\n" +
"pawnch: Heavys Falcon Punch (TF2)\n" +
"ohshit: Oh Shiiiiiiit\n" +
"sob: \'You Son Of A Bitch\'\n" +
"dinos: \'Who Killed The Dinos\?\'\n" +
"fua: \'Fuck You Asshole\'\n" +
"spine: \'Break Your God Damn Spine\'\n" +
"stfu: \'SHUT UP\'\n" +
"boris: \'I Am INVINCIBLE\'\n" +
"bs: \'BULLSHIT\'\n" +
"cocainum: \'COCAINUM\'\n" +
"gfym: GRAPEFRUIT\n" +
"dicksout: DICKS OUT FOR HARAMBE\n\`\`\`\n\n";

if(soundCommands.length > 0){
message += "__**Custom Sounds**__\n\n\`\`\`xl\n";

for (let sound of soundCommands) {
message += `${sound.commandText.slice(1)}\n`;
}

message += `\`\`\`\n\n`;
let message = 'Here\'s a list of my commands:\n\n' +
'Command prefix (trigger) character is **\'~\'**\n\n' +
'To create a custom command, use the following format:\n' +
'```xl\n' +
'~createcommand ~[commandname]|[commandtype ex: image, text, sound]|[imageurl, responsetext, yturl]|[starttime (format: 00:00:00)]|[duration (07 (seconds))\n' +
'Examples:\n\nSound:\n~createcommand ~test|sound|https://www.youtube.com/watch?v=dQw4w9WgXcQ|00:00:43|07\n' +
'Image:\n~createcommand ~imagetest|image|http://i.imgur.com/kTRCbX0.gif\n' +
'```\n\n' +
'To delete a command, use the following command\n' +
'```xl\n' +
'~deletecommand ~[commandname]\n' +
'Example:\n\nto delete a command that is triggered by typing ~facepalm, type \'~deletecommand ~facepalm\'\n' +
'```\n\n' +
'__**Sounds**__\n\n```xl\n' +
'cena: BOO-DO-DO-DOOOOOO\n' +
'cenahorn: BOO-DO-DO-DOOOOOO (with airhorns)\n' +
'yeslawd: YES LAWD\n' +
'yesnigga: YES NIGGA\n' +
'watermalone: Random \'watermalone\' \n' +
'asslick/dickpunch/fuckenter: John Cena Quotes From \'Trainwreck\'\n' +
'pawnch: Heavys Falcon Punch (TF2)\n' +
'ohshit: Oh Shiiiiiiit\n' +
'sob: \'You Son Of A Bitch\'\n' +
'dinos: \'Who Killed The Dinos?\'\n' +
'fua: \'Fuck You Asshole\'\n' +
'spine: \'Break Your God Damn Spine\'\n' +
'stfu: \'SHUT UP\'\n' +
'boris: \'I Am INVINCIBLE\'\n' +
'bs: \'BULLSHIT\'\n' +
'cocainum: \'COCAINUM\'\n' +
'gfym: GRAPEFRUIT\n' +
'dicksout: DICKS OUT FOR HARAMBE\n```\n\n';

if (soundCommands.length > 0) {
message += '__**Custom Sounds**__\n\n```xl\n';

for (let sound of soundCommands) {
message += `${sound.commandText.slice(1)}\n`;
}

message += "__**Images**__\n\n\`\`\`xl\n" +
"feelsgoodman: Feelsgoodman Meme\n" +
"feelsbadman: Feelsbadman Meme\n" +
"woody: Random \'Rapey Woody\' Meme\n" +
"finishme: White Creamy Sauce\n" +
"needful: Do The Needful\`\`\`\n\n";
message += `\`\`\`\n\n`;
}

if (imageCommands.length > 0) {
message += "__**Custom Images**__\n\n\`\`\`xl\n";
message += '__**Images**__\n\n```xl\n' +
'feelsgoodman: Feelsgoodman Meme\n' +
'feelsbadman: Feelsbadman Meme\n' +
'woody: Random \'Rapey Woody\' Meme\n' +
'finishme: White Creamy Sauce\n' +
'needful: Do The Needful```\n\n';

for (let image of imageCommands) {
message += `${image.commandText.slice(1)}\n`;
}
if (imageCommands.length > 0) {
message += '__**Custom Images**__\n\n```xl\n';

message += "\`\`\`\n\n";
for (let image of imageCommands) {
message += `${image.commandText.slice(1)}\n`;
}

message += "__**Text**__\n\n\`\`\`xl\n";
message += "dongerino: Random ASCII Dick\n" +
"salt: ASCII Salt\n" +
"lenny: Lenny Face Meme\`\`\`\n\n";
message += '```\n\n';
}

if (textCommands.length > 0) {
message += "__**Custom Text**__\n\n\`\`\`xl\n";
message += '__**Text**__\n\n```xl\n';
message += 'dongerino: Random ASCII Dick\n' +
'salt: ASCII Salt\n' +
'lenny: Lenny Face Meme```\n\n';

for (let text of textCommands) {
message += `${text.commandText.slice(1)}\n`;
}
if (textCommands.length > 0) {
message += '__**Custom Text**__\n\n```xl\n';

message += "\`\`\`\n";
for (let text of textCommands) {
message += `${text.commandText.slice(1)}\n`;
}

return message;
message += '```\n';
}

return message;
};

let utilities = {
"cuckhelp": {
usage: "~cuckhelp",
delete: false,
type: "utilities",
process: (bot, msg) => {
CustomCommand.filter({serverId: msg.server.id}).run({readMode: 'majority'}).then((result) => {
let imageCommands = result.filter((cmd) => { return cmd.commandType == 'image'});
let textCommands = result.filter((cmd) => { return cmd.commandType == 'text'});
let soundCommands = result.filter((cmd) => { return cmd.commandType == 'sound'});

let message = buildHelpMessage(imageCommands, textCommands, soundCommands);

msg.author.sendMessage(message).then(() => { msg.reply(`I've sent you my commands via PM`)});
});
}
},
"clear": {
usage: "~clear (number of messages to remove from the chat log)",
delete: true,
type: "utilities",
process: (bot, msg, suffix) => {
let args = suffix.split(" ");

let adminsArray = Array.from(admins["admins"]);

if (!_.includes(adminsArray, msg.author.id.toString())) {
msg.reply("You don't have access to this command. :middle_finger:");
return;
}

console.log('commandOptions: ' + suffix);
if (args.length > 2) {
msg.reply("Incorrect usage! There are too many parameters for that command.");
return;
}


let numberToDelete = Number(args[0]);

// there was a user mentioned, so we delete that specific users messages.
if (args.length == 2) {
let user = msg.mentions.users.first();
let counter = 0;
msg.channel.fetchMessages({limit: numberToDelete * 3}).then(messages => {
let deleteMessages = messages.filter(message => {
if (counter < numberToDelete && user.id == message.author.id) {
return message;
} else {
}
});

msg.channel.bulkDelete(deleteMessages).then(msgs => {
console.log(`Removed the last ${msgs.size()} messages from ${user.username}`);
});
});
} else { // do a regular bulk delete
msg.channel.fetchMessages({limit: numberToDelete}).then(messages => {
msg.channel.bulkDelete(messages);
});
'cuckhelp': {
usage: '~cuckhelp',
delete: false,
type: 'utilities',
process: (bot, msg) => {
CustomCommand.filter({serverId: msg.server.id}).run({readMode: 'majority'}).then((result) => {
let imageCommands = result.filter((cmd) => {
return cmd.commandType === 'image';
});
let textCommands = result.filter((cmd) => {
return cmd.commandType === 'text';
});
let soundCommands = result.filter((cmd) => {
return cmd.commandType === 'sound';
});

let message = buildHelpMessage(imageCommands, textCommands, soundCommands);

msg.author.sendMessage(message).then(() => {
msg.reply(`I've sent you my commands via PM`);
});
});
}
},
'clear': {
usage: '~clear (number of messages to remove from the chat log)',
delete: true,
type: 'utilities',
process: (bot, msg, suffix) => {
let args = suffix.split(' ');

let adminsArray = Array.from(admins['admins']);

if (!_.includes(adminsArray, msg.author.id.toString())) {
msg.reply('You don\'t have access to this command. :middle_finger:');
return;
}

console.log('commandOptions: ' + suffix);
if (args.length > 2) {
msg.reply('Incorrect usage! There are too many parameters for that command.');
return;
}

let numberToDelete = Number(args[0]);

// there was a user mentioned, so we delete that specific users messages.
if (args.length === 2) {
let user = msg.mentions.users.first();
let counter = 0;
msg.channel.fetchMessages({limit: numberToDelete * 3}).then(messages => {
let deleteMessages = messages.filter(message => {
if (counter < numberToDelete && user.id === message.author.id) {
return message;
} else {
}

// bot.getChannelLogs(channel, numberToDelete).then( messages => {
// bot.deleteMessages(messages).catch( err => {
// console.log("there was a problem deleting messages: " + err);
// });
// }).catch(err => {
// console.log('error collecting messages for removal: ' + err);
// });
}
},
"reloadcommands": {
usage: "~reloadcommands",
delete: true,
type: "utilities",
process: () => {
const loadDbCommands = require('./loadDbCommands.js').loadDbCommands;

loadDbCommands();
}
});

msg.channel.bulkDelete(deleteMessages).then(msgs => {
console.log(`Removed the last ${msgs.size()} messages from ${user.username}`);
});
});
} else { // do a regular bulk delete
msg.channel.fetchMessages({limit: numberToDelete}).then(messages => {
msg.channel.bulkDelete(messages);
});
}

// bot.getChannelLogs(channel, numberToDelete).then( messages => {
// bot.deleteMessages(messages).catch( err => {
// console.log("there was a problem deleting messages: " + err);
// });
// }).catch(err => {
// console.log('error collecting messages for removal: ' + err);
// });
}
},
'reloadcommands': {
usage: '~reloadcommands',
delete: true,
type: 'utilities',
process: () => {
const loadDbCommands = require('./loadDbCommands.js').loadDbCommands;

loadDbCommands();
}
}
};

exports.utilities = utilities;
exports.utilities = utilities;