48 lines
1.6 KiB
Python
48 lines
1.6 KiB
Python
from datetime import date, timedelta
|
|
import locale
|
|
|
|
import logger
|
|
|
|
|
|
class Anniv:
|
|
def process(self, bot, channel, sender, message):
|
|
"""
|
|
Si la commande est bonne, le bot renvoie les dates d'anniversaire de la revue.
|
|
"""
|
|
if message.lower() == "!anniv":
|
|
logger.info("!anniv caught.")
|
|
|
|
# Calcul des anniversaires
|
|
locale.setlocale(locale.LC_ALL, "fr_FR.utf8")
|
|
formatter = "%A %d %B %Y"
|
|
today = date.today()
|
|
|
|
review_birthdate = date(2010, 4, 30)
|
|
review_birthday = review_birthdate.strftime(formatter)
|
|
review_age = int((today - review_birthdate).days / 365.2425)
|
|
bot.send(
|
|
channel,
|
|
f"La revue hebdomadaire est née le {review_birthday} et a "
|
|
f"{review_age} ans",
|
|
)
|
|
|
|
hebdobot_birthdate = date(2011, 9, 9)
|
|
hebdobot_birthday = hebdobot_birthdate.strftime(formatter)
|
|
hebdobot_age = int((today - hebdobot_birthdate).days / 365.2425)
|
|
bot.send(
|
|
channel,
|
|
f"Hebdobot a géré sa première revue le {hebdobot_birthday} et a "
|
|
f"{hebdobot_age} ans",
|
|
)
|
|
|
|
april_birthdate = date(1996, 11, 20)
|
|
april_birthday = april_birthdate.strftime(formatter)
|
|
april_age = int((today - april_birthdate).days / 365.2425)
|
|
bot.send(
|
|
channel,
|
|
f"L'April a été déclarée en préfecture le {april_birthday} et a "
|
|
f"{april_age} ans",
|
|
)
|
|
|
|
return True
|