Compare commits
11 Commits
4382db9e8b
...
cbdef8e674
Author | SHA1 | Date |
---|---|---|
Christian P. MOMON | cbdef8e674 | |
Christian P. MOMON | 483732382b | |
Christian P. MOMON | 925bc0a805 | |
Christian P. MOMON | d709328666 | |
Christian P. MOMON | 54669590ab | |
Christian P. MOMON | 66bb09ef87 | |
Christian P. MOMON | f5da3a6ae4 | |
Christian P. MOMON | 534d335df1 | |
Christian P. MOMON | 216db84883 | |
Christian P. MOMON | 47fd4b58e8 | |
Christian P. MOMON | c469fd5c7b |
|
@ -27,8 +27,10 @@ import java.time.LocalTime;
|
|||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.april.hebdobot.HebdobotException;
|
||||
import org.april.hebdobot.bot.hooks.AnnivHook;
|
||||
import org.april.hebdobot.bot.hooks.BadCommandHook;
|
||||
import org.april.hebdobot.bot.hooks.CancelPreviousInputHook;
|
||||
import org.april.hebdobot.bot.hooks.ChronoHook;
|
||||
import org.april.hebdobot.bot.hooks.CollectiveSubjectHook;
|
||||
import org.april.hebdobot.bot.hooks.CommentHook;
|
||||
import org.april.hebdobot.bot.hooks.CurrentHook;
|
||||
|
@ -37,7 +39,7 @@ import org.april.hebdobot.bot.hooks.DefaultHook;
|
|||
import org.april.hebdobot.bot.hooks.FinishReviewHook;
|
||||
import org.april.hebdobot.bot.hooks.HelloHook;
|
||||
import org.april.hebdobot.bot.hooks.HelpHook;
|
||||
import org.april.hebdobot.bot.hooks.HookManager;
|
||||
import org.april.hebdobot.bot.hooks.Hooker;
|
||||
import org.april.hebdobot.bot.hooks.IndividualSubjectHook;
|
||||
import org.april.hebdobot.bot.hooks.InputReviewHook;
|
||||
import org.april.hebdobot.bot.hooks.LicenseHook;
|
||||
|
@ -48,7 +50,6 @@ import org.april.hebdobot.bot.hooks.StatsHook;
|
|||
import org.april.hebdobot.bot.hooks.StatusHook;
|
||||
import org.april.hebdobot.bot.hooks.StopReviewHook;
|
||||
import org.april.hebdobot.bot.hooks.ThanksHook;
|
||||
import org.april.hebdobot.bot.hooks.TimekeeperHook;
|
||||
import org.april.hebdobot.bot.hooks.VersionHook;
|
||||
import org.april.hebdobot.bot.review.Message;
|
||||
import org.april.hebdobot.bot.review.Review;
|
||||
|
@ -58,7 +59,7 @@ import org.april.hebdobot.identica.IdenticaSettings;
|
|||
import org.april.hebdobot.privatebin.PrivatebinSettings;
|
||||
import org.april.hebdobot.twitter.TwitterClient;
|
||||
import org.april.hebdobot.twitter.TwitterSettings;
|
||||
import org.april.hebdobot.util.Timekeeper;
|
||||
import org.april.hebdobot.util.Chrono;
|
||||
import org.jibble.pircbot.IrcException;
|
||||
import org.jibble.pircbot.NickAlreadyInUseException;
|
||||
import org.jibble.pircbot.PircBot;
|
||||
|
@ -66,6 +67,7 @@ import org.quartz.SchedulerException;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import fr.devinsy.strings.StringList;
|
||||
import twitter4j.TwitterException;
|
||||
|
||||
/**
|
||||
|
@ -85,14 +87,14 @@ public class Hebdobot extends PircBot
|
|||
private String reviewFileSuffix;
|
||||
private LocalTime reviewWaitTime;
|
||||
private Review review;
|
||||
private Timekeeper timekeeper;
|
||||
private Chrono chrono;
|
||||
private IdenticaSettings identicaSettings;
|
||||
private PrivatebinSettings privatebinSettings;
|
||||
private TwitterSettings twitterSettings;
|
||||
private CronSettings cronSettings;
|
||||
private UserAliases aliases;
|
||||
private CronManager cronManager;
|
||||
private HookManager hooker;
|
||||
private Hooker hooker;
|
||||
|
||||
/**
|
||||
* Instantiates a new hebdobot.
|
||||
|
@ -128,7 +130,7 @@ public class Hebdobot extends PircBot
|
|||
this.reviewFileSuffix = null;
|
||||
this.reviewWaitTime = null;
|
||||
this.review = null;
|
||||
this.timekeeper = new Timekeeper();
|
||||
this.chrono = new Chrono();
|
||||
|
||||
this.identicaSettings = new IdenticaSettings();
|
||||
this.privatebinSettings = new PrivatebinSettings();
|
||||
|
@ -139,8 +141,10 @@ public class Hebdobot extends PircBot
|
|||
this.cronManager = null;
|
||||
|
||||
//
|
||||
this.hooker = new HookManager();
|
||||
this.hooker = new Hooker();
|
||||
|
||||
this.hooker.add(new CancelPreviousInputHook());
|
||||
this.hooker.add(new ChronoHook());
|
||||
this.hooker.add(new CollectiveSubjectHook());
|
||||
this.hooker.add(new CommentHook());
|
||||
this.hooker.add(new CurrentHook());
|
||||
|
@ -153,9 +157,8 @@ public class Hebdobot extends PircBot
|
|||
this.hooker.add(new StopReviewHook());
|
||||
this.hooker.add(new StatsHook());
|
||||
this.hooker.add(new StatusHook());
|
||||
this.hooker.add(new CancelPreviousInputHook());
|
||||
|
||||
this.hooker.add(new TimekeeperHook());
|
||||
this.hooker.add(new AnnivHook());
|
||||
this.hooker.add(new DateHook());
|
||||
this.hooker.add(new HelloHook());
|
||||
this.hooker.add(new LicenseHook());
|
||||
|
@ -197,6 +200,15 @@ public class Hebdobot extends PircBot
|
|||
this.dispose();
|
||||
}
|
||||
|
||||
/**
|
||||
* End review.
|
||||
*/
|
||||
public void endReview()
|
||||
{
|
||||
this.review.endReview();
|
||||
this.chrono.reset();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the aliases.
|
||||
*
|
||||
|
@ -207,6 +219,11 @@ public class Hebdobot extends PircBot
|
|||
return this.aliases;
|
||||
}
|
||||
|
||||
public Chrono getChrono()
|
||||
{
|
||||
return this.chrono;
|
||||
}
|
||||
|
||||
public CronManager getCronManager()
|
||||
{
|
||||
return this.cronManager;
|
||||
|
@ -222,6 +239,32 @@ public class Hebdobot extends PircBot
|
|||
return this.cronSettings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the help.
|
||||
*
|
||||
* @param source
|
||||
* the source
|
||||
* @return the help
|
||||
* @throws HebdobotException
|
||||
* the hebdobot exception
|
||||
*/
|
||||
public StringList getHelp(final String source) throws HebdobotException
|
||||
{
|
||||
StringList result;
|
||||
|
||||
if (source == null)
|
||||
{
|
||||
result = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = this.hooker.attemptHelp(source);
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the home directory.
|
||||
*
|
||||
|
@ -272,11 +315,6 @@ public class Hebdobot extends PircBot
|
|||
return this.reviewWaitTime;
|
||||
}
|
||||
|
||||
public Timekeeper getTimekeeper()
|
||||
{
|
||||
return this.timekeeper;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the twitter settings.
|
||||
*
|
||||
|
@ -454,13 +492,14 @@ public class Hebdobot extends PircBot
|
|||
}
|
||||
catch (IOException exception)
|
||||
{
|
||||
logger.error("IOException during connection ", exception);
|
||||
try
|
||||
{
|
||||
Thread.sleep(60000);
|
||||
Thread.sleep(200000);
|
||||
}
|
||||
catch (InterruptedException subException)
|
||||
{
|
||||
subException.printStackTrace();
|
||||
logger.error("Exception during sleep ", subException);
|
||||
}
|
||||
}
|
||||
catch (IrcException exception)
|
||||
|
@ -486,6 +525,28 @@ public class Hebdobot extends PircBot
|
|||
logger.info("Bot ready.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Send chrono message.
|
||||
*/
|
||||
public void sendChronoMessage()
|
||||
{
|
||||
if (this.review == null)
|
||||
{
|
||||
sendMessage("% durée du point : pas de revue en cours.");
|
||||
}
|
||||
else if (this.review.isEmpty())
|
||||
{
|
||||
sendMessage("% durée du point : pas de point en cours.");
|
||||
}
|
||||
else
|
||||
{
|
||||
String topicTitle = this.review.getCurrentTopic().getTitle();
|
||||
String chronoValue = this.chrono.toString();
|
||||
|
||||
sendMessage(String.format("%% durée du point %s : %s", topicTitle, chronoValue));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send message.
|
||||
*
|
||||
|
@ -532,4 +593,13 @@ public class Hebdobot extends PircBot
|
|||
{
|
||||
this.reviewWaitTime = reviewWaitTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop review.
|
||||
*/
|
||||
public void stopReview()
|
||||
{
|
||||
setReview(null);
|
||||
this.chrono.reset();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,103 @@
|
|||
/**
|
||||
* Copyright (C) 2021 Christian Pierre MOMON <cmomon@april.org>
|
||||
*
|
||||
* This file is part of (April) Hebdobot.
|
||||
*
|
||||
* Hebdobot 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.
|
||||
*
|
||||
* Hebdobot 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 Hebdobot. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
package org.april.hebdobot.bot.hooks;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.Period;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.april.hebdobot.HebdobotException;
|
||||
import org.april.hebdobot.bot.Hebdobot;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import fr.devinsy.strings.StringList;
|
||||
import fr.devinsy.strings.StringsUtils;
|
||||
|
||||
/**
|
||||
* The Class AnnivHook.
|
||||
*/
|
||||
public class AnnivHook extends Hook
|
||||
{
|
||||
private static final Logger logger = LoggerFactory.getLogger(AnnivHook.class);
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.april.hebdobot.bot.hooks.Hook#attemptHelp(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public StringList attemptHelp(final String token) throws HebdobotException
|
||||
{
|
||||
StringList result;
|
||||
|
||||
if (StringsUtils.equalsAnyIgnoreCase(token, "anniv"))
|
||||
{
|
||||
result = new StringList("!anniv : afficher des anniversaires");
|
||||
}
|
||||
else
|
||||
{
|
||||
result = null;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/* (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, "!anniv"))
|
||||
{
|
||||
logger.info("!anniv caught.");
|
||||
|
||||
LocalDate now = LocalDate.now();
|
||||
LocalDate revueBirthdate = LocalDate.of(2010, 04, 30);
|
||||
String birthdate = revueBirthdate.format(DateTimeFormatter.ofPattern("EEEE dd MMMM yyyy", Locale.FRENCH));
|
||||
int years = Period.between(revueBirthdate, now).getYears();
|
||||
|
||||
bot.sendMessage(String.format("La revue hebdomadaire est née le %s et a %d ans", birthdate, years));
|
||||
|
||||
LocalDate hebdobotBirthdate = LocalDate.of(2011, 9, 9);
|
||||
years = Period.between(hebdobotBirthdate, now).getYears();
|
||||
birthdate = hebdobotBirthdate.format(DateTimeFormatter.ofPattern("EEEE dd MMMM yyyy", Locale.FRENCH));
|
||||
bot.sendMessage(String.format("Hebdobot a géré sa première revue le %s et a %d ans", birthdate, years));
|
||||
|
||||
LocalDate aprilBirthdate = LocalDate.of(1996, 11, 20);
|
||||
birthdate = aprilBirthdate.format(DateTimeFormatter.ofPattern("EEEE dd MMMM yyyy", Locale.FRENCH));
|
||||
years = Period.between(aprilBirthdate, now).getYears();
|
||||
bot.sendMessage(String.format("L'April a été déclarée en préférecture le %s et a %d ans", birthdate, years));
|
||||
|
||||
result = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2018 Christian Pierre MOMON <cmomon@april.org>
|
||||
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||
*
|
||||
* This file is part of (April) Hebdobot.
|
||||
*
|
||||
|
@ -18,10 +18,13 @@
|
|||
*/
|
||||
package org.april.hebdobot.bot.hooks;
|
||||
|
||||
import org.april.hebdobot.HebdobotException;
|
||||
import org.april.hebdobot.bot.Hebdobot;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import fr.devinsy.strings.StringList;
|
||||
|
||||
/**
|
||||
* The Class DefaultHook.
|
||||
*/
|
||||
|
@ -29,6 +32,15 @@ public class BadCommandHook extends Hook
|
|||
{
|
||||
private static final Logger logger = LoggerFactory.getLogger(BadCommandHook.class);
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.april.hebdobot.bot.hooks.Hook#attemptHelp(org.april.hebdobot.bot.Hebdobot, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public StringList attemptHelp(final String message) throws HebdobotException
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (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)
|
||||
*/
|
||||
|
|
|
@ -18,11 +18,13 @@
|
|||
*/
|
||||
package org.april.hebdobot.bot.hooks;
|
||||
|
||||
import org.april.hebdobot.HebdobotException;
|
||||
import org.april.hebdobot.bot.Hebdobot;
|
||||
import org.april.hebdobot.bot.review.Topic;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import fr.devinsy.strings.StringList;
|
||||
import fr.devinsy.strings.StringsUtils;
|
||||
|
||||
/**
|
||||
|
@ -32,6 +34,27 @@ public class CancelPreviousInputHook extends Hook
|
|||
{
|
||||
private static final Logger logger = LoggerFactory.getLogger(CancelPreviousInputHook.class);
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.april.hebdobot.bot.hooks.Hook#attemptHelp(org.april.hebdobot.bot.Hebdobot, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public StringList attemptHelp(final String token) throws HebdobotException
|
||||
{
|
||||
StringList result;
|
||||
|
||||
if (StringsUtils.equalsAnyIgnoreCase(token, "cancelprevious", "oops", "oups"))
|
||||
{
|
||||
result = new StringList("!oups, !oops, !cancelprevious : annuler la dernière entrée dans un point de revue");
|
||||
}
|
||||
else
|
||||
{
|
||||
result = null;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/* (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)
|
||||
*/
|
||||
|
|
|
@ -19,16 +19,41 @@
|
|||
package org.april.hebdobot.bot.hooks;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.april.hebdobot.HebdobotException;
|
||||
import org.april.hebdobot.bot.Hebdobot;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import fr.devinsy.strings.StringList;
|
||||
import fr.devinsy.strings.StringsUtils;
|
||||
|
||||
/**
|
||||
* The Class TimekeeperHook.
|
||||
* The Class ChronoHook.
|
||||
*/
|
||||
public class TimekeeperHook extends Hook
|
||||
public class ChronoHook extends Hook
|
||||
{
|
||||
private static final Logger logger = LoggerFactory.getLogger(TimekeeperHook.class);
|
||||
private static final Logger logger = LoggerFactory.getLogger(ChronoHook.class);
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.april.hebdobot.bot.hooks.Hook#attemptHelp(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public StringList attemptHelp(final String token) throws HebdobotException
|
||||
{
|
||||
StringList result;
|
||||
|
||||
if (StringsUtils.equalsAnyIgnoreCase(token, "chrono"))
|
||||
{
|
||||
result = new StringList("!chrono : afficher la durée du point de revue en cours");
|
||||
}
|
||||
else
|
||||
{
|
||||
result = null;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/* (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)
|
||||
|
@ -39,10 +64,11 @@ public class TimekeeperHook extends Hook
|
|||
{
|
||||
boolean result;
|
||||
|
||||
if (StringUtils.equalsAnyIgnoreCase(message, "!timekeeper", "!chrono"))
|
||||
if (StringUtils.equalsAnyIgnoreCase(message, "!chrono"))
|
||||
{
|
||||
logger.info("!chrono caught.");
|
||||
bot.sendMessage(bot.getTimekeeper().format());
|
||||
// bot.sendChronoMessage();
|
||||
bot.sendMessage(bot.getChrono().format());
|
||||
|
||||
result = true;
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2018 Christian Pierre MOMON <cmomon@april.org>
|
||||
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||
*
|
||||
* This file is part of (April) Hebdobot.
|
||||
*
|
||||
|
@ -19,11 +19,15 @@
|
|||
package org.april.hebdobot.bot.hooks;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.april.hebdobot.HebdobotException;
|
||||
import org.april.hebdobot.bot.Hebdobot;
|
||||
import org.april.hebdobot.bot.review.CollectiveTopic;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import fr.devinsy.strings.StringList;
|
||||
import fr.devinsy.strings.StringsUtils;
|
||||
|
||||
/**
|
||||
* The Class CollectiveSubjectHook.
|
||||
*/
|
||||
|
@ -31,6 +35,27 @@ public class CollectiveSubjectHook extends Hook
|
|||
{
|
||||
private static final Logger logger = LoggerFactory.getLogger(CollectiveSubjectHook.class);
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.april.hebdobot.bot.hooks.Hook#attemptHelp(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public StringList attemptHelp(final String token) throws HebdobotException
|
||||
{
|
||||
StringList result;
|
||||
|
||||
if (StringsUtils.equalsAnyIgnoreCase(token, "##"))
|
||||
{
|
||||
result = new StringList("## titre : démarrer un sujet collectif");
|
||||
}
|
||||
else
|
||||
{
|
||||
result = null;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/* (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)
|
||||
*/
|
||||
|
@ -52,16 +77,17 @@ public class CollectiveSubjectHook extends Hook
|
|||
CollectiveTopic topic = new CollectiveTopic(message.replaceFirst("##", "").trim());
|
||||
if (!bot.getReview().isEmpty())
|
||||
{
|
||||
bot.sendChronoMessage();
|
||||
|
||||
String participants = StringUtils.join(bot.getReview().getParticipants(), " ");
|
||||
bot.sendMessage(String.format("%% %s %s, on va passer à la suite : %s", bot.getTimekeeper().format(), participants,
|
||||
topic.getTitle()));
|
||||
bot.sendMessage(String.format("%% %s, on va passer à la suite : %s", participants, topic.getTitle()));
|
||||
}
|
||||
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");
|
||||
bot.getTimekeeper().start();
|
||||
bot.getChrono().start();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2018 Christian Pierre MOMON <cmomon@april.org>
|
||||
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||
*
|
||||
* This file is part of (April) Hebdobot.
|
||||
*
|
||||
|
@ -18,10 +18,14 @@
|
|||
*/
|
||||
package org.april.hebdobot.bot.hooks;
|
||||
|
||||
import org.april.hebdobot.HebdobotException;
|
||||
import org.april.hebdobot.bot.Hebdobot;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import fr.devinsy.strings.StringList;
|
||||
import fr.devinsy.strings.StringsUtils;
|
||||
|
||||
/**
|
||||
* The Class CommentHook.
|
||||
*/
|
||||
|
@ -29,6 +33,27 @@ public class CommentHook extends Hook
|
|||
{
|
||||
private static final Logger logger = LoggerFactory.getLogger(CommentHook.class);
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.april.hebdobot.bot.hooks.Hook#attemptHelp(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public StringList attemptHelp(final String token) throws HebdobotException
|
||||
{
|
||||
StringList result;
|
||||
|
||||
if (StringsUtils.equalsAnyIgnoreCase(token, "%"))
|
||||
{
|
||||
result = new StringList("% message : traiter le message comme un commentaire (ignoré dans la synthèse de la revue)");
|
||||
}
|
||||
else
|
||||
{
|
||||
result = null;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/* (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)
|
||||
*/
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2018-2019 Christian Pierre MOMON <cmomon@april.org>
|
||||
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||
*
|
||||
* This file is part of (April) Hebdobot.
|
||||
*
|
||||
|
@ -19,6 +19,7 @@
|
|||
package org.april.hebdobot.bot.hooks;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.april.hebdobot.HebdobotException;
|
||||
import org.april.hebdobot.bot.Hebdobot;
|
||||
import org.april.hebdobot.bot.review.CollectiveTopic;
|
||||
import org.april.hebdobot.bot.review.IndividualTopic;
|
||||
|
@ -26,6 +27,9 @@ import org.april.hebdobot.bot.review.Topic;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import fr.devinsy.strings.StringList;
|
||||
import fr.devinsy.strings.StringsUtils;
|
||||
|
||||
/**
|
||||
* The Class CurrentHook.
|
||||
*/
|
||||
|
@ -33,6 +37,27 @@ public class CurrentHook extends Hook
|
|||
{
|
||||
private static final Logger logger = LoggerFactory.getLogger(CurrentHook.class);
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.april.hebdobot.bot.hooks.Hook#attemptHelp(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public StringList attemptHelp(final String token) throws HebdobotException
|
||||
{
|
||||
StringList result;
|
||||
|
||||
if (StringsUtils.equalsAnyIgnoreCase(token, "courant"))
|
||||
{
|
||||
result = new StringList("!courant : afficher le sujet en cours");
|
||||
}
|
||||
else
|
||||
{
|
||||
result = null;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/* (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)
|
||||
*/
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2018 Christian Pierre MOMON <cmomon@april.org>
|
||||
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||
*
|
||||
* This file is part of (April) Hebdobot.
|
||||
*
|
||||
|
@ -23,10 +23,14 @@ import java.time.format.DateTimeFormatter;
|
|||
import java.util.Locale;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.april.hebdobot.HebdobotException;
|
||||
import org.april.hebdobot.bot.Hebdobot;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import fr.devinsy.strings.StringList;
|
||||
import fr.devinsy.strings.StringsUtils;
|
||||
|
||||
/**
|
||||
* The Class DateHook.
|
||||
*/
|
||||
|
@ -34,6 +38,27 @@ public class DateHook extends Hook
|
|||
{
|
||||
private static final Logger logger = LoggerFactory.getLogger(DateHook.class);
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.april.hebdobot.bot.hooks.Hook#attemptHelp(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public StringList attemptHelp(final String token) throws HebdobotException
|
||||
{
|
||||
StringList result;
|
||||
|
||||
if (StringsUtils.equalsAnyIgnoreCase(token, "date", "time", "now"))
|
||||
{
|
||||
result = new StringList("!date, !time, !now : afficher la date et l'heure");
|
||||
}
|
||||
else
|
||||
{
|
||||
result = null;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/* (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)
|
||||
*/
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2018 Christian Pierre MOMON <cmomon@april.org>
|
||||
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||
*
|
||||
* This file is part of (April) Hebdobot.
|
||||
*
|
||||
|
@ -18,10 +18,13 @@
|
|||
*/
|
||||
package org.april.hebdobot.bot.hooks;
|
||||
|
||||
import org.april.hebdobot.HebdobotException;
|
||||
import org.april.hebdobot.bot.Hebdobot;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import fr.devinsy.strings.StringList;
|
||||
|
||||
/**
|
||||
* The Class DefaultHook.
|
||||
*/
|
||||
|
@ -29,6 +32,20 @@ public class DefaultHook extends Hook
|
|||
{
|
||||
private static final Logger logger = LoggerFactory.getLogger(DefaultHook.class);
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.april.hebdobot.bot.hooks.Hook#attemptHelp(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public StringList attemptHelp(final String token) throws HebdobotException
|
||||
{
|
||||
StringList result;
|
||||
|
||||
result = null;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/* (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)
|
||||
*/
|
||||
|
|
|
@ -27,6 +27,7 @@ import java.time.format.DateTimeFormatter;
|
|||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.april.hebdobot.HebdobotException;
|
||||
import org.april.hebdobot.bot.Hebdobot;
|
||||
import org.april.hebdobot.bot.review.ReviewReporter;
|
||||
import org.april.hebdobot.bot.stats.ReviewData;
|
||||
|
@ -37,6 +38,9 @@ import org.april.hebdobot.privatebin.PrivatebinClient;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import fr.devinsy.strings.StringList;
|
||||
import fr.devinsy.strings.StringsUtils;
|
||||
|
||||
/**
|
||||
* The Class FinishReviewHook.
|
||||
*/
|
||||
|
@ -46,6 +50,27 @@ public class FinishReviewHook extends Hook
|
|||
|
||||
public static String DEFAULT_SUFFIX = "-log-irc-revue-hebdomadaire.txt";
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.april.hebdobot.bot.hooks.Hook#attemptHelp(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public StringList attemptHelp(final String token) throws HebdobotException
|
||||
{
|
||||
StringList result;
|
||||
|
||||
if (StringsUtils.equalsAnyIgnoreCase(token, "fin"))
|
||||
{
|
||||
result = new StringList("!fin : terminer la revue en cours");
|
||||
}
|
||||
else
|
||||
{
|
||||
result = null;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/* (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)
|
||||
*/
|
||||
|
@ -80,9 +105,8 @@ public class FinishReviewHook extends Hook
|
|||
else
|
||||
{
|
||||
// End the review.
|
||||
bot.getReview().endReview();
|
||||
|
||||
bot.sendMessage("%% +%01d:%02d", bot.getTimekeeper().format());
|
||||
bot.sendChronoMessage();
|
||||
bot.endReview();
|
||||
|
||||
// Load and update review statistics.
|
||||
ReviewDatas datas;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2018 Christian Pierre MOMON <cmomon@april.org>
|
||||
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||
*
|
||||
* This file is part of (April) Hebdobot.
|
||||
*
|
||||
|
@ -19,10 +19,12 @@
|
|||
package org.april.hebdobot.bot.hooks;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.april.hebdobot.HebdobotException;
|
||||
import org.april.hebdobot.bot.Hebdobot;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import fr.devinsy.strings.StringList;
|
||||
import fr.devinsy.strings.StringsUtils;
|
||||
|
||||
/**
|
||||
|
@ -32,6 +34,27 @@ public class HelloHook extends Hook
|
|||
{
|
||||
private static final Logger logger = LoggerFactory.getLogger(HelloHook.class);
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.april.hebdobot.bot.hooks.Hook#attemptHelp(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public StringList attemptHelp(final String token) throws HebdobotException
|
||||
{
|
||||
StringList result;
|
||||
|
||||
if (StringsUtils.equalsAnyIgnoreCase(token, "salut", "bonjour", "hello"))
|
||||
{
|
||||
result = new StringList("!salut, !bonjour, !hello : dire bonjour");
|
||||
}
|
||||
else
|
||||
{
|
||||
result = null;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/* (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)
|
||||
*/
|
||||
|
|
|
@ -1,110 +0,0 @@
|
|||
/**
|
||||
* Copyright (C) 2018 Christian Pierre MOMON <cmomon@april.org>
|
||||
*
|
||||
* This file is part of (April) Hebdobot.
|
||||
*
|
||||
* Hebdobot 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.
|
||||
*
|
||||
* Hebdobot 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 Hebdobot. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
package org.april.hebdobot.bot.hooks;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.april.hebdobot.bot.Hebdobot;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* The Class HelpByCommandHook.
|
||||
*/
|
||||
public class HelpByCommandHook extends Hook
|
||||
{
|
||||
private static final Logger logger = LoggerFactory.getLogger(HelpByCommandHook.class);
|
||||
|
||||
private static final Pattern PATTERN = Pattern.compile("^!help\\s+(\\S+)$");
|
||||
|
||||
/* (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;
|
||||
|
||||
Matcher matcher = PATTERN.matcher(message);
|
||||
|
||||
if (matcher.find())
|
||||
{
|
||||
String command = matcher.group(1);
|
||||
|
||||
if (StringUtils.equals(command, "help"))
|
||||
{
|
||||
bot.sendMessage(sender + ": help display help commands");
|
||||
bot.sendMessage(sender + ": help command display help on specific command");
|
||||
}
|
||||
else if (StringUtils.equals(command, "ignore"))
|
||||
{
|
||||
bot.sendMessage(sender + ": ignore host:service ignore a specific probe");
|
||||
bot.sendMessage(sender + ": ignore list ignore probes");
|
||||
}
|
||||
else if (StringUtils.equals(command, "unignore"))
|
||||
{
|
||||
bot.sendMessage(sender + ": unignore host:service ignore a specific probe");
|
||||
}
|
||||
else if (StringUtils.equals(command, "ack"))
|
||||
{
|
||||
bot.sendMessage(sender + ": ack unack an alert");
|
||||
}
|
||||
else if (StringUtils.equals(command, "unack"))
|
||||
{
|
||||
bot.sendMessage(sender + ": unack unack an alert");
|
||||
}
|
||||
else if (StringUtils.equalsAnyIgnoreCase(command, "!mute", "!tagueule", "!ta gueule", "!chut", "!sieste"))
|
||||
{
|
||||
bot.sendMessage(sender + ": mute|tagueule|chut|sieste mute alert display");
|
||||
}
|
||||
else if (StringUtils.equalsAnyIgnoreCase(command, "!unmute"))
|
||||
{
|
||||
bot.sendMessage(sender + ": unmute mute alert display");
|
||||
}
|
||||
else if (StringUtils.equals(command, "list"))
|
||||
{
|
||||
bot.sendMessage(sender + ": list display current alerts");
|
||||
}
|
||||
else if (StringUtils.equals(command, "refresh"))
|
||||
{
|
||||
bot.sendMessage(sender + ": refresh update alert list");
|
||||
}
|
||||
else if (StringUtils.equals(command, "recheck"))
|
||||
{
|
||||
bot.sendMessage(sender + ": recheck reschedule current alerts");
|
||||
}
|
||||
else
|
||||
{
|
||||
bot.sendMessage(sender + ": no help available for this command");
|
||||
}
|
||||
|
||||
result = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -18,24 +18,56 @@
|
|||
*/
|
||||
package org.april.hebdobot.bot.hooks;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.april.hebdobot.HebdobotException;
|
||||
import org.april.hebdobot.bot.Hebdobot;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import fr.devinsy.strings.StringList;
|
||||
import fr.devinsy.strings.StringsUtils;
|
||||
|
||||
/**
|
||||
* The Class HelpHook.
|
||||
*/
|
||||
public class HelpHook extends Hook
|
||||
{
|
||||
private static final Pattern COMMAND_HELP_PATTERN = Pattern.compile("^!(aide|help)\\s+(?<token>\\S+)$");
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(HelpHook.class);
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.april.hebdobot.bot.hooks.Hook#attemptHelp(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public StringList attemptHelp(final String token) throws HebdobotException
|
||||
{
|
||||
StringList result;
|
||||
|
||||
if (StringsUtils.equalsAnyIgnoreCase(token, "aide", "help"))
|
||||
{
|
||||
result = new StringList();
|
||||
result.append("!aide, !help : afficher l'aide générale");
|
||||
result.append("!aide foo, !help foo : afficher l'aide de la commande foo");
|
||||
}
|
||||
else
|
||||
{
|
||||
result = null;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/* (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)
|
||||
final String message) throws HebdobotException
|
||||
{
|
||||
boolean result;
|
||||
|
||||
|
@ -44,34 +76,82 @@ public class HelpHook extends Hook
|
|||
logger.info("!help caught.");
|
||||
|
||||
// Help.
|
||||
bot.sendMessage(sender, "Bienvenue " + sender);
|
||||
bot.sendMessage(sender, "Je suis " + bot.getName() + ", le robot de gestion des revues hebdomadaires de l'April.");
|
||||
bot.sendMessage(sender,
|
||||
String.format("Bienvenue %s. Je suis %s, le robot de gestion des revues hebdomadaires de l'April.", sender, bot.getName()));
|
||||
bot.sendMessage(sender, "Voici les commandes que je comprends :");
|
||||
bot.sendMessage(sender, " ");
|
||||
bot.sendMessage(sender, " !aide,!help : afficher cette aide");
|
||||
bot.sendMessage(sender, " !aide foo : afficher l'aide de la comande foo");
|
||||
bot.sendMessage(sender, " !début : commencer une nouvelle revue");
|
||||
bot.sendMessage(sender, " % message : traiter comme un commentaire");
|
||||
bot.sendMessage(sender, " # titre : démarrer un sujet individuel");
|
||||
bot.sendMessage(sender, " ## titre : démarrer un sujet collectif");
|
||||
bot.sendMessage(sender, " % message : traiter comme un commentaire");
|
||||
bot.sendMessage(sender, " !oups : annuler la dernière entrée dans un point de revue");
|
||||
bot.sendMessage(sender, " !courant : afficher le sujet en cours");
|
||||
bot.sendMessage(sender, " !manquants : afficher qui n'a pas participé sur le dernier sujet");
|
||||
bot.sendMessage(sender, " !fin : terminer la revue en cours");
|
||||
bot.sendMessage(sender, " !stop : abandonner la revue en cours");
|
||||
bot.sendMessage(sender, " !licence : afficher la licence du logiciel Hebdobot et le lien vers ses sources");
|
||||
bot.sendMessage(sender, " !record : affiche le record de participation à la revue");
|
||||
bot.sendMessage(sender, " !stats : statistiques sur les précédentes revues");
|
||||
bot.sendMessage(sender, " !version : afficher la version d'Hebdobot");
|
||||
bot.sendMessage(sender, " ");
|
||||
bot.sendMessage(sender, "Autres commandes de dialogue : !bonjour, !date, !hello, !merci, !salut");
|
||||
bot.sendMessage(sender, "Autres commandes : !bonjour, !date, !hello, !licence, !manquants, !merci, !record, !salut, !stats, !version");
|
||||
|
||||
result = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = false;
|
||||
String token = extractTargetHelp(message);
|
||||
|
||||
if (token == null)
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
StringList help = bot.getHelp(token);
|
||||
if (help == null)
|
||||
{
|
||||
bot.sendMessage("aide indisponible pour la commande " + token);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (String line : help)
|
||||
{
|
||||
bot.sendMessage(line);
|
||||
}
|
||||
}
|
||||
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract target help.
|
||||
*
|
||||
* @return the string
|
||||
*/
|
||||
private String extractTargetHelp(final String message)
|
||||
{
|
||||
String result;
|
||||
|
||||
Matcher matcher = COMMAND_HELP_PATTERN.matcher(message);
|
||||
if (matcher.find())
|
||||
{
|
||||
result = matcher.group("token");
|
||||
|
||||
if (StringUtils.startsWith(result, "!"))
|
||||
{
|
||||
result = result.substring(1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result = null;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2018 Christian Pierre MOMON <cmomon@april.org>
|
||||
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||
*
|
||||
* This file is part of (April) Hebdobot.
|
||||
*
|
||||
|
@ -21,11 +21,25 @@ package org.april.hebdobot.bot.hooks;
|
|||
import org.april.hebdobot.HebdobotException;
|
||||
import org.april.hebdobot.bot.Hebdobot;
|
||||
|
||||
import fr.devinsy.strings.StringList;
|
||||
|
||||
/**
|
||||
* The Class Hook.
|
||||
*/
|
||||
public abstract class Hook
|
||||
{
|
||||
/**
|
||||
* Attempt help.
|
||||
*
|
||||
* @param bot
|
||||
* the bot
|
||||
* @param message
|
||||
* the message
|
||||
* @return true, if successful
|
||||
* @throws HebdobotException
|
||||
* the hebdobot exception
|
||||
*/
|
||||
public abstract StringList attemptHelp(final String string) throws HebdobotException;
|
||||
|
||||
/**
|
||||
* Attempt process.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2018-2019 Christian Pierre MOMON <cmomon@april.org>
|
||||
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||
*
|
||||
* This file is part of (April) Hebdobot.
|
||||
*
|
||||
|
@ -29,18 +29,18 @@ import org.slf4j.LoggerFactory;
|
|||
import fr.devinsy.strings.StringList;
|
||||
|
||||
/**
|
||||
* The Interface MessageHook.
|
||||
* The class Hooker, a hook manager.
|
||||
*/
|
||||
public class HookManager
|
||||
public class Hooker
|
||||
{
|
||||
private static final Logger logger = LoggerFactory.getLogger(HookManager.class);
|
||||
private static final Logger logger = LoggerFactory.getLogger(Hooker.class);
|
||||
|
||||
private ArrayList<Hook> hooks;
|
||||
|
||||
/**
|
||||
* Instantiates a new hook manager.
|
||||
*/
|
||||
public HookManager()
|
||||
public Hooker()
|
||||
{
|
||||
this.hooks = new ArrayList<>(30);
|
||||
}
|
||||
|
@ -59,6 +59,48 @@ public class HookManager
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt help.
|
||||
*
|
||||
* @param bot
|
||||
* the bot
|
||||
* @param message
|
||||
* the message
|
||||
* @return true, if successful
|
||||
* @throws HebdobotException
|
||||
* the hebdobot exception
|
||||
*/
|
||||
public StringList attemptHelp(final String message) throws HebdobotException
|
||||
{
|
||||
StringList result;
|
||||
|
||||
boolean ended = false;
|
||||
Iterator<Hook> iterator = this.hooks.iterator();
|
||||
result = null;
|
||||
while (!ended)
|
||||
{
|
||||
if (iterator.hasNext())
|
||||
{
|
||||
Hook hook = iterator.next();
|
||||
StringList help = hook.attemptHelp(message);
|
||||
|
||||
if (help != null)
|
||||
{
|
||||
ended = true;
|
||||
result = help;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ended = true;
|
||||
result = null;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt process.
|
||||
*
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2018 Christian Pierre MOMON <cmomon@april.org>
|
||||
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||
*
|
||||
* This file is part of (April) Hebdobot.
|
||||
*
|
||||
|
@ -19,11 +19,15 @@
|
|||
package org.april.hebdobot.bot.hooks;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.april.hebdobot.HebdobotException;
|
||||
import org.april.hebdobot.bot.Hebdobot;
|
||||
import org.april.hebdobot.bot.review.IndividualTopic;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import fr.devinsy.strings.StringList;
|
||||
import fr.devinsy.strings.StringsUtils;
|
||||
|
||||
/**
|
||||
* The Class IndividualSubjectHook.
|
||||
*/
|
||||
|
@ -31,6 +35,27 @@ public class IndividualSubjectHook extends Hook
|
|||
{
|
||||
private static final Logger logger = LoggerFactory.getLogger(IndividualSubjectHook.class);
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.april.hebdobot.bot.hooks.Hook#attemptHelp(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public StringList attemptHelp(final String token) throws HebdobotException
|
||||
{
|
||||
StringList result;
|
||||
|
||||
if (StringsUtils.equalsAnyIgnoreCase(token, "#"))
|
||||
{
|
||||
result = new StringList("# titre : démarrer un sujet individuel");
|
||||
}
|
||||
else
|
||||
{
|
||||
result = null;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/* (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)
|
||||
*/
|
||||
|
@ -52,15 +77,16 @@ public class IndividualSubjectHook extends Hook
|
|||
IndividualTopic topic = new IndividualTopic(message.replaceFirst("#", "").trim());
|
||||
if (!bot.getReview().isEmpty())
|
||||
{
|
||||
bot.sendChronoMessage();
|
||||
|
||||
String participants = StringUtils.join(bot.getReview().getParticipants(), " ");
|
||||
bot.sendMessage(String.format("%% %s %s, on va passer à la suite : %s", bot.getTimekeeper().format(), participants,
|
||||
topic.getTitle()));
|
||||
bot.sendMessage(String.format("%% %s, on va passer à la suite : %s", participants, topic.getTitle()));
|
||||
}
|
||||
bot.getReview().begin(topic);
|
||||
bot.sendMessage("Sujet individuel : " + topic.getTitle());
|
||||
bot.sendMessage("% si rien à signaler vous pouvez écrire % ras");
|
||||
bot.sendMessage("% quand vous avez fini vous le dites par % fini");
|
||||
bot.getTimekeeper().start();
|
||||
bot.getChrono().start();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2018 Christian Pierre MOMON <cmomon@april.org>
|
||||
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||
*
|
||||
* This file is part of (April) Hebdobot.
|
||||
*
|
||||
|
@ -18,11 +18,14 @@
|
|||
*/
|
||||
package org.april.hebdobot.bot.hooks;
|
||||
|
||||
import org.april.hebdobot.HebdobotException;
|
||||
import org.april.hebdobot.bot.Hebdobot;
|
||||
import org.april.hebdobot.bot.review.Message;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import fr.devinsy.strings.StringList;
|
||||
|
||||
/**
|
||||
* The Class DefaultHook.
|
||||
*/
|
||||
|
@ -30,6 +33,20 @@ public class InputReviewHook extends Hook
|
|||
{
|
||||
private static final Logger logger = LoggerFactory.getLogger(InputReviewHook.class);
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.april.hebdobot.bot.hooks.Hook#attemptHelp(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public StringList attemptHelp(final String token) throws HebdobotException
|
||||
{
|
||||
StringList result;
|
||||
|
||||
result = null;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/* (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)
|
||||
*/
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2018 Christian Pierre MOMON <cmomon@april.org>
|
||||
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||
*
|
||||
* This file is part of (April) Hebdobot.
|
||||
*
|
||||
|
@ -18,10 +18,12 @@
|
|||
*/
|
||||
package org.april.hebdobot.bot.hooks;
|
||||
|
||||
import org.april.hebdobot.HebdobotException;
|
||||
import org.april.hebdobot.bot.Hebdobot;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import fr.devinsy.strings.StringList;
|
||||
import fr.devinsy.strings.StringsUtils;
|
||||
|
||||
/**
|
||||
|
@ -31,6 +33,27 @@ public class LicenseHook extends Hook
|
|||
{
|
||||
private static final Logger logger = LoggerFactory.getLogger(LicenseHook.class);
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.april.hebdobot.bot.hooks.Hook#attemptHelp(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public StringList attemptHelp(final String token) throws HebdobotException
|
||||
{
|
||||
StringList result;
|
||||
|
||||
if (StringsUtils.equalsAnyIgnoreCase(token, "licence", "license"))
|
||||
{
|
||||
result = new StringList("!licence, !license : afficher la licence du logiciel Hebdobot et le lien vers ses sources");
|
||||
}
|
||||
else
|
||||
{
|
||||
result = null;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/* (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)
|
||||
*/
|
||||
|
@ -44,8 +67,7 @@ public class LicenseHook extends Hook
|
|||
{
|
||||
logger.info("!licence caught.");
|
||||
|
||||
bot.sendMessage(sender
|
||||
+ ", Hebdobot est un logiciel libre de l'April sous licence GNU AGPL (sources : https://forge.april.org/adminsys/hebdobot).");
|
||||
bot.sendMessage("Hebdobot est un logiciel libre de l'April sous licence GNU AGPL, sources : https://forge.april.org/adminsys/hebdobot");
|
||||
|
||||
result = true;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2018-2019 Christian Pierre MOMON <cmomon@april.org>
|
||||
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||
*
|
||||
* This file is part of (April) Hebdobot.
|
||||
*
|
||||
|
@ -22,12 +22,15 @@ import java.util.Collection;
|
|||
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.april.hebdobot.HebdobotException;
|
||||
import org.april.hebdobot.bot.Hebdobot;
|
||||
import org.april.hebdobot.bot.review.Topic;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import fr.devinsy.strings.StringList;
|
||||
import fr.devinsy.strings.StringSet;
|
||||
import fr.devinsy.strings.StringsUtils;
|
||||
|
||||
/**
|
||||
* The Class MissingHook.
|
||||
|
@ -36,6 +39,27 @@ public class MissingHook extends Hook
|
|||
{
|
||||
private static final Logger logger = LoggerFactory.getLogger(MissingHook.class);
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.april.hebdobot.bot.hooks.Hook#attemptHelp(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public StringList attemptHelp(final String token) throws HebdobotException
|
||||
{
|
||||
StringList result;
|
||||
|
||||
if (StringsUtils.equalsAnyIgnoreCase(token, "manquants"))
|
||||
{
|
||||
result = new StringList("!manquants : afficher les pseudos n'ayant pas participé au point en cours");
|
||||
}
|
||||
else
|
||||
{
|
||||
result = null;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/* (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)
|
||||
*/
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2018 Christian Pierre MOMON <cmomon@april.org>
|
||||
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||
*
|
||||
* This file is part of (April) Hebdobot.
|
||||
*
|
||||
|
@ -20,6 +20,7 @@ package org.april.hebdobot.bot.hooks;
|
|||
|
||||
import java.io.File;
|
||||
|
||||
import org.april.hebdobot.HebdobotException;
|
||||
import org.april.hebdobot.bot.Hebdobot;
|
||||
import org.april.hebdobot.bot.stats.ReviewDatas;
|
||||
import org.april.hebdobot.bot.stats.ReviewDatasFile;
|
||||
|
@ -27,6 +28,9 @@ import org.april.hebdobot.bot.stats.ReviewStatsReporter;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import fr.devinsy.strings.StringList;
|
||||
import fr.devinsy.strings.StringsUtils;
|
||||
|
||||
/**
|
||||
* The Class RecordHook.
|
||||
*/
|
||||
|
@ -34,6 +38,27 @@ public class RecordHook extends Hook
|
|||
{
|
||||
private static final Logger logger = LoggerFactory.getLogger(RecordHook.class);
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.april.hebdobot.bot.hooks.Hook#attemptHelp(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public StringList attemptHelp(final String token) throws HebdobotException
|
||||
{
|
||||
StringList result;
|
||||
|
||||
if (StringsUtils.equalsAnyIgnoreCase(token, "record"))
|
||||
{
|
||||
result = new StringList("!record : afficher le record de participation à la revue");
|
||||
}
|
||||
else
|
||||
{
|
||||
result = null;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/* (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)
|
||||
*/
|
||||
|
@ -55,7 +80,7 @@ public class RecordHook extends Hook
|
|||
{
|
||||
ReviewDatas datas = ReviewDatasFile.load(reviewDataFile);
|
||||
datas.clean();
|
||||
bot.sendMessage("% " + ReviewStatsReporter.reportUserCountRecord(datas));
|
||||
bot.sendMessage(ReviewStatsReporter.reportUserCountRecord(datas));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -21,12 +21,16 @@ package org.april.hebdobot.bot.hooks;
|
|||
import java.time.LocalTime;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.april.hebdobot.HebdobotException;
|
||||
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;
|
||||
|
||||
import fr.devinsy.strings.StringList;
|
||||
import fr.devinsy.strings.StringsUtils;
|
||||
|
||||
/**
|
||||
* The Class StartReviewHook.
|
||||
*/
|
||||
|
@ -34,6 +38,27 @@ public class StartReviewHook extends Hook
|
|||
{
|
||||
private static final Logger logger = LoggerFactory.getLogger(StartReviewHook.class);
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.april.hebdobot.bot.hooks.Hook#attemptHelp(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public StringList attemptHelp(final String token) throws HebdobotException
|
||||
{
|
||||
StringList result;
|
||||
|
||||
if (StringsUtils.equalsAnyIgnoreCase(token, "début", "debut", "start"))
|
||||
{
|
||||
result = new StringList("!début, !debut, !start : commencer une nouvelle revue");
|
||||
}
|
||||
else
|
||||
{
|
||||
result = null;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/* (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)
|
||||
*/
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2018 Christian Pierre MOMON <cmomon@april.org>
|
||||
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||
*
|
||||
* This file is part of (April) Hebdobot.
|
||||
*
|
||||
|
@ -20,6 +20,7 @@ package org.april.hebdobot.bot.hooks;
|
|||
|
||||
import java.io.File;
|
||||
|
||||
import org.april.hebdobot.HebdobotException;
|
||||
import org.april.hebdobot.bot.Hebdobot;
|
||||
import org.april.hebdobot.bot.stats.ReviewDatas;
|
||||
import org.april.hebdobot.bot.stats.ReviewDatasFile;
|
||||
|
@ -27,6 +28,9 @@ import org.april.hebdobot.bot.stats.ReviewStatsReporter;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import fr.devinsy.strings.StringList;
|
||||
import fr.devinsy.strings.StringsUtils;
|
||||
|
||||
/**
|
||||
* The Class StatsHook.
|
||||
*/
|
||||
|
@ -34,6 +38,27 @@ public class StatsHook extends Hook
|
|||
{
|
||||
private static final Logger logger = LoggerFactory.getLogger(StatsHook.class);
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.april.hebdobot.bot.hooks.Hook#attemptHelp(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public StringList attemptHelp(final String token) throws HebdobotException
|
||||
{
|
||||
StringList result;
|
||||
|
||||
if (StringsUtils.equalsAnyIgnoreCase(token, "stats"))
|
||||
{
|
||||
result = new StringList("!stats : statistiques sur les précédentes revues");
|
||||
}
|
||||
else
|
||||
{
|
||||
result = null;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/* (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)
|
||||
*/
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2018 Christian Pierre MOMON <cmomon@april.org>
|
||||
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||
*
|
||||
* This file is part of (April) Hebdobot.
|
||||
*
|
||||
|
@ -19,10 +19,14 @@
|
|||
package org.april.hebdobot.bot.hooks;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.april.hebdobot.HebdobotException;
|
||||
import org.april.hebdobot.bot.Hebdobot;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import fr.devinsy.strings.StringList;
|
||||
import fr.devinsy.strings.StringsUtils;
|
||||
|
||||
/**
|
||||
* The Class StatusHook.
|
||||
*/
|
||||
|
@ -30,6 +34,27 @@ public class StatusHook extends Hook
|
|||
{
|
||||
private static final Logger logger = LoggerFactory.getLogger(StatusHook.class);
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.april.hebdobot.bot.hooks.Hook#attemptHelp(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public StringList attemptHelp(final String token) throws HebdobotException
|
||||
{
|
||||
StringList result;
|
||||
|
||||
if (StringsUtils.equalsAnyIgnoreCase(token, "status", "statut"))
|
||||
{
|
||||
result = new StringList("!status, !statut : état et paramétrage d'Hebdobot");
|
||||
}
|
||||
else
|
||||
{
|
||||
result = null;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/* (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)
|
||||
*/
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2018-2019 Christian Pierre MOMON <cmomon@april.org>
|
||||
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||
*
|
||||
* This file is part of (April) Hebdobot.
|
||||
*
|
||||
|
@ -19,10 +19,14 @@
|
|||
package org.april.hebdobot.bot.hooks;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.april.hebdobot.HebdobotException;
|
||||
import org.april.hebdobot.bot.Hebdobot;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import fr.devinsy.strings.StringList;
|
||||
import fr.devinsy.strings.StringsUtils;
|
||||
|
||||
/**
|
||||
* The Class StopReviewHook.
|
||||
*/
|
||||
|
@ -30,6 +34,27 @@ public class StopReviewHook extends Hook
|
|||
{
|
||||
private static final Logger logger = LoggerFactory.getLogger(StopReviewHook.class);
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.april.hebdobot.bot.hooks.Hook#attemptHelp(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public StringList attemptHelp(final String token) throws HebdobotException
|
||||
{
|
||||
StringList result;
|
||||
|
||||
if (StringsUtils.equalsAnyIgnoreCase(token, "stop"))
|
||||
{
|
||||
result = new StringList("!stop : abandonner la revue en cours");
|
||||
}
|
||||
else
|
||||
{
|
||||
result = null;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/* (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)
|
||||
*/
|
||||
|
@ -55,7 +80,7 @@ public class StopReviewHook extends Hook
|
|||
else
|
||||
{
|
||||
bot.sendMessage("Abandon de la revue en cours.");
|
||||
bot.setReview(null);
|
||||
bot.stopReview();
|
||||
}
|
||||
|
||||
result = true;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2018 Christian Pierre MOMON <cmomon@april.org>
|
||||
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||
*
|
||||
* This file is part of (April) Hebdobot.
|
||||
*
|
||||
|
@ -19,10 +19,12 @@
|
|||
package org.april.hebdobot.bot.hooks;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.april.hebdobot.HebdobotException;
|
||||
import org.april.hebdobot.bot.Hebdobot;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import fr.devinsy.strings.StringList;
|
||||
import fr.devinsy.strings.StringsUtils;
|
||||
|
||||
/**
|
||||
|
@ -32,6 +34,27 @@ public class ThanksHook extends Hook
|
|||
{
|
||||
private static final Logger logger = LoggerFactory.getLogger(ThanksHook.class);
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.april.hebdobot.bot.hooks.Hook#attemptHelp(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public StringList attemptHelp(final String token) throws HebdobotException
|
||||
{
|
||||
StringList result;
|
||||
|
||||
if (StringsUtils.equalsAnyIgnoreCase(token, "merci"))
|
||||
{
|
||||
result = new StringList("!merci : dire que ça fait plaisir");
|
||||
}
|
||||
else
|
||||
{
|
||||
result = null;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/* (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)
|
||||
*/
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2018 Christian Pierre MOMON <cmomon@april.org>
|
||||
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||
*
|
||||
* This file is part of (April) Hebdobot.
|
||||
*
|
||||
|
@ -18,11 +18,15 @@
|
|||
*/
|
||||
package org.april.hebdobot.bot.hooks;
|
||||
|
||||
import org.april.hebdobot.HebdobotException;
|
||||
import org.april.hebdobot.bot.Hebdobot;
|
||||
import org.april.hebdobot.util.BuildInformation;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import fr.devinsy.strings.StringList;
|
||||
import fr.devinsy.strings.StringsUtils;
|
||||
|
||||
/**
|
||||
* The Class VersionHook.
|
||||
*/
|
||||
|
@ -30,6 +34,27 @@ public class VersionHook extends Hook
|
|||
{
|
||||
private static final Logger logger = LoggerFactory.getLogger(VersionHook.class);
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.april.hebdobot.bot.hooks.Hook#attemptHelp(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public StringList attemptHelp(final String token) throws HebdobotException
|
||||
{
|
||||
StringList result;
|
||||
|
||||
if (StringsUtils.equalsAnyIgnoreCase(token, "version"))
|
||||
{
|
||||
result = new StringList("!version : afficher la version d'Hebdobot");
|
||||
}
|
||||
else
|
||||
{
|
||||
result = null;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/* (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)
|
||||
*/
|
||||
|
|
|
@ -282,7 +282,7 @@ public class ReviewReporter
|
|||
//
|
||||
addLine(buffer, '=');
|
||||
addEmpty(buffer);
|
||||
addCenter(buffer, "Participants", '-');
|
||||
addCenter(buffer, "Personnes participantes", '-');
|
||||
for (final String participant : review.getParticipants())
|
||||
{
|
||||
addChunk(buffer, "* " + review.getAliases().getRealName(participant));
|
||||
|
|
|
@ -22,18 +22,18 @@ import java.time.Duration;
|
|||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* The Class TimeKeeper.
|
||||
* The Class Chrono.
|
||||
*/
|
||||
public class Timekeeper
|
||||
public class Chrono
|
||||
{
|
||||
private LocalDateTime start;
|
||||
|
||||
/**
|
||||
* Instantiates a new time keeper.
|
||||
*/
|
||||
public Timekeeper()
|
||||
public Chrono()
|
||||
{
|
||||
this.start = null;
|
||||
reset();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -61,6 +61,14 @@ public class Timekeeper
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset.
|
||||
*/
|
||||
public void reset()
|
||||
{
|
||||
this.start = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Start.
|
||||
*/
|
||||
|
@ -68,4 +76,20 @@ public class Timekeeper
|
|||
{
|
||||
this.start = LocalDateTime.now();
|
||||
}
|
||||
|
||||
/**
|
||||
* To string.
|
||||
*
|
||||
* @return the string
|
||||
*/
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
String result;
|
||||
|
||||
result = format();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue