Merge branch '4-gestion-des-admins' into 'develop'

Resolve "Gestion des admins"

Closes #4

See merge request dbroqua/irc-radio-bot!4
This commit is contained in:
Damien Broqua 2020-01-13 14:45:59 +01:00
commit b6beab9a71

View File

@ -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