diff --git a/src/org/april/hebdobot/bot/Hebdobot.java b/src/org/april/hebdobot/bot/Hebdobot.java index 230c32c..ebcd6f8 100644 --- a/src/org/april/hebdobot/bot/Hebdobot.java +++ b/src/org/april/hebdobot/bot/Hebdobot.java @@ -1,5 +1,5 @@ /** - * Copyright (C) 2017-2019 Christian Pierre MOMON + * Copyright (C) 2017-2021 Christian Pierre MOMON * Copyright (C) 2011-2013,2017 Nicolas Vinot * * This file is part of (April) Hebdobot. @@ -22,6 +22,7 @@ package org.april.hebdobot.bot; import java.io.File; import java.io.IOException; import java.text.ParseException; +import java.time.LocalDate; import java.time.LocalTime; import org.apache.commons.lang3.StringUtils; @@ -166,6 +167,27 @@ public class Hebdobot extends PircBot this.hooker.add(new DefaultHook()); } + /** + * Check anniversary. + */ + public void checkReviewAnniversary() + { + LocalDate now = LocalDate.now(); + LocalDate creation = LocalDate.of(2010, 04, 30); + LocalDate anniv = LocalDate.of(now.getYear(), creation.getMonth(), creation.getDayOfMonth()); + + logger.debug("now ={}", now.toString()); + logger.debug("creation={}", creation.toString()); + logger.debug("anniv ={}", anniv.toString()); + + if ((!now.isBefore(anniv)) && (now.isBefore(anniv.plusDays(7)))) + { + logger.info("Review anniversary detected."); + int year = anniv.getYear() - creation.getYear(); + sendMessage("% \\o/ Joyeux " + year + "e anniversaire la revue hebdo \\o/"); + } + } + /** * Close. */