Browse Source

feat: Ajout action contact

Martin Passard 7 years ago
parent
commit
370137f6d6
1 changed files with 41 additions and 0 deletions
  1. 41 0
      src/actions/Contact.java

+ 41 - 0
src/actions/Contact.java

@@ -0,0 +1,41 @@
+package actions;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import data.CoveredAreas;
+import data.ISP;
+import data.ISPDAO;
+import main.Bot;
+import main.Cache;
+import verif_saisie.EntierPositifNonVide;
+
+public class Contact extends Action {
+
+	public Contact(Bot b) {
+		this.bot = b;
+		List<String> ar = new ArrayList<>();
+		ar.add("contact");
+		this.keyWords = ar;
+	}
+
+	@Override
+	public void react(String channel, String sender, String login, String hostname, String message) {
+		
+		String s = message.substring(message.indexOf(' ')+1);
+		if(!EntierPositifNonVide.verifie(s)) {					// +contact suivi d'un mot
+			Cache c = Cache.getInstance();
+			ISP fai = c.getISPWithName(s);
+			if(fai == null) {
+				bot.sendMessage(channel, "Aucun FAI "+s);
+			}else {
+				Bot b = (Bot) bot;
+				b.sendMessage(channel, fai.contact());
+			}
+		}
+
+	}
+
+}
+
+