Improved code.

This commit is contained in:
Christian P. MOMON 2019-05-02 13:09:20 +02:00
parent 96a37bf770
commit 2c37b9ab0a
1 changed files with 13 additions and 8 deletions

View File

@ -107,12 +107,12 @@ public class FinishReviewHook extends Hook
datas = null;
}
// Conclusion message in channel.
// Generate the review text.
String date = LocalDate.now().format(DateTimeFormatter.BASIC_ISO_DATE);
String reviewText = ReviewReporter.report(datas, bot.getReview());
bot.sendMessage("% " + ReviewStatsReporter.reportReviewCount(datas));
//
// Pastebin the review text.
String pastebinUrl;
if (bot.getPastebinSettings().isValid())
{
logger.info("Pastebin the review.");
@ -120,17 +120,20 @@ public class FinishReviewHook extends Hook
{
PastebinClient pastebinClient = new PastebinClient(bot.getPastebinSettings().getApiKey());
String pastebinUrl = pastebinClient.paste(reviewText, "Revue APRIL " + date, Private.UNLISTED);
bot.sendMessage("% Compte-rendu de la revue : " + pastebinUrl);
pastebinUrl = pastebinClient.paste(reviewText, "Revue APRIL " + date, Private.UNLISTED);
}
catch (final Exception exception)
{
logger.error("Error during Pastebin submit.", exception);
pastebinUrl = "erreur";
}
}
else
{
pastebinUrl = "aucun";
}
//
// Save the review text.
logger.info("Write review file.");
File reviewFile = new File(bot.getReviewDirectory(), date + StringUtils.defaultString(bot.getReviewFileSuffix(), DEFAULT_SUFFIX));
if (reviewFile.exists())
@ -154,10 +157,12 @@ public class FinishReviewHook extends Hook
logger.error("Error during file writing.", exception);
}
// Send conclusion message in channel.
bot.sendMessage("% " + ReviewStatsReporter.reportReviewCount(datas));
bot.sendMessage("% Compte-rendu de la revue : " + pastebinUrl);
bot.sendMessage("% Durée de la revue : " + bot.getReview().getDurationInMinutes() + " minutes");
bot.sendMessage("% Nombre de personnes participantes : " + bot.getReview().getParticipants().size());
// Display statistics.
bot.sendMessage("% " + ReviewStatsReporter.reportNewMaxUserCount(datas, bot.getReview().getParticipants().size()));
bot.sendMessage(bot.getReview().getOwner(), ReviewStatsReporter.reportUserCount(datas, bot.getReview().getParticipants().size()));
bot.sendMessage(bot.getReview().getOwner(), ReviewStatsReporter.reportDuration(datas, bot.getReview().getDurationInMinutes()));