minor tweaks

This commit is contained in:
Alex Grintsvayg 2016-08-30 15:34:35 -04:00
parent a0302ef885
commit a834e838d2

View file

@ -42,14 +42,11 @@ function respond(bot, data) {
} }
var subcommand = words.length >= 2 ? words[1] : 'help'; var subcommand = words.length >= 2 ? words[1] : 'help';
var isAllowedTip = false;
if ((!tipper.is_admin || !tipper.is_owner) && channel.name !== 'bot-sandbox' ){ var moveToBotSandbox = !tipper.is_admin && !tipper.is_owner && channel.name !== 'bot-sandbox' && ['help', 'balance', 'deposit', 'withdraw'].indexOf(subcommand) != -1
//to check if the command is a tip (hence allowed to pass through) we need to check against all the other commands) if (moveToBotSandbox) {
if (subcommand === 'help' || subcommand === 'balance' || subcommand === 'deposit' || subcommand === 'withdraw'){ bot.postMessage(channel, 'Please use #bot-sandbox to talk to bots', globalSlackParams);
bot.postMessage(channel, 'Please help keep the channel clean: use #bot-sandbox', globalSlackParams); return;
return;
}
isAllowedTip = true;
} }
if (subcommand === 'help') { if (subcommand === 'help') {
@ -65,7 +62,7 @@ function respond(bot, data) {
doWithdraw(bot, channel, tipper, words); doWithdraw(bot, channel, tipper, words);
} }
else { else {
doTip(bot, channel, tipper, words, isAllowedTip); doTip(bot, channel, tipper, words);
} }
} }
@ -120,11 +117,9 @@ function doWithdraw(bot, channel, tipper, words) {
} }
function doTip(bot, channel, tipper, words, isAllowedTip) { function doTip(bot, channel, tipper, words) {
if (words.length < 3) { if (words.length < 3) {
//necessary to avoid the help menu opening up on all channels doHelp(bot, channel);
if (!isAllowedTip)
doHelp(bot, channel);
return; return;
} }
@ -155,6 +150,7 @@ function doTip(bot, channel, tipper, words, isAllowedTip) {
function doHelp(bot, channel) { function doHelp(bot, channel) {
bot.postMessage(channel, bot.postMessage(channel,
'*USE <#bot-sandbox> FOR EVERYTHING EXCEPT ACTUAL TIPPING*\n' +
'`' + command + ' help`: this message\n' + '`' + command + ' help`: this message\n' +
'`' + command + ' balance`: get your balance\n' + '`' + command + ' balance`: get your balance\n' +
'`' + command + ' deposit`: get address for deposits\n' + '`' + command + ' deposit`: get address for deposits\n' +