diff --git a/pom.xml b/pom.xml
index 48d9e22..638c1ed 100644
--- a/pom.xml
+++ b/pom.xml
@@ -141,7 +141,6 @@
commons-collections
commons-collections
3.2.1
- runtime
org.springframework
diff --git a/src/main/java/fr/imirhil/april/hebdobot/irc/Bot.java b/src/main/java/fr/imirhil/april/hebdobot/irc/Bot.java
index ee96723..5fc59cc 100644
--- a/src/main/java/fr/imirhil/april/hebdobot/irc/Bot.java
+++ b/src/main/java/fr/imirhil/april/hebdobot/irc/Bot.java
@@ -3,6 +3,8 @@ package fr.imirhil.april.hebdobot.irc;
import java.util.Collection;
import java.util.LinkedList;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang.StringUtils;
import org.jibble.pircbot.PircBot;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -66,6 +68,7 @@ public class Bot extends PircBot {
this.handleMessage(sender, message);
}
}
+ this.handleManquants(sender, message);
this.handleComment(sender, message);
this.handleDisplayCurrent(sender, message);
this.handleHelp(sender, message);
@@ -86,21 +89,54 @@ public class Bot extends PircBot {
this.sendMessage(sender, "— # titre : démarrer un sujet individuel");
this.sendMessage(sender, "— ## titre : démarrer un sujet collectif");
this.sendMessage(sender, "— !courant : affiche le sujet en cours");
+ this.sendMessage(
+ sender,
+ "— !manquants : affiche les participants qui n'ont pas répondu sur le dernier sujet");
this.sendMessage(sender, "— % message : un commentaire");
}
- private void handleMessage(final String sender, final String message) {
+ private boolean handleMessage(final String sender, final String message) {
if (this.review == null || message.startsWith("%")) {
- return;
+ return false;
}
this.review.add(new Message(sender, message));
+ return true;
}
- private void handleComment(final String sender, final String message) {
+ private boolean handleManquants(final String sender, final String message) {
+ if (this.review == null || !"!manquants".equalsIgnoreCase(message)) {
+ return false;
+ }
+
+ final Topic topic = this.review.getCurrentTopic();
+ if (topic == null) {
+ this.sendMessage("Aucun sujet traité");
+ return true;
+ }
+
+ final Collection participants = this.review.getParticipants();
+ final Collection currentParticipants = topic.getParticipants();
+
+ @SuppressWarnings("unchecked")
+ final Collection missing =
+ CollectionUtils.subtract(participants, currentParticipants);
+ if (missing.isEmpty()) {
+ this.sendMessage("Aucun participant manquant \\o/");
+ return true;
+ }
+
+ this.sendMessage(String.format(
+ "Les participants suivants sont manquants : %1s",
+ StringUtils.join(missing, ", ")));
+ return true;
+ }
+
+ private boolean handleComment(final String sender, final String message) {
if (this.review == null) {
- return;
+ return false;
}
this.review.addRaw(new Message(sender, message));
+ return true;
}
private boolean handleDie(final String sender, final String message) {
diff --git a/src/main/java/fr/imirhil/april/hebdobot/review/Review.java b/src/main/java/fr/imirhil/april/hebdobot/review/Review.java
index 11728ff..1b2c8f9 100644
--- a/src/main/java/fr/imirhil/april/hebdobot/review/Review.java
+++ b/src/main/java/fr/imirhil/april/hebdobot/review/Review.java
@@ -1,5 +1,6 @@
package fr.imirhil.april.hebdobot.review;
+import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
@@ -200,4 +201,15 @@ public class Review {
add(buffer, chunk(content));
}
+ public Collection getParticipants() {
+ final Collection reviewers = new HashSet();
+ for (final Topic topic : this.individualTopics) {
+ reviewers.addAll(topic.getParticipants());
+ }
+ for (final Topic topic : this.collectiveTopics) {
+ reviewers.addAll(topic.getParticipants());
+ }
+ return reviewers;
+ }
+
}