diff --git a/src/org/april/hebdobot/cli/HebdobotCLI.java b/src/org/april/hebdobot/cli/HebdobotCLI.java index 541e99e..d7a589e 100644 --- a/src/org/april/hebdobot/cli/HebdobotCLI.java +++ b/src/org/april/hebdobot/cli/HebdobotCLI.java @@ -1,6 +1,6 @@ /** * Copyright (C) 2011-2013 Nicolas Vinot - * Copyright (C) 2017 Christian Pierre MOMON + * Copyright (C) 2017-2018 Christian Pierre MOMON * * This file is part of (April) Hebdobot. * @@ -201,7 +201,11 @@ public class HebdobotCLI logger.info("Alias list: " + aliases.toLineString()); Hebdobot bot = new Hebdobot(config.getIrcHost(), config.getIrcPort(), config.getIrcName(), config.getIrcChannel(), - configFile.getParentFile(), reviewDirectory, config.getReviewFileSuffix()); + configFile.getParentFile(), reviewDirectory); + + // + bot.setReviewWaitTime(config.getReviewWaitTime()); + bot.setReviewFileSuffix(config.getReviewFileSuffix()); // logger.info("Bot configuring…"); diff --git a/src/org/april/hebdobot/cli/HebdobotConfigFile.java b/src/org/april/hebdobot/cli/HebdobotConfigFile.java index 785cee4..bc75886 100644 --- a/src/org/april/hebdobot/cli/HebdobotConfigFile.java +++ b/src/org/april/hebdobot/cli/HebdobotConfigFile.java @@ -1,5 +1,5 @@ /** - * Copyright (C) 2017 Christian Pierre MOMON + * Copyright (C) 2017-2018 Christian Pierre MOMON * * This file is part of (April) Hebdobot. * @@ -21,6 +21,8 @@ package org.april.hebdobot.cli; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; +import java.time.LocalTime; +import java.time.format.DateTimeFormatter; import java.util.Properties; import org.april.hebdobot.HebdobotException; @@ -37,9 +39,12 @@ import fr.devinsy.util.strings.StringSet; */ public class HebdobotConfigFile extends Properties { - private static final long serialVersionUID = 5954809202666104536L; private static final Logger logger = LoggerFactory.getLogger(HebdobotConfigFile.class); + private static final long serialVersionUID = 5954809202666104536L; + + private static final String TIME_PATTERN = "^\\d\\dh\\d\\d$"; + /** * Instantiates a new launcher. * @@ -311,6 +316,31 @@ public class HebdobotConfigFile extends Properties return result; } + /** + * Gets the review wait time. + * + * @return the review wait time + * @throws HebdobotException + */ + public LocalTime getReviewWaitTime() throws HebdobotException + { + LocalTime result; + + String value = getProperty("review.waittime"); + + if ((value != null) && (value.matches(TIME_PATTERN))) + { + result = LocalTime.parse(value, DateTimeFormatter.ofPattern("HH'h'mm")); + } + else + { + result = null; + } + + // + return result; + } + /** * Gets the twitter access token. * @@ -380,7 +410,14 @@ public class HebdobotConfigFile extends Properties { boolean result; - result = true; + if ((getProperty("review.waittime") != null) && (!getProperty("review.waittime").matches(TIME_PATTERN))) + { + result = false; + } + else + { + result = true; + } // return result; diff --git a/test/org/april/hebdobot/BotMock.java b/test/org/april/hebdobot/BotMock.java index 93a4f41..64ad892 100644 --- a/test/org/april/hebdobot/BotMock.java +++ b/test/org/april/hebdobot/BotMock.java @@ -1,6 +1,6 @@ /** * Copyright (C) 2011-2013,2017 Nicolas Vinot - * Copyright (C) 2017 Christian Pierre MOMON + * Copyright (C) 2017-2018 Christian Pierre MOMON * * This file is part of (April) Hebdobot. * @@ -36,7 +36,7 @@ public class BotMock extends Hebdobot */ public BotMock() throws Exception { - super("myHost", 0, "Hebdobot", "#april-mock", null, new File("/tmp/"), "revue.txt"); + super("myHost", 0, "Hebdobot", "#april-mock", null, new File("/tmp/")); } /* (non-Javadoc)