hebdobot/bot/hooks/record.py

27 lines
761 B
Python
Raw Normal View History

2024-01-11 08:17:25 +01:00
import locale
import logger
from bot.review.stats import ReviewStats
class Record:
def process(self, bot, channel, sender, message):
"""
Si la commande est bonne, le bot renvoie le record de participation à la revue.
"""
if message.lower() == "!record":
logger.info("!record caught.")
locale.setlocale(locale.LC_ALL, "fr_FR.utf8")
formatter = "%A %d %B %Y"
stats = ReviewStats(bot.settings.REVIEW_STATS)
stats.load()
bot.send(
channel,
f"Le record de participation est de {stats.biggest.user_count} "
f"personnes le {stats.biggest.date.strftime(formatter)}.",
)
return True