Added review.waittime option. Improved config file validation and
Hebdobot constructor.
This commit is contained in:
parent
76f47db602
commit
29babf478b
3 changed files with 48 additions and 7 deletions
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (C) 2011-2013 Nicolas Vinot <aeris@imirhil.fr>
|
* Copyright (C) 2011-2013 Nicolas Vinot <aeris@imirhil.fr>
|
||||||
* Copyright (C) 2017 Christian Pierre MOMON <cmomon@april.org>
|
* Copyright (C) 2017-2018 Christian Pierre MOMON <cmomon@april.org>
|
||||||
*
|
*
|
||||||
* This file is part of (April) Hebdobot.
|
* This file is part of (April) Hebdobot.
|
||||||
*
|
*
|
||||||
|
@ -201,7 +201,11 @@ public class HebdobotCLI
|
||||||
logger.info("Alias list: " + aliases.toLineString());
|
logger.info("Alias list: " + aliases.toLineString());
|
||||||
|
|
||||||
Hebdobot bot = new Hebdobot(config.getIrcHost(), config.getIrcPort(), config.getIrcName(), config.getIrcChannel(),
|
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…");
|
logger.info("Bot configuring…");
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (C) 2017 Christian Pierre MOMON <cmomon@april.org>
|
* Copyright (C) 2017-2018 Christian Pierre MOMON <cmomon@april.org>
|
||||||
*
|
*
|
||||||
* This file is part of (April) Hebdobot.
|
* This file is part of (April) Hebdobot.
|
||||||
*
|
*
|
||||||
|
@ -21,6 +21,8 @@ package org.april.hebdobot.cli;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.time.LocalTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.april.hebdobot.HebdobotException;
|
import org.april.hebdobot.HebdobotException;
|
||||||
|
@ -37,9 +39,12 @@ import fr.devinsy.util.strings.StringSet;
|
||||||
*/
|
*/
|
||||||
public class HebdobotConfigFile extends Properties
|
public class HebdobotConfigFile extends Properties
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 5954809202666104536L;
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(HebdobotConfigFile.class);
|
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.
|
* Instantiates a new launcher.
|
||||||
*
|
*
|
||||||
|
@ -311,6 +316,31 @@ public class HebdobotConfigFile extends Properties
|
||||||
return result;
|
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.
|
* Gets the twitter access token.
|
||||||
*
|
*
|
||||||
|
@ -380,7 +410,14 @@ public class HebdobotConfigFile extends Properties
|
||||||
{
|
{
|
||||||
boolean result;
|
boolean result;
|
||||||
|
|
||||||
result = true;
|
if ((getProperty("review.waittime") != null) && (!getProperty("review.waittime").matches(TIME_PATTERN)))
|
||||||
|
{
|
||||||
|
result = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result = true;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (C) 2011-2013,2017 Nicolas Vinot <aeris@imirhil.fr>
|
* Copyright (C) 2011-2013,2017 Nicolas Vinot <aeris@imirhil.fr>
|
||||||
* Copyright (C) 2017 Christian Pierre MOMON <cmomon@april.org>
|
* Copyright (C) 2017-2018 Christian Pierre MOMON <cmomon@april.org>
|
||||||
*
|
*
|
||||||
* This file is part of (April) Hebdobot.
|
* This file is part of (April) Hebdobot.
|
||||||
*
|
*
|
||||||
|
@ -36,7 +36,7 @@ public class BotMock extends Hebdobot
|
||||||
*/
|
*/
|
||||||
public BotMock() throws Exception
|
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)
|
/* (non-Javadoc)
|
||||||
|
|
Loading…
Reference in a new issue