Improved !help feature.
This commit is contained in:
parent
54669590ab
commit
d709328666
@ -38,7 +38,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;
|
||||
@ -66,6 +66,7 @@ import org.quartz.SchedulerException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import fr.devinsy.strings.StringList;
|
||||
import twitter4j.TwitterException;
|
||||
|
||||
/**
|
||||
@ -92,7 +93,7 @@ public class Hebdobot extends PircBot
|
||||
private CronSettings cronSettings;
|
||||
private UserAliases aliases;
|
||||
private CronManager cronManager;
|
||||
private HookManager hooker;
|
||||
private Hooker hooker;
|
||||
|
||||
/**
|
||||
* Instantiates a new hebdobot.
|
||||
@ -139,7 +140,7 @@ public class Hebdobot extends PircBot
|
||||
this.cronManager = null;
|
||||
|
||||
//
|
||||
this.hooker = new HookManager();
|
||||
this.hooker = new Hooker();
|
||||
|
||||
this.hooker.add(new CollectiveSubjectHook());
|
||||
this.hooker.add(new CommentHook());
|
||||
@ -236,6 +237,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.
|
||||
*
|
||||
|
@ -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,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 ChronoHook.
|
||||
*/
|
||||
@ -30,6 +34,27 @@ public class ChronoHook extends Hook
|
||||
{
|
||||
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)
|
||||
*/
|
||||
|
@ -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)
|
||||
*/
|
||||
|
@ -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)
|
||||
*/
|
||||
|
@ -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;
|
||||
|
||||
@ -49,29 +81,77 @@ public class HelpHook extends Hook
|
||||
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.
|
||||
*
|
@ -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)
|
||||
*/
|
||||
|
@ -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)
|
||||
*/
|
||||
|
@ -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)
|
||||
*/
|
||||
|
@ -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)
|
||||
*/
|
||||
|
@ -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)
|
||||
*/
|
||||
|
@ -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)
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user