Grammar fixes and un-hardcode bot-sandbox

This commit is contained in:
aayanl 2018-02-06 02:53:59 -05:00
parent 623250e1b4
commit ad848c3ab1
No known key found for this signature in database
GPG key ID: 4D77183E3E121D71
2 changed files with 21 additions and 19 deletions

View file

@ -4,6 +4,7 @@ const bitcoin = require('bitcoin');
let config = require('config'); let config = require('config');
config = config.get('lbrycrd'); config = config.get('lbrycrd');
const lbry = new bitcoin.Client(config); const lbry = new bitcoin.Client(config);
let moderation = config.get('moderation');
exports.commands = [ exports.commands = [
"tip", "tip",
@ -17,13 +18,13 @@ exports.tip = {
let tipper = msg.author.id.replace('!', ''), let tipper = msg.author.id.replace('!', ''),
words = msg.content.trim().split(' ').filter(function (n) { return n !== ""; }), words = msg.content.trim().split(' ').filter(function (n) { return n !== ""; }),
subcommand = words.length >= 2 ? words[1] : 'help', subcommand = words.length >= 2 ? words[1] : 'help',
helpmsgparts = [['[help]', 'Get this message'], helpmsgparts = [['[help]', 'Get this message.'],
['balance', 'Get your balance'], ['balance', 'Get your balance.'],
['deposit', 'Get address for your deposits'], ['deposit', 'Get address for your deposits.'],
['withdraw ADDRESS AMOUNT', 'Withdraw AMOUNT credits to ADDRESS'], ['withdraw ADDRESS AMOUNT', 'Withdraw AMOUNT credits to ADDRESS'],
['[private] <user> <amount>', 'Mention a user with @ and then the amount to tip them, or put private before the user to tip them privately.']], ['[private] <user> <amount>', 'Mention a user with @ and then the amount to tip them, or put private before the user to tip them privately.']],
helpmsg = '```**!tip**\n' + formatDescriptions(helpmsgparts) + 'Key: [] : Optionally include contained keyword, <> : Replace with appropriate value.```', helpmsg = '```**!tip**\n' + formatDescriptions(helpmsgparts) + 'Key: [] : Optionally include contained keyword, <> : Replace with appropriate value.```',
channelwarning = 'Please use <#369896313082478594> or DMs to talk to bots.'; channelwarning = 'Please use <'+ moderation.sandboxchannel + '> or DMs to talk to bots.';
switch (subcommand) { switch (subcommand) {
case 'help': privateOrSandboxOnly(msg, channelwarning, doHelp, [helpmsg]); break; case 'help': privateOrSandboxOnly(msg, channelwarning, doHelp, [helpmsg]); break;
case 'balance': doBalance(msg, tipper); break; case 'balance': doBalance(msg, tipper); break;
@ -41,11 +42,11 @@ exports.multitip = {
let tipper = msg.author.id.replace('!', ''), let tipper = msg.author.id.replace('!', ''),
words = msg.content.trim().split(' ').filter(function (n) { return n !== ""; }), words = msg.content.trim().split(' ').filter(function (n) { return n !== ""; }),
subcommand = words.length >= 2 ? words[1] : 'help', subcommand = words.length >= 2 ? words[1] : 'help',
helpmsgparts = [['[help]', 'Get this message'], helpmsgparts = [['[help]', 'Get this message.'],
['<user>+ <amount>', 'Mention one or more users in a row, seperated by spaces, then an amount that each mentioned user will receive.'], ['<user>+ <amount>', 'Mention one or more users in a row, seperated by spaces, then an amount that each mentioned user will receive.'],
['private <user>+ <amount>','Put private before the user list to have each user tipped privately, without revealing other users tipped.']], ['private <user>+ <amount>','Put private before the user list to have each user tipped privately, without revealing other users tipped.']],
helpmsg = '```**!multitip**\n' + formatDescriptions(helpmsgparts) + 'Key: [] : Optionally include contained keyword, <> : Replace with the appropriate value, + : Value can be repeated for multiple entries.```', helpmsg = '```**!multitip**\n' + formatDescriptions(helpmsgparts) + 'Key: [] : Optionally include contained keyword, <> : Replace with the appropriate value, + : Value can be repeated for multiple entries.```',
channelwarning = 'Please use <#369896313082478594> or DMs to talk to bots.'; channelwarning = 'Please use <'+ moderation.sandboxchannel + '> or DMs to talk to bots.';
switch(subcommand) { switch(subcommand) {
case 'help': privateOrSandboxOnly(msg, channelwarning, doHelp, [helpmsg]); break; case 'help': privateOrSandboxOnly(msg, channelwarning, doHelp, [helpmsg]); break;
default: doMultiTip(msg, tipper, words, helpmsg); break; default: doMultiTip(msg, tipper, words, helpmsg); break;
@ -65,7 +66,7 @@ exports.roletip = {
['<role> <amount>', 'Mention a single role, then an amount that each user in that role will receive.'], ['<role> <amount>', 'Mention a single role, then an amount that each user in that role will receive.'],
['private <role> <amount>','Put private before the role to have each user tipped privately, without revealing other users tipped.']], ['private <role> <amount>','Put private before the role to have each user tipped privately, without revealing other users tipped.']],
helpmsg = '```**!roletip**\n' + formatDescriptions(helpmsgparts) + 'Key: [] : Optionally include contained keyword, <> : Replace with the appropriate value.```', helpmsg = '```**!roletip**\n' + formatDescriptions(helpmsgparts) + 'Key: [] : Optionally include contained keyword, <> : Replace with the appropriate value.```',
channelwarning = 'Please use <#369896313082478594> or DMs to talk to bots.'; channelwarning = 'Please use <'+ moderation.sandboxchannel + '> or DMs to talk to bots.';
switch(subcommand) { switch(subcommand) {
case 'help': privateOrSandboxOnly(msg, channelwarning, doHelp, [helpmsg]); break; case 'help': privateOrSandboxOnly(msg, channelwarning, doHelp, [helpmsg]); break;
default: doRoleTip(msg, tipper, words, helpmsg); break; default: doRoleTip(msg, tipper, words, helpmsg); break;
@ -91,7 +92,7 @@ function doHelp(message, helpmsg) {
function doBalance(message, tipper) { function doBalance(message, tipper) {
lbry.getBalance(tipper, 1, function (err, balance) { lbry.getBalance(tipper, 1, function (err, balance) {
if (err) { if (err) {
message.reply('Error getting balance'); message.reply('Error getting balance.');
} }
else { else {
message.reply('You have *' + balance + '* LBC'); message.reply('You have *' + balance + '* LBC');
@ -103,7 +104,7 @@ function doBalance(message, tipper) {
function doDeposit(message, tipper) { function doDeposit(message, tipper) {
getAddress(tipper, function (err, address) { getAddress(tipper, function (err, address) {
if (err) { if (err) {
message.reply('Error getting deposit address'); message.reply('Error getting your deposit address.');
} }
else { else {
message.reply('Your address is ' + address); message.reply('Your address is ' + address);
@ -122,7 +123,7 @@ function doWithdraw(message, tipper, words, helpmsg) {
amount = getValidatedAmount(words[3]); amount = getValidatedAmount(words[3]);
if (amount === null) { if (amount === null) {
message.reply('I dont know how to withdraw that many credits'); message.reply('I dont know how to withdraw that many credits...');
return; return;
} }
@ -131,7 +132,7 @@ function doWithdraw(message, tipper, words, helpmsg) {
message.reply(err.message); message.reply(err.message);
} }
else { else {
message.reply('You withdrew ' + amount + ' to ' + address + ' (' + txLink(txId) + ')'); message.reply('You withdrew ' + amount + ' to ' + address + ' (' + txLink(txId) + ').');
} }
}); });
} }
@ -153,7 +154,7 @@ function doTip(message, tipper, words, helpmsg) {
let amount = getValidatedAmount(words[amountOffset]); let amount = getValidatedAmount(words[amountOffset]);
if (amount === null) { if (amount === null) {
message.reply('I dont know how to tip that many credits'); message.reply('I dont know how to tip that many credits...');
return; return;
} }
@ -181,7 +182,7 @@ function doMultiTip(message, tipper, words, helpmsg) {
} }
let [userIDs, amount] = findUserIDsAndAmount(message, words, prv + 1); let [userIDs, amount] = findUserIDsAndAmount(message, words, prv + 1);
if (amount == null) { if (amount == null) {
message.reply('I dont know how to tip that many credits'); message.reply('I don\'t know how to tip that many credits...');
return; return;
} }
if (!userIDs) { if (!userIDs) {
@ -207,7 +208,7 @@ function doRoleTip(message, tipper, words, helpmsg) {
} }
let amount = getValidatedAmount(words[amountOffset]); let amount = getValidatedAmount(words[amountOffset]);
if (amount == null) { if (amount == null) {
message.reply('I dont know how to tip that many credits'); message.reply('I don\'t know how to tip that many credits...');
return; return;
} }
if (message.mentions.roles.first().id) { if (message.mentions.roles.first().id) {
@ -234,7 +235,7 @@ function findUserIDsAndAmount(message, words, startOffset) {
var idList = []; var idList = [];
var amount = null; var amount = null;
var count = 0; var count = 0;
for (var i = startOffset; i < words.length; i++) { for (var i = startOffset; i < words.length; i++) {
if (message.mentions.USERS_PATTERN.test(words[i])) { if (message.mentions.USERS_PATTERN.test(words[i])) {
count++; count++;
@ -301,7 +302,7 @@ function getAddress(userId, cb) {
function inPrivateOrBotSandbox(msg) { function inPrivateOrBotSandbox(msg) {
if ((msg.channel.type == 'dm') || (msg.channel.id === '369896313082478594')) { if ((msg.channel.type == 'dm') || (msg.channel.id === moderation.sandboxchannel)) {
return true; return true;
} else { } else {
return false; return false;

View file

@ -14,7 +14,8 @@
"url":"mongodb://localhost:27017/wunderbot" "url":"mongodb://localhost:27017/wunderbot"
}, },
"moderation":{ "moderation":{
"perms": ["LBRY MODS","LBRY TEAM"], // Roles that have access to all commands. "perms": ["LBRY MODS","LBRY TEAM"], // Roles that have access to all commands.
"logchannel": "371620338263523328" // Channel to log the bots moderation.. "logchannel": "371620338263523328", // Channel to log the bots moderation.
"sandboxchannel": "369896313082478594" // Channel for bot sandbox.
} }
} }