/** * Copyright (C) 2018 Christian Pierre MOMON * * This file is part of (April) Ememem. * * Ememem is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Ememem is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with Ememem. If not, see */ package org.april.hebdobot.bot.hooks; import java.time.LocalTime; import org.apache.commons.lang3.StringUtils; import org.april.hebdobot.bot.Hebdobot; import org.april.hebdobot.bot.review.Review; import org.quartz.SchedulerException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * The Class StartReviewHook. */ public class StartReviewHook extends Hook { private static final Logger logger = LoggerFactory.getLogger(StartReviewHook.class); /* (non-Javadoc) * @see org.april.hebdobot.bot.hooks.Hook#attemptProcess(org.april.hebdobot.bot.Hebdobot, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String) */ @Override public boolean attemptProcess(final Hebdobot bot, final String channel, final String sender, final String login, final String hostname, final String message) { boolean result; if (StringUtils.equalsAnyIgnoreCase(message, "!debut", "!début")) { logger.info("!debut caught."); if ((bot.getReviewWaitTime() != null) && (LocalTime.now().isBefore(bot.getReviewWaitTime()))) { bot.sendMessage(sender + ", ce n'est pas encore l'heure."); } else { // Start. if (bot.getCronManager() != null) { try { bot.getCronManager().shutdown(); } catch (SchedulerException exception) { logger.warn("Scheduler shutdown failed.", exception); } } bot.setReview(new Review(sender, bot.getAliases())); bot.sendMessage(sender, "Bonjour " + sender + ", vous êtes le conducteur de réunion."); bot.sendMessage(sender, "Pour terminer la réunion, tapez \"!fin\""); bot.sendMessage("% Début de la réunion hebdomadaire"); bot.sendMessage( "% rappel : toute ligne commençant par % sera considérée comme un commentaire et non prise en compte dans la synthèse"); bot.sendMessage("% pour connaître le point courant, taper !courant"); } result = true; } else { result = false; } // return result; } }