forked from mindiell/hebdobot
49 lines
1.5 KiB
Python
49 lines
1.5 KiB
Python
|
import locale
|
||
|
|
||
|
import logger
|
||
|
from bot.review.stats import ReviewStats
|
||
|
|
||
|
|
||
|
class Stats:
|
||
|
def process(self, bot, channel, sender, message):
|
||
|
"""
|
||
|
Si la commande est bonne, le bot renvoie quelques statistiques de la revue.
|
||
|
"""
|
||
|
if message.lower() == "!stats":
|
||
|
logger.info("!stats caught.")
|
||
|
|
||
|
locale.setlocale(locale.LC_ALL, "fr_FR.utf8")
|
||
|
formatter = "%A %d %B %Y"
|
||
|
stats = ReviewStats(bot.settings.REVIEW_STATS)
|
||
|
stats.load()
|
||
|
|
||
|
if stats.size > 0:
|
||
|
bot.send(
|
||
|
channel,
|
||
|
f"% Il y a eu {stats.size} revues. La première date "
|
||
|
f"du {stats.first.date.strftime(formatter)}.",
|
||
|
)
|
||
|
else:
|
||
|
bot.send(channel, "% Il n'y a pas encore eu de revue.")
|
||
|
|
||
|
bot.send(
|
||
|
channel,
|
||
|
f"% Participation aux revues : min.={stats.min_users}, "
|
||
|
f"moy.={stats.avg_users:.1f}, max={stats.max_users}",
|
||
|
)
|
||
|
bot.send(
|
||
|
channel,
|
||
|
f"% Durée des revues : min.={stats.min_duration} min, "
|
||
|
f"moy.={stats.avg_duration:.1f} min, max={stats.max_duration} min",
|
||
|
)
|
||
|
bot.send(
|
||
|
channel,
|
||
|
f"% Tableau du nombre de personnes participantes : {stats.users_board}",
|
||
|
)
|
||
|
bot.send(
|
||
|
channel,
|
||
|
f"% Tableau des durées (en minutes) : {stats.durations_board}",
|
||
|
)
|
||
|
|
||
|
return True
|