Added review anniversary feature.

This commit is contained in:
Christian P. MOMON 2021-04-15 00:11:46 +02:00
parent caba69fc75
commit 58d8bcc3a8

View File

@ -1,5 +1,5 @@
/** /**
* Copyright (C) 2017-2019 Christian Pierre MOMON <cmomon@april.org> * Copyright (C) 2017-2021 Christian Pierre MOMON <cmomon@april.org>
* Copyright (C) 2011-2013,2017 Nicolas Vinot <aeris@imirhil.fr> * Copyright (C) 2011-2013,2017 Nicolas Vinot <aeris@imirhil.fr>
* *
* This file is part of (April) Hebdobot. * This file is part of (April) Hebdobot.
@ -22,6 +22,7 @@ package org.april.hebdobot.bot;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.text.ParseException; import java.text.ParseException;
import java.time.LocalDate;
import java.time.LocalTime; import java.time.LocalTime;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -166,6 +167,27 @@ public class Hebdobot extends PircBot
this.hooker.add(new DefaultHook()); 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. * Close.
*/ */