hebdobot/hooks/missing.py

37 lines
1.3 KiB
Python

import logger
class Missing:
def process(self, bot, channel, sender, message):
"""
Si la commande est bonne, le bot renvoie la liste des personnes n'ayant pas
encore participé au sujet en cours.
"""
if message.lower() in ("!manquants", "!manquantes"):
logger.info("!manquants caught.")
if not bot.review.is_started:
bot.send(channel, f"{sender}, pas de revue en cours.")
return True
if bot.review.current_topic is None:
bot.send(channel, "% Pas de sujet en cours.")
return True
all_participants = bot.review.participants + [bot.review.owner]
missing_participants = list(
set(all_participants) - set(bot.review.current_topic.participants)
)
if missing_participants == []:
bot.send(
channel,
"% Tout le monde s'est exprimé sur le sujet courant \\o/",
)
else:
bot.send(
channel,
"% Personnes participantes ne s'étant pas exprimées sur le "
f"sujet courant : {', '.join(missing_participants)}",
)
return True