Improved end review message (AGIR #2892).

This commit is contained in:
Christian P. MOMON 2018-01-28 11:20:56 +01:00
parent ad8cf7485f
commit c4f6f9ef3d
2 changed files with 37 additions and 37 deletions

View File

@ -4,7 +4,7 @@
# Revue settings.
review.directory=../reviews
review.file.suffix=revue.txt
review.file.suffix=-log-irc-revue-hebdomadaire.txt
# IRC settings.

View File

@ -63,6 +63,8 @@ public class Hebdobot extends PircBot
{
private static final Logger logger = LoggerFactory.getLogger(Hebdobot.class);
private static String DEFAULT_SUFFIX = "-log-irc-revue-hebdomadaire.txt";
private File homeDirectory;
private String host;
private int port;
@ -313,54 +315,52 @@ public class Hebdobot extends PircBot
}
else
{
String date = LocalDate.now().format(DateTimeFormatter.BASIC_ISO_DATE);
String textReview = this.review.toString();
if (this.pastebinSettings.isValid())
{
String date = LocalDate.now().format(DateTimeFormatter.BASIC_ISO_DATE);
String textReview = this.review.toString();
if (this.pastebinSettings.isValid())
logger.info("Pastebin the review.");
try
{
logger.info("Pastebin the review.");
try
{
PastebinClient pastebinClient = new PastebinClient(this.pastebinSettings.getApiKey());
PastebinClient pastebinClient = new PastebinClient(this.pastebinSettings.getApiKey());
String pastebinUrl = pastebinClient.paste(textReview, "Revue APRIL " + date, Private.UNLISTED);
String pastebinUrl = pastebinClient.paste(textReview, "Revue APRIL " + date, Private.UNLISTED);
sendMessage("% Compte-rendu de la revue : " + pastebinUrl);
}
catch (final Exception exception)
{
logger.error("Error during Pastebin submit.", exception);
}
sendMessage("% Compte-rendu de la revue : " + pastebinUrl);
}
if (this.reviewFileSuffix != null)
catch (final Exception exception)
{
logger.info("Write review file.");
try
{
if (!this.reviewDirectory.exists())
{
logger.info("Create review directory: " + this.reviewDirectory.getAbsolutePath());
this.reviewDirectory.mkdirs();
}
File file = new File(this.reviewDirectory, date + "_" + this.reviewFileSuffix);
FileUtils.writeStringToFile(file, textReview, StandardCharsets.UTF_8);
logger.info("File review saved in: [{}]", file.getAbsolutePath());
sendMessage("% Compte-rendu de la revue : " + file.getName());
}
catch (final Exception exception)
{
logger.error("Error during file generation", exception);
}
logger.error("Error during Pastebin submit.", exception);
}
}
logger.info("Write review file.");
File file = new File(this.reviewDirectory, date + StringUtils.defaultString(this.reviewFileSuffix, DEFAULT_SUFFIX));
try
{
if (!this.reviewDirectory.exists())
{
logger.info("Create review directory: " + this.reviewDirectory.getAbsolutePath());
this.reviewDirectory.mkdirs();
}
FileUtils.writeStringToFile(file, textReview, StandardCharsets.UTF_8);
logger.info("File review saved in: [{}]", file.getAbsolutePath());
}
catch (final Exception exception)
{
logger.error("Error during file generation", exception);
}
sendMessage("% Durée de la revue : " + this.review.getDurationInMinutes() + " minutes");
sendMessage("% Nombre de personnes participantes : " + this.review.getParticipants().size());
sendMessage("% " + this.review.getOwner()
+ ", ne pas oublier d'ajouter le compte-rendu de la revue sur https://agir.april.org/issues/135");
String x = String.format(
"%% %s, ne pas oublier d'ajouter le compte-rendu de la revue sur https://agir.april.org/issues/135 en utilisant comme nom de fichier %s",
this.review.getOwner(), file.getName());
logger.info("x=[{}]", x);
sendMessage(x);
String participants = StringUtils.join(this.review.getParticipants(), " ");
sendMessage("% " + participants + ", pensez à noter votre bénévalo : http://www.april.org/my?action=benevalo");
sendMessage("% Fin de la revue hebdomadaire");