Browse Source

Ajout des Help de commandes

Martin Passard 7 years ago
parent
commit
0de07c7c68

+ 2 - 0
src/actions/Action.java

@@ -79,5 +79,7 @@ public abstract class Action {
 		return ar;
 		return ar;
 	}
 	}
 	
 	
+	public abstract String help();
+	
 
 
 }
 }

+ 7 - 0
src/actions/Contact.java

@@ -34,6 +34,13 @@ public class Contact extends Action {
 
 
 	}
 	}
 
 
+	@Override
+	public String help() {
+		return " suivi du nom d'un fai. Renvoie les moyens pour contacter le FAI en question";
+	}
+
+	
+
 }
 }
 
 
 
 

+ 6 - 0
src/actions/Distance.java

@@ -93,6 +93,12 @@ public class Distance extends Action {
 			array[i]=array[i-1];
 			array[i]=array[i-1];
 		}
 		}
 	}
 	}
+
+	@Override
+	public String help() {
+		
+		return " suivi de la latitude, puis la longitude au format décimal. Exemple: +"+keyWords.get(0)+" 50,410658 61.574548      Renvoie les "+NOMBRE_AFFICHABLE+" FAI de la fédération les plus proches à vol d'oiseau";
+	}
 	
 	
 }
 }
 
 

+ 19 - 15
src/actions/Help.java

@@ -12,31 +12,35 @@ public class Help extends Action {
 		List<String> kw = new ArrayList<>(3);
 		List<String> kw = new ArrayList<>(3);
 		kw.add("help");
 		kw.add("help");
 		kw.add("?");
 		kw.add("?");
+		this.keyWords = kw;
 	}
 	}
 
 
 	@Override
 	@Override
 	public void react(String channel, String sender, String login, String hostname, String message) {
 	public void react(String channel, String sender, String login, String hostname, String message) {
 		List<Action> l = Action.getAllActions((Bot) bot);
 		List<Action> l = Action.getAllActions((Bot) bot);
 		String commande = message.substring(message.indexOf(' ')+1);
 		String commande = message.substring(message.indexOf(' ')+1);
-		commande = commande.substring(0,message.indexOf(' '));
-		boolean hasreacted = false;
-		if(commande.equals("help")) {
-			bot.sendMessage(channel, help());
-			hasreacted = true;
-		}else {
-			for(Action a : l) {
-				if(a.keyWords.contains(commande) && hasreacted == false) {
-					String msg = "";
-					for(String s : a.keyWords) {
-						msg+="+"+s+" ";
+		if(commande.indexOf(' ') != -1) {
+			commande = commande.substring(0,commande.indexOf(' '));
+		}
+			boolean hasreacted = false;
+			if(commande.equals("help")) {
+				bot.sendMessage(channel, help());
+				hasreacted = true;
+			}else {
+				for(Action a : l) {
+					if(a.keyWords.contains(commande) && hasreacted == false) {
+						String msg = "";
+						for(String s : a.keyWords) {
+							msg+="+"+s+" ";
+						}
+						msg += a.help();
+						bot.sendMessage(channel, msg);
+						hasreacted = true;
 					}
 					}
-					msg += a.help();
-					bot.sendMessage(channel, msg);
-					hasreacted = true;
 				}
 				}
 			}
 			}
-		}
 		
 		
+
 	}
 	}
 
 
 	@Override
 	@Override

+ 5 - 0
src/actions/ID.java

@@ -53,4 +53,9 @@ public class ID extends Action {
 		bot.sendMessage(channel, sender+": "+s);
 		bot.sendMessage(channel, sender+": "+s);
 	}
 	}
 
 
+	@Override
+	public String help() {
+		return " Suivi du nom d'un FAI ou du numero d'un FAI. Renvoie l'Opposé de l'information donnée en paramètre. Exemple: \"+id 2\"   renvoie \"Ilico\"";
+	}
+
 }
 }

+ 5 - 0
src/actions/Info.java

@@ -74,6 +74,11 @@ public class Info extends Action {
 
 
 	}
 	}
 
 
+	@Override
+	public String help() {
+		return " suivi du nom d'un FAI ou de son numero. Dans le cas d'un nom, il va le chercher dans le Cache. Dans le cas d'un numéro, il fait la requète directement dans db.ffdn.org. Exemples: \"+info 2\" ou \"+info fdn\" ";
+	}
+
 }
 }
 
 
 
 

+ 5 - 0
src/actions/Liste.java

@@ -75,6 +75,11 @@ public class Liste extends Action {
 		b2.sendMessage(channel, messages);
 		b2.sendMessage(channel, messages);
 	}
 	}
 
 
+	@Override
+	public String help() {
+		return " Liste tous les FAI de la fédération. L'Ajout du parametre All affiche aussi ceux hors fédération.";
+	}
+
 }
 }
 
 
 
 

+ 5 - 0
src/actions/Reload.java

@@ -39,4 +39,9 @@ public class Reload extends Action {
 		return c.reload();
 		return c.reload();
 	}
 	}
 
 
+	@Override
+	public String help() {
+		return " Met à jour le cache";
+	}
+
 }
 }

+ 5 - 0
src/actions/Source.java

@@ -21,6 +21,11 @@ public class Source extends Action {
 		bot.sendMessage(channel, sender+": mes sources sont disponibles ici: https://code.ffdn.org/marmat8951/bot-irc2");
 		bot.sendMessage(channel, sender+": mes sources sont disponibles ici: https://code.ffdn.org/marmat8951/bot-irc2");
 	}
 	}
 
 
+	@Override
+	public String help() {
+		return " Renvoie une URI où on peut trouver les sources";
+	}
+
 }
 }