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:
commit
b6beab9a71
1 changed files with 20 additions and 15 deletions
35
index.js
35
index.js
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue