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

View File

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

View File

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

View File

@ -1,9 +1,5 @@
#Sat Dec 10 17:49:06 CET 2011
eclipse.preferences.version=1 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.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=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.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.6 org.eclipse.jdt.core.compiler.source=1.6

View File

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

View File

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

View File

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