2018-09-21 01:04:12 +02:00
|
|
|
|
/**
|
|
|
|
|
* Copyright (C) 2018 Christian Pierre MOMON <cmomon@april.org>
|
|
|
|
|
*
|
2018-11-07 14:01:29 +01:00
|
|
|
|
* This file is part of (April) Hebdobot.
|
2018-09-21 01:04:12 +02:00
|
|
|
|
*
|
2018-11-07 14:01:29 +01:00
|
|
|
|
* Hebdobot is free software: you can redistribute it and/or modify
|
2018-09-21 01:04:12 +02:00
|
|
|
|
* 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.
|
|
|
|
|
*
|
2018-11-07 14:01:29 +01:00
|
|
|
|
* Hebdobot is distributed in the hope that it will be useful,
|
2018-09-21 01:04:12 +02:00
|
|
|
|
* 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
|
2018-11-07 14:01:29 +01:00
|
|
|
|
* along with Hebdobot. If not, see <http://www.gnu.org/licenses/>
|
2018-09-21 01:04:12 +02:00
|
|
|
|
*/
|
|
|
|
|
package org.april.hebdobot.bot.hooks;
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.april.hebdobot.bot.Hebdobot;
|
|
|
|
|
import org.april.hebdobot.bot.review.CollectiveTopic;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The Class CollectiveSubjectHook.
|
|
|
|
|
*/
|
|
|
|
|
public class CollectiveSubjectHook extends Hook
|
|
|
|
|
{
|
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(CollectiveSubjectHook.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 (message.matches("\\s*##.*"))
|
|
|
|
|
{
|
|
|
|
|
logger.info("\\s*##.* caught.");
|
|
|
|
|
|
|
|
|
|
// Collective topic, must be before individual topic.
|
|
|
|
|
if (bot.getReview() != null)
|
|
|
|
|
{
|
|
|
|
|
if (bot.getReview().isOwner(sender))
|
|
|
|
|
{
|
|
|
|
|
CollectiveTopic topic = new CollectiveTopic(message.replaceFirst("##", "").trim());
|
|
|
|
|
if (!bot.getReview().isEmpty())
|
|
|
|
|
{
|
|
|
|
|
String participants = StringUtils.join(bot.getReview().getParticipants(), " ");
|
2021-01-30 23:48:08 +01:00
|
|
|
|
bot.sendMessage(String.format("%% +%s %s, on va passer à la suite : %s", bot.getTimekeeper().format(), participants,
|
|
|
|
|
topic.getTitle()));
|
2018-09-21 01:04:12 +02:00
|
|
|
|
}
|
|
|
|
|
bot.getReview().begin(topic);
|
|
|
|
|
bot.sendMessage("Sujet collectif : " + topic.getTitle());
|
|
|
|
|
bot.sendMessage("% 1 minute max");
|
|
|
|
|
bot.sendMessage("% si rien à signaler vous pouvez écrire % ras");
|
|
|
|
|
bot.sendMessage("% quand vous avez fini vous le dites par % fini");
|
2021-01-30 23:48:08 +01:00
|
|
|
|
bot.getTimekeeper().start();
|
2018-09-21 01:04:12 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
bot.sendMessage(sender + ", vous n'êtes pas le conducteur de la réunion");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
result = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|