From 2c37b9ab0a9c7cb54a1c3554bcc83c589b8bc365 Mon Sep 17 00:00:00 2001 From: "Christian P. MOMON" Date: Thu, 2 May 2019 13:09:20 +0200 Subject: [PATCH] Improved code. --- .../hebdobot/bot/hooks/FinishReviewHook.java | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/org/april/hebdobot/bot/hooks/FinishReviewHook.java b/src/org/april/hebdobot/bot/hooks/FinishReviewHook.java index 3bc2800..d401ca1 100644 --- a/src/org/april/hebdobot/bot/hooks/FinishReviewHook.java +++ b/src/org/april/hebdobot/bot/hooks/FinishReviewHook.java @@ -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()));