added support for tipping in every channel

This commit is contained in:
Niko Storni 2016-08-30 21:16:19 +02:00
parent cf689927d9
commit 1d0252ab02

View file

@ -41,12 +41,16 @@ function respond(bot, data) {
return; return;
} }
if ((!tipper.is_admin || !tipper.is_owner) && channel.name !== "bot-sandbox" ){ var subcommand = words.length >= 2 ? words[1] : 'help';
var isAllowedTip = false;
if ((!tipper.is_admin || !tipper.is_owner) && channel.name !== 'bot-sandbox' ){
//to check if the command is a tip (hence allowed to pass through) we need to check against all the other commands)
if (subcommand === 'help' || subcommand === 'balance' || subcommand === 'deposit' || subcommand === 'withdraw'){
bot.postMessage(channel, 'Please help keep the channel clean: use #bot-sandbox', globalSlackParams); bot.postMessage(channel, 'Please help keep the channel clean: use #bot-sandbox', globalSlackParams);
return; return;
} }
isAllowedTip = true;
var subcommand = words.length >= 2 ? words[1] : 'help'; }
if (subcommand === 'help') { if (subcommand === 'help') {
doHelp(bot, channel); doHelp(bot, channel);
@ -61,7 +65,7 @@ function respond(bot, data) {
doWithdraw(bot, channel, tipper, words); doWithdraw(bot, channel, tipper, words);
} }
else { else {
doTip(bot, channel, tipper, words); doTip(bot, channel, tipper, words, isAllowedTip);
} }
} }
@ -116,8 +120,10 @@ function doWithdraw(bot, channel, tipper, words) {
} }
function doTip(bot, channel, tipper, words) { function doTip(bot, channel, tipper, words, isAllowedTip) {
if (words.length < 3) { if (words.length < 3) {
//necessary to avoid the help menu opening up on all channels
if (!isAllowedTip)
doHelp(bot, channel); doHelp(bot, channel);
return; return;
} }