* /nick <nouveau nick>
* Modifie le pseudo courant
*/
-euphorik.Commandes = function(client) {
+euphorik.Commandes = function(client, pageMinichat, util, formateur) {
+ var thisCommandes = this;
+
this.client = client;
+ this.pageMinichat = pageMinichat;
+ this.util = util;
+ this.formateur = formateur;
+
+ // construction du texte d'aide (liste des commandes) de manière statique
+ this.texteAide = "<div id=\"aideCommandes\"><h1>Commandes</h1><ul>";
+ objectEach(
+ euphorik.Commandes.liste,
+ function(nom, commande) {
+ thisCommandes.texteAide += "<li><span class=\"usage\">" + thisCommandes.formateur.traitementComplet(commande.usage) + "</span> : " + thisCommandes.formateur.traitementComplet(commande.description) + "</li>";
+ }
+ );
+ this.texteAide += "</ul></div>";
};
euphorik.Commandes.statut = {ok : 0, pas_une_commande : 1, erreur_commande : 2};
euphorik.Commandes.liste = {
"nick" : {
+ description : "Change le pseudo courant",
usage : "/nick <nouveau pseudo>",
exec : function(args, client) {
return [euphorik.Commandes.statut.ok, ''];
}
- }
+ },
+ "cpf" : {
+ description : "Envoie le message \"C'est pas faux\"",
+ usage : "/cpf",
+ exec : function(args, client, pageMinichat) {
+ pageMinichat.envoyerMessage("C'est pas faux");
+ return [euphorik.Commandes.statut.ok, ''];
+ }
+ }
};
/**
if (nomCommande === "") {
return [euphorik.Commandes.statut.erreur_commande, 'La commande est vide'];
}
+ // commandes spéciales pour afficher l'aide : "?", "h", "help", "aide"
+ if (nomCommande === "?" || nomCommande === "h" || nomCommande === "help" || nomCommande === "aide") {
+ this.util.messageDialogue(
+ this.texteAide,
+ euphorik.Util.messageType.informatif,
+ {"fermer" : function(){}},
+ false,
+ -1
+ );
+ return [euphorik.Commandes.statut.ok, ''];
+ }
if (euphorik.Commandes.liste.hasOwnProperty(nomCommande)) {
- return euphorik.Commandes.liste[nomCommande].exec(args, this.client);
+ return euphorik.Commandes.liste[nomCommande].exec(args, this.client, this.pageMinichat);
}
return [euphorik.Commandes.statut.erreur_commande, 'La commande /' + nomCommande + ' est inconnue'];