@4-gestion-des-admins

This commit is contained in:
dbroqua 2020-01-13 14:45:06 +01:00
parent b88a776071
commit 7cd51aaf94

View file

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