Forbid stopping when review in progress

This commit is contained in:
Nicolas Vinot 2012-09-08 17:34:28 +02:00
parent b2009b66fd
commit 929671c5a5
7 changed files with 61 additions and 22 deletions

View File

@ -1,14 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java"/>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/classes" path="target/generated-sources/jaxb">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>

View File

@ -6,12 +6,12 @@
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>

View File

@ -1,4 +1,3 @@
#Sun Oct 09 17:20:12 CEST 2011
eclipse.preferences.version=1
encoding//src/main/java=UTF8
encoding//src/main/resources=UTF8

View File

@ -1,9 +1,5 @@
#Sat Dec 10 17:49:06 CET 2011
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.6

View File

@ -1,4 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<installed facet="java" version="1.6"/>
</faceted-project>

View File

@ -4,6 +4,8 @@ import java.util.Collection;
import java.util.LinkedList;
import org.jibble.pircbot.PircBot;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.imirhil.april.hebdobot.Context;
import fr.imirhil.april.hebdobot.review.CollectiveTopic;
@ -13,6 +15,7 @@ import fr.imirhil.april.hebdobot.review.Review;
import fr.imirhil.april.hebdobot.review.Topic;
public class Bot extends PircBot {
private static final Logger LOGGER = LoggerFactory.getLogger(Bot.class);
private final String host;
private final int port;
private final String channel;
@ -45,6 +48,10 @@ public class Bot extends PircBot {
@Override
protected void onMessage(final String channel, final String sender,
final String login, final String hostname, String message) {
LOGGER.debug(
"Message received - channel : {}, sender : {}, message : {}",
new Object[] { channel, sender, message });
if (!channel.equalsIgnoreCase(this.channel)) {
return;
}
@ -101,6 +108,11 @@ public class Bot extends PircBot {
return false;
}
if (this.review != null) {
this.sendMessage("% Une revue est en cours, arrêt impossible");
return false;
}
Context.close();
return true;
}
@ -114,7 +126,7 @@ public class Bot extends PircBot {
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");
this.sendMessage("% Début de la réunion hebdomadaire");
return true;
}
@ -134,7 +146,7 @@ public class Bot extends PircBot {
}
this.review = null;
this.sendMessage("Fin de la revue hebdomadaire");
this.sendMessage("% Fin de la revue hebdomadaire");
return true;
}
@ -184,17 +196,19 @@ public class Bot extends PircBot {
final Topic current = this.review.getCurrentTopic();
if (current == null) {
this.sendMessage("Pas de sujet en cours");
this.sendMessage("% Pas de sujet en cours");
} else if (current instanceof IndividualTopic) {
this.sendMessage("Sujet individuel en cours : "
this.sendMessage("% Sujet individuel en cours : "
+ current.getTitle());
} else if (current instanceof CollectiveTopic) {
this.sendMessage("Sujet collectif en cours : " + current.getTitle());
this.sendMessage("% Sujet collectif en cours : "
+ current.getTitle());
}
return true;
}
public void sendMessage(final String message) {
LOGGER.debug("Send message : {}", message);
this.sendMessage(this.channel, message);
}
}

View File

@ -34,9 +34,13 @@ public abstract class StatusNetClient {
System.out.println(service.getAuthorizationUrl(requestToken));
System.out.print(">>");
final Scanner scanner = new Scanner(System.in);
Verifier verifier = new Verifier(scanner.nextLine());
final Token token = service.getAccessToken(requestToken, verifier);
System.out.println(token);
try {
final Verifier verifier = new Verifier(scanner.nextLine());
final Token token = service.getAccessToken(requestToken, verifier);
System.out.println(token);
} finally {
scanner.close();
}
}
public void post(final String message) {