hebdobot/hooks/collective_subject.py

47 lines
1.9 KiB
Python
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import re
import logger
class CollectiveSubject:
def process(self, bot, channel, sender, message):
"""
Si la commande est bonne, le bot démarre un nouveau sujet collectif.
"""
if re.match("^\s*##.*$", message):
logger.info("^\s*##.*$ caught.")
if bot.review.is_started:
if bot.review.is_owner(sender):
# On lance un nouveau sujet collectif
bot.review.new_collective_topic(message.strip()[2:].strip())
# S'il y avait un ancien sujet, on le signale
if bot.review.last_topic:
bot.review.last_topic.close()
bot.send(
channel,
f"% durée du point {bot.review.last_topic.title} : "
f"{bot.review.last_topic.duration}",
)
# Et on prévient les participants
bot.send(
channel,
f"% {' '.join(bot.review.participants)}, on va passer à la "
f"suite : {bot.review.current_topic.title}",
)
# Et on signale le démarrage du sujet
bot.send(
channel,
f"Sujet collectif : {bot.review.current_topic.title}",
)
bot.send(channel, "% 1 minute max")
bot.send(channel, "% si rien à signaler vous pouvez écrire % ras")
bot.send(channel, "% quand vous avez fini vous le dites par % fini")
else:
bot.send(
channel,
f"{sender}, vous n'êtes pas responsable de la réunion",
)
return True