irc-radio-bot/libs/Help.js

204 lines
7.6 KiB
JavaScript
Raw Normal View History

2019-12-24 11:30:41 +01:00
class Help {
2020-01-10 20:32:06 +01:00
static helpSay (say, where, message) {
say(where, message, true, true)
}
2019-12-24 11:30:41 +01:00
/**
* Fonction affichant l'aide générale
* @param {Function} say
* @param {String} where
* @param {Array} args
2020-01-10 20:55:53 +01:00
* @param {Array} allowedCmds
2019-12-24 11:30:41 +01:00
*/
2020-01-10 20:55:53 +01:00
static show (say, where, args, allowedCmds) {
2019-12-24 11:30:41 +01:00
if (args.length > 2) {
switch (args[2]) {
case '!artist':
2020-01-10 20:55:53 +01:00
if (allowedCmds[0] === 'ALL' || allowedCmds.indexOf('!artist') !== -1) {
Help.showArtistSong(say, where, args)
}
break
2019-12-24 11:30:41 +01:00
case '!song':
2020-01-10 20:55:53 +01:00
if (allowedCmds[0] === 'ALL' || allowedCmds.indexOf('!song') !== -1) {
Help.showArtistSong(say, where, args)
}
2019-12-24 11:30:41 +01:00
break
case '!stats':
2020-01-10 20:55:53 +01:00
if (allowedCmds[0] === 'ALL' || allowedCmds.indexOf('!stats') !== -1) {
Help.showStats(say, where)
}
2019-12-24 11:30:41 +01:00
break
case '!when':
2020-01-10 20:55:53 +01:00
if (allowedCmds[0] === 'ALL' || allowedCmds.indexOf('!when') !== -1) {
Help.showWhen(say, where)
}
2019-12-24 11:30:41 +01:00
break
2019-12-25 13:47:42 +01:00
case '!list':
2020-01-10 20:55:53 +01:00
if (allowedCmds[0] === 'ALL' || allowedCmds.indexOf('!list') !== -1) {
Help.showList(say, where)
}
2019-12-25 13:47:42 +01:00
break
2019-12-24 11:30:41 +01:00
case '!notifications':
2020-01-10 20:55:53 +01:00
if (allowedCmds[0] === 'ALL' || allowedCmds.indexOf('!notifications') !== -1) {
Help.showNotifications(say, where)
}
2019-12-24 11:30:41 +01:00
break
2020-01-07 09:55:55 +01:00
case '!stream':
2020-01-10 20:55:53 +01:00
if (allowedCmds[0] === 'ALL' || allowedCmds.indexOf('!stream') !== -1) {
Help.showStream(say, where)
}
2020-01-07 09:55:55 +01:00
break
2020-01-10 20:32:06 +01:00
case '!mute':
2020-01-10 20:55:53 +01:00
if (allowedCmds[0] === 'ALL' || allowedCmds.indexOf('!mute') !== -1) {
Help.showMute(say, where)
}
2020-01-10 20:32:06 +01:00
break
2019-12-24 11:30:41 +01:00
default:
break
}
} else {
2020-01-13 11:42:51 +01:00
Help.say(say, where, 'IRC Radio Bot :: Help')
2020-01-10 20:55:53 +01:00
if (allowedCmds[0] === 'ALL' || allowedCmds.indexOf('!artist') !== -1) {
2020-01-13 11:42:51 +01:00
Help.say(say, where, '!artist <add/del> {nom à sauvegarder si différent du morceau en cours}')
2020-01-10 20:55:53 +01:00
}
if (allowedCmds[0] === 'ALL' || allowedCmds.indexOf('!song') !== -1) {
2020-01-13 11:42:51 +01:00
Help.say(say, where, '!song <add/del> {nom à sauvegarder si différent du morceau en cours}')
2020-01-10 20:55:53 +01:00
}
if (allowedCmds[0] === 'ALL' || allowedCmds.indexOf('!stats') !== -1) {
2020-01-13 11:42:51 +01:00
Help.say(say, where, '!stats <period> {artist/song}')
2020-01-10 20:55:53 +01:00
}
if (allowedCmds[0] === 'ALL' || allowedCmds.indexOf('!when') !== -1) {
2020-01-13 11:42:51 +01:00
Help.say(say, where, '!when <period> <artist/song>')
2020-01-10 20:55:53 +01:00
}
if (allowedCmds[0] === 'ALL' || allowedCmds.indexOf('!list') !== -1) {
2020-01-13 11:42:51 +01:00
Help.say(say, where, '!list <period> <artist/song>')
2020-01-10 20:55:53 +01:00
}
if (allowedCmds[0] === 'ALL' || allowedCmds.indexOf('!help') !== -1) {
2020-01-13 11:42:51 +01:00
Help.say(say, where, '!help {command}')
2020-01-10 20:55:53 +01:00
}
if (allowedCmds[0] === 'ALL' || allowedCmds.indexOf('!notifications') !== -1) {
2020-01-13 11:42:51 +01:00
Help.say(say, where, '!notifications <on/off/state>')
2020-01-10 20:55:53 +01:00
}
if (allowedCmds[0] === 'ALL' || allowedCmds.indexOf('!stream') !== -1) {
2020-01-13 11:42:51 +01:00
Help.say(say, where, '!stream')
2020-01-10 20:55:53 +01:00
}
if (allowedCmds[0] === 'ALL' || allowedCmds.indexOf('!mute') !== -1) {
2020-01-13 11:42:51 +01:00
Help.say(say, where, '!mute <on/off/state>')
2020-01-10 20:55:53 +01:00
}
2019-12-24 11:30:41 +01:00
}
2020-01-13 11:42:51 +01:00
Help.say(say, where, '__ END __')
2019-12-24 11:30:41 +01:00
}
2020-01-07 09:55:55 +01:00
/**
* Fonction affichant l'aide sur la commande !stream
* @param {Function} say
* @param {String} where
* @param {Array} args
*/
static showStream (say, where, args) {
2020-01-13 11:42:51 +01:00
Help.say(say, where, 'IRC Radio Bot :: Stream', false, true)
Help.say(say, where, 'Affiche l\'url du flux radio pour ton player favoris', false, true)
Help.say(say, where, '!stream')
2020-01-10 20:32:06 +01:00
}
/**
* Fonction affichant l'aide sur la commande !mute
* @param {Function} say
* @param {String} where
* @param {Array} args
*/
static showMute (say, where, args) {
2020-01-13 11:42:51 +01:00
Help.say(say, where, 'IRC Radio Bot :: Mute')
Help.say(say, where, 'Permet d\'activer ou de désactiver les messages publics du bot')
Help.say(say, where, '!mute on')
Help.say(say, where, '!mute off')
Help.say(say, where, '!mute state')
2020-01-07 09:55:55 +01:00
}
2019-12-24 11:30:41 +01:00
/**
* Fonction affichant l'aide sur les commandes !artist et !song
* @param {Function} say
* @param {String} where
* @param {Array} args
*/
static showArtistSong (say, where, args) {
2020-01-13 11:42:51 +01:00
Help.say(say, where, 'IRC Radio Bot :: Artist/Song')
Help.say(say, where, `${args[2]} add {[facultatif] nom} < Permet de rajouter une notification sur ${args[2] === '!artist' ? 'cet artiste' : 'ce morceau'}`)
Help.say(say, where, `${args[2]} del {[facultatif] nom} < Permet de supprimer une notification sur ${args[2] === '!artist' ? 'cet artiste' : 'ce morceau'}`)
2019-12-24 11:30:41 +01:00
}
/**
* Fonction affichant l'aide sur la commande !stats
* @param {Function} say
* @param {String} where
*/
static showStats (say, where) {
2020-01-13 11:42:51 +01:00
Help.say(say, where, 'IRC Radio Bot :: Stats')
Help.say(say, where, 'Permet d\'afficher le nombre de passage à l\'antenne d\'un artiste/morceau sur une période donnée')
Help.say(say, where, '!stats day <title>')
Help.say(say, where, '!stats week <title>')
Help.say(say, where, '!stats month <title>')
Help.say(say, where, '!stats year <title>')
Help.say(say, where, '!stats lastday <title>')
2020-01-13 14:26:18 +01:00
Help.say(say, where, '!stats yesterday <title>')
2020-01-13 11:42:51 +01:00
Help.say(say, where, '!stats lastweek <title>')
Help.say(say, where, '!stats lastmonth <title>')
Help.say(say, where, '!stats lastyear <title>')
Help.say(say, where, 'Si <title> n\'est pas spécifie la stats concerne le nombre d\'artistes différents pour cette période')
2019-12-24 11:30:41 +01:00
}
/**
* Fonction affichant l'aide sur la commande !when
* @param {Function} say
* @param {String} where
*/
static showWhen (say, where) {
2020-01-13 11:42:51 +01:00
Help.say(say, where, 'IRC Radio Bot :: When')
Help.say(say, where, 'Permet d\'afficher la dernier passage d\'un artiste/morceau sur une période donnée')
Help.say(say, where, '!when day <title>')
Help.say(say, where, '!when week <title>')
Help.say(say, where, '!when month <title>')
Help.say(say, where, '!when year <title>')
Help.say(say, where, '!when lastday <title>')
2020-01-13 14:26:18 +01:00
Help.say(say, where, '!when yesterday <title>')
2020-01-13 11:42:51 +01:00
Help.say(say, where, '!when lastweek <title>')
Help.say(say, where, '!when lastmonth <title>')
Help.say(say, where, '!when lastyear <title>')
2019-12-24 11:30:41 +01:00
}
2019-12-25 13:47:42 +01:00
/**
* Fonction affichant l'aide sur la commande !list
* @param {Function} say
* @param {String} where
*/
static showList (say, where) {
2020-01-13 11:42:51 +01:00
Help.say(say, where, 'IRC Radio Bot :: List')
Help.say(say, where, 'Permet d\'afficher la liste des titres joués pour un artiste sr une période donnée')
Help.say(say, where, '!list day <artist>')
Help.say(say, where, '!list week <artist>')
Help.say(say, where, '!list month <artist>')
Help.say(say, where, '!list year <artist>')
Help.say(say, where, '!list lastday <artist>')
2020-01-13 14:26:18 +01:00
Help.say(say, where, '!list yesterday <artist>')
2020-01-13 11:42:51 +01:00
Help.say(say, where, '!list lastweek <artist>')
Help.say(say, where, '!list lastmonth <artist>')
Help.say(say, where, '!list lastyear <artist>')
2019-12-25 13:47:42 +01:00
}
2019-12-24 11:30:41 +01:00
/**
* Fonction affichant l'aide sur la commande !notifications
* @param {Function} say
* @param {String} where
*/
static showNotifications (say, where) {
2020-01-13 11:42:51 +01:00
Help.say(say, where, 'IRC Radio Bot :: Notifications')
Help.say(say, where, 'Permet d\'activer et de désactiver les notifications pour soit')
Help.say(say, where, '!notifications off')
Help.say(say, where, '!notifications off')
Help.say(say, where, '!notifications state < Permet de voir si l\'on a désactivé ou non les notifications')
2019-12-24 11:30:41 +01:00
}
}
module.exports = Help