Improved code.

This commit is contained in:
Christian P. MOMON 2019-05-02 12:50:29 +02:00
parent 935bdeed07
commit dbbb9da4d6
2 changed files with 31 additions and 5 deletions

View File

@ -69,6 +69,10 @@ public class FinishReviewHook extends Hook
{
bot.sendMessage(sender + ", vous n'êtes pas le conducteur de la réunion");
}
else if (bot.getReview().isEnded())
{
bot.sendMessage("La revue est déjà finie.");
}
else if (bot.getReview().getParticipants().size() == 0)
{
bot.sendMessage("Participation nulle détectée. La revue est ignorée.");
@ -76,7 +80,7 @@ public class FinishReviewHook extends Hook
}
else
{
//
// End the review.
bot.getReview().endReview();
// Load and update review statistics.
@ -105,7 +109,7 @@ public class FinishReviewHook extends Hook
// Conclusion message in channel.
String date = LocalDate.now().format(DateTimeFormatter.BASIC_ISO_DATE);
String textReview = ReviewReporter.report(datas, bot.getReview());
String reviewText = ReviewReporter.report(datas, bot.getReview());
bot.sendMessage("% " + ReviewStatsReporter.reportReviewCount(datas));
//
@ -116,7 +120,7 @@ public class FinishReviewHook extends Hook
{
PastebinClient pastebinClient = new PastebinClient(bot.getPastebinSettings().getApiKey());
String pastebinUrl = pastebinClient.paste(textReview, "Revue APRIL " + date, Private.UNLISTED);
String pastebinUrl = pastebinClient.paste(reviewText, "Revue APRIL " + date, Private.UNLISTED);
bot.sendMessage("% Compte-rendu de la revue : " + pastebinUrl);
}
@ -142,12 +146,12 @@ public class FinishReviewHook extends Hook
logger.info("Create review directory: " + bot.getReviewDirectory().getAbsolutePath());
bot.getReviewDirectory().mkdirs();
}
FileUtils.writeStringToFile(reviewFile, textReview, StandardCharsets.UTF_8);
FileUtils.writeStringToFile(reviewFile, reviewText, StandardCharsets.UTF_8);
logger.info("File review saved in: [{}]", reviewFile.getAbsolutePath());
}
catch (final Exception exception)
{
logger.error("Error during file writing", exception);
logger.error("Error during file writing.", exception);
}
bot.sendMessage("% Durée de la revue : " + bot.getReview().getDurationInMinutes() + " minutes");

View File

@ -317,6 +317,28 @@ public class Review
return result;
}
/**
* Checks if is ended.
*
* @return true, if is ended
*/
public boolean isEnded()
{
boolean result;
if (this.endTime == null)
{
result = true;
}
else
{
result = false;
}
//
return result;
}
/**
* Checks if is owner.
*