diff --git a/.classpath b/.classpath
index 9547f0f..08d4bbc 100644
--- a/.classpath
+++ b/.classpath
@@ -37,10 +37,9 @@
-
-
+
+
-
@@ -48,5 +47,6 @@
+
diff --git a/lib/devinsy-strings-0.4.1.jar b/lib/devinsy-strings-0.4.1.jar
deleted file mode 100644
index e6febe7..0000000
Binary files a/lib/devinsy-strings-0.4.1.jar and /dev/null differ
diff --git a/lib/devinsy-strings-0.4.1-sources.zip b/lib/devinsy-strings-0.4.2-sources.zip
similarity index 60%
rename from lib/devinsy-strings-0.4.1-sources.zip
rename to lib/devinsy-strings-0.4.2-sources.zip
index 8480d88..144cfbf 100644
Binary files a/lib/devinsy-strings-0.4.1-sources.zip and b/lib/devinsy-strings-0.4.2-sources.zip differ
diff --git a/lib/devinsy-strings-0.4.2.jar b/lib/devinsy-strings-0.4.2.jar
new file mode 100644
index 0000000..1cf5fed
Binary files /dev/null and b/lib/devinsy-strings-0.4.2.jar differ
diff --git a/src/org/april/hebdobot/cli/HebdobotCLI.java b/src/org/april/hebdobot/cli/HebdobotCLI.java
index 1265b5d..678b160 100644
--- a/src/org/april/hebdobot/cli/HebdobotCLI.java
+++ b/src/org/april/hebdobot/cli/HebdobotCLI.java
@@ -136,8 +136,9 @@ public class HebdobotCLI
File aliasFile = new File(configFile.getParentFile(), DEFAULT_ALIAS_FILE);
logger.info("Aliases file loading… ({}).", aliasFile.getAbsolutePath());
UserAliases aliases = new UserAliases(aliasFile);
- logger.info("Aliases file loaded.");
+ logger.info("Aliases file loaded (" + aliases.size() + " aliases).");
+ System.exit(0);
if (config.isValid())
{
logger.info("Bot configuring…");
diff --git a/src/org/april/hebdobot/model/Hebdobot.java b/src/org/april/hebdobot/model/Hebdobot.java
index 32cd0c3..91c0c77 100644
--- a/src/org/april/hebdobot/model/Hebdobot.java
+++ b/src/org/april/hebdobot/model/Hebdobot.java
@@ -46,6 +46,8 @@ import org.joda.time.format.ISODateTimeFormat;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import fr.devinsy.util.strings.StringsUtils;
+
/**
* The Class Hebdobot.
*/
@@ -153,24 +155,25 @@ public class Hebdobot extends PircBot
{
String text = message.trim();
- if (StringUtils.equalsIgnoreCase(text, "!help"))
+ if ((StringUtils.equalsIgnoreCase(text, "!aide")) || (StringUtils.equalsIgnoreCase(text, "!help")))
{
logger.info("!help caught.");
// Help.
sendMessage(sender, "Bienvenue " + sender);
- sendMessage(sender, "Je suis " + getName() + ", le robot de gestion des revues hebdomadaires de l'APRIL");
+ sendMessage(sender, "Je suis " + getName() + ", le robot de gestion des revues hebdomadaires de l'APRIL.");
sendMessage(sender, "Voici les commandes que je comprends :");
sendMessage(sender, " ");
- sendMessage(sender, "— !debut : commencer une nouvelle revue");
- sendMessage(sender, "— !fin : terminer la revue en cours");
- sendMessage(sender, "— # titre : démarrer un sujet individuel");
- sendMessage(sender, "— ## titre : démarrer un sujet collectif");
- sendMessage(sender, "— !courant : affiche le sujet en cours");
- sendMessage(sender, "— !manquants : affiche les participants qui n'ont pas répondu sur le dernier sujet");
- sendMessage(sender, "— % message : un commentaire");
- sendMessage(sender, "— !stop : abandonner la revue en cours");
- sendMessage(sender, "— !vaten : faire partir le bot");
+ sendMessage(sender, " !debut : commencer une nouvelle revue");
+ sendMessage(sender, " !fin : terminer la revue en cours");
+ sendMessage(sender, " # titre : démarrer un sujet individuel");
+ sendMessage(sender, " ## titre : démarrer un sujet collectif");
+ sendMessage(sender, " !courant : affiche le sujet en cours");
+ sendMessage(sender, " !manquants : affiche les participants qui n'ont pas répondu sur le dernier sujet");
+ sendMessage(sender, " % message : un commentaire");
+ sendMessage(sender, " !stop : abandonner la revue en cours");
+ sendMessage(sender, " !vaten : faire partir le bot");
+ sendMessage(sender, " !aide : afficher cette aide");
}
else if (StringUtils.equalsIgnoreCase(text, "!vaten"))
{
@@ -192,24 +195,25 @@ public class Hebdobot extends PircBot
}
else
{
- sendMessage("% Une revue est en cours, arrêt impossible");
+ sendMessage("% Une revue est en cours, arrêt impossible.");
}
}
else if (StringUtils.equalsIgnoreCase(text, "!stop"))
{
logger.info("!stop caught.");
- // Die.
+ // Stop.
if (this.review == null)
{
- sendMessage("Aucune revue en cours, arrêt impossible");
+ sendMessage("Aucune revue en cours, arrêt impossible.");
}
else
{
+ sendMessage("Arrêt de la revue en cours.");
this.review = null;
}
}
- else if ((StringUtils.equalsIgnoreCase(text, "!debut")) || (StringUtils.equalsIgnoreCase(text, "!début")))
+ else if (StringsUtils.equalsAnyIgnoreCase(text, "!debut", "!début"))
{
logger.info("!debut caught.");
diff --git a/src/org/april/hebdobot/model/UserAliases.java b/src/org/april/hebdobot/model/UserAliases.java
index 035cecc..41fcd6c 100644
--- a/src/org/april/hebdobot/model/UserAliases.java
+++ b/src/org/april/hebdobot/model/UserAliases.java
@@ -22,31 +22,32 @@ package org.april.hebdobot.model;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Iterator;
-import java.util.Map;
-import java.util.Properties;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang3.StringUtils;
import org.april.hebdobot.HebdobotException;
-import org.april.hebdobot.util.HebdobotUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import fr.devinsy.util.strings.StringList;
+
/**
* The Class UserAliases.
*/
-public class UserAliases
+public class UserAliases extends HashMap
{
+ private static final long serialVersionUID = -7563433397065777556L;
private static final Logger logger = LoggerFactory.getLogger(UserAliases.class);
- private final Map aliases;
-
/**
* Instantiates a new user aliases.
*/
public UserAliases()
{
- this.aliases = new HashMap();
+ super();
}
/**
@@ -59,20 +60,24 @@ public class UserAliases
*/
public UserAliases(final File source) throws HebdobotException
{
- this.aliases = new HashMap();
+ super();
try
{
+ StringList lines = new StringList(FileUtils.readLines(source, StandardCharsets.UTF_8));
- Properties users = HebdobotUtils.loadProperties(source);
-
- for (String realName : users.stringPropertyNames())
+ for (String line : lines)
{
- String[] nicks = users.getProperty(realName).split(",");
-
- for (String nick : nicks)
+ if ((StringUtils.isNotBlank(line)) && (!line.startsWith("#")))
{
- this.aliases.put(nick, realName);
+ String[] tokens = line.split("=");
+ String realName = tokens[0];
+ String[] nicks = tokens[1].split(",");
+
+ for (String nick : nicks)
+ {
+ put(nick, realName);
+ }
}
}
}
@@ -97,12 +102,12 @@ public class UserAliases
{
String result;
- result = this.aliases.get(nick);
+ String realName = get(nick);
- if (result == null)
+ if (realName == null)
{
boolean ended = false;
- Iterator iterator = this.aliases.keySet().iterator();
+ Iterator iterator = keySet().iterator();
while (!ended)
{
if (iterator.hasNext())
@@ -112,29 +117,40 @@ public class UserAliases
if (nick.toLowerCase().contains(currentNick.toLowerCase()))
{
ended = true;
- result = this.aliases.get(currentNick) + " ( " + nick + " )";
+ realName = get(currentNick);
}
}
else
{
- result = nick;
+ realName = nick;
ended = true;
}
}
}
+ result = realName + " (" + nick + ")";
+
//
return result;
}
- /**
- * Put all.
- *
- * @param source
- * the source
+ /* (non-Javadoc)
+ * @see java.util.AbstractMap#toString()
*/
- public void putAll(final UserAliases source)
+ @Override
+ public String toString()
{
- this.aliases.putAll(source.aliases);
+ String result;
+
+ StringList buffer = new StringList();
+ for (String nick : this.keySet())
+ {
+ buffer.appendln(getRealName(nick));
+ }
+
+ result = buffer.toString();
+
+ //
+ return result;
}
}