diff --git a/index.js b/index.js index d4bc206..4e45fbc 100644 --- a/index.js +++ b/index.js @@ -174,6 +174,7 @@ const botSay = (where, what, dontDisplayRadio, forceSend) => { */ const actions = (where, message, from) => { const exploded = message.split(' ') + const admins = (process.env.ADMINISTRATORS || 'ALL').toLowerCase().split(',') let allowedCmds = ['ALL'] if (process.env.AVAILABLE_CMD) { @@ -251,25 +252,29 @@ const actions = (where, message, from) => { } break case '!mute': - if (allowedCmds[0] === 'ALL' || allowedCmds.indexOf('!mute') !== -1) { - if (exploded[2] && ['on', 'off', 'state'].indexOf(exploded[2]) !== -1) { - switch (exploded[2]) { - case 'on': - isMute = true - botSay(where, "Pff ! c'est toujours pareil ici :'(", false, true) - break - case 'off': - isMute = false - botSay(where, "Merci ! j'avais tellement de chose à te dire...", false, true) - break - default: - botSay(where, isMute ? 'Je ne dirais rien !' : "T'inquiète ! tu vas l'avoir ta notif !", false, true) + if (admins[0] === 'ALL' || allowedCmds.indexOf(from.toLowerCase()) !== -1) { + if (allowedCmds[0] === 'ALL' || allowedCmds.indexOf('!mute') !== -1) { + if (exploded[2] && ['on', 'off', 'state'].indexOf(exploded[2]) !== -1) { + switch (exploded[2]) { + case 'on': + isMute = true + botSay(where, "Pff ! c'est toujours pareil ici :'(", false, true) + break + case 'off': + isMute = false + botSay(where, "Merci ! j'avais tellement de chose à te dire...", false, true) + break + default: + botSay(where, isMute ? 'Je ne dirais rien !' : "T'inquiète ! tu vas l'avoir ta notif !", false, true) + } + } else { + botSay(where, '!help mute', false, true) } } else { - botSay(where, '!help mute', false, true) + unknownCmd() } } else { - unknownCmd() + botSay(where, 'Bien tenté mais...') } break