Commits

aeris committed c5b2e10

Don't consider new topic as topic message

Comments (0)

Files changed (1)

src/main/java/fr/imirhil/april/hebdobot/irc/Bot.java

 		this.handleDie(sender, message);
 		this.handleStartReview(sender, message);
 		this.handleStopReview(sender, message);
-		this.handleStartIndividualTopic(sender, message);
-		this.handleStartCollectiveTopic(sender, message);
+		if (!this.handleStartIndividualTopic(sender, message)) {
+			if (!this.handleStartCollectiveTopic(sender, message)) {
+				this.handleMessage(sender, message);
+			}
+		}
 		this.handleComment(sender, message);
-		this.handleMessage(sender, message);
 		this.handleDisplayCurrent(sender, message);
 		this.handleHelp(sender, message);
 	}
 		this.review.addRaw(new Message(sender, message));
 	}
 
-	private void handleDie(final String sender, final String message) {
+	private boolean handleDie(final String sender, final String message) {
 		if (!"!stop".equalsIgnoreCase(message)) {
-			return;
+			return false;
 		}
 
 		this.disconnect();
 		this.dispose();
+		return true;
 	}
 
-	private void handleStartReview(final String sender, final String message) {
+	private boolean
+			handleStartReview(final String sender, final String message) {
 		if (!"!debut".equalsIgnoreCase(message)) {
-			return;
+			return false;
 		}
 
 		this.review = new Review(sender);
 		this.sendMessage(sender, "Vous êtes le conducteur de réunion");
 		this.sendMessage(sender, "Pour terminer la réunion, tapez \"!fin\"");
 		this.sendMessage("Début de la réunion hebdomadaire");
+		return true;
 	}
 
-	private void handleStopReview(final String sender, final String message) {
+	private boolean handleStopReview(final String sender, final String message) {
 		if (this.review == null || !"!fin".equalsIgnoreCase(message)) {
-			return;
+			return false;
 		}
 
 		if (!this.review.isOwner(sender)) {
 			this.sendMessage(sender
 					+ ", vous n'êtes pas le conducteur de la réunion");
-			return;
+			return false;
 		}
 
 		for (final ReviewListener listener : this.listeners) {
 
 		this.review = null;
 		this.sendMessage("Fin de la revue hebdomadaire");
+		return true;
 	}
 
-	private void handleStartIndividualTopic(final String sender,
+	private boolean handleStartIndividualTopic(final String sender,
 			final String message) {
 		if (this.review == null || !message.matches("\\s*#[^#].*")) {
-			return;
+			return false;
 		}
 
 		if (!this.review.isOwner(sender)) {
 			this.sendMessage(sender
 					+ ", vous n'êtes pas le conducteur de la réunion");
-			return;
+			return false;
 		}
 
 		final IndividualTopic topic =
 				new IndividualTopic(message.replaceFirst("#", "").trim());
 		this.review.begin(topic);
 		this.sendMessage("Sujet individuel : " + topic.getTitle());
+		return true;
 	}
 
-	private void handleStartCollectiveTopic(final String sender,
+	private boolean handleStartCollectiveTopic(final String sender,
 			final String message) {
 		if (this.review == null || !message.matches("\\s*##.*")) {
-			return;
+			return false;
 		}
 
 		if (!this.review.isOwner(sender)) {
 			this.sendMessage(sender
 					+ ", vous n'êtes pas le conducteur de la réunion");
-			return;
+			return false;
 		}
 
 		final CollectiveTopic topic =
 				new CollectiveTopic(message.replaceFirst("##", "").trim());
 		this.review.begin(topic);
 		this.sendMessage("Sujet collectif : " + topic.getTitle());
+		return true;
 	}
 
-	private void
-			handleDisplayCurrent(final String sender, final String message) {
+	private boolean handleDisplayCurrent(final String sender,
+			final String message) {
 		if (this.review == null || !"!courant".equalsIgnoreCase(message)) {
-			return;
+			return false;
 		}
 
 		final Topic current = this.review.getCurrentTopic();
 		} else if (current instanceof CollectiveTopic) {
 			this.sendMessage("Sujet collectif en cours : " + current.getTitle());
 		}
+		return true;
 	}
 
 	public void sendMessage(final String message) {