Compare commits
No commits in common. "Hebdobot-v2" and "2.11.0" have entirely different histories.
Hebdobot-v
...
2.11.0
2
CHANGES
2
CHANGES
@ -1,6 +1,6 @@
|
||||
|
||||
|
||||
* Changed license from GNU GPL v3 to GNU AGPL v3+.
|
||||
* Changed license from GNU GPL v3 to GNU AGPL v3.
|
||||
|
||||
Le 08/01/2018 à 01:07, aeris a écrit :
|
||||
> From: aeris <aeris@imirhil.fr>
|
||||
|
22
README.md
22
README.md
@ -6,7 +6,7 @@ Présentation de la revue hebdomadaire : https://www.april.org/revues-hebdomadai
|
||||
|
||||
La revue hebdo dispose d'un bot IRC qui gère les logs et la synthèse de la revue hebdo : Hebdobot.
|
||||
|
||||
Hebdobot est un logiciel libre sous licence GNU AGPLv3+ édité par l'April dont le projet est géré ici : https://agir.april.org/projects/hebdobot.
|
||||
Hebdobot est un logiciel libre sous licence GNU AGPL édité par l'April dont le projet est géré ici : https://agir.april.org/projects/hebdobot.
|
||||
|
||||
Résultat de la commande !aide :
|
||||
|
||||
@ -35,23 +35,13 @@ Résultat de la commande !aide :
|
||||
|
||||
À la fin de la revue, une synthèse est accessible via un site de pastes et des statistiques de la revue sont affichées.
|
||||
|
||||
## Build
|
||||
|
||||
### Dépendances
|
||||
|
||||
```bash
|
||||
apt install ant default-jdk
|
||||
```
|
||||
|
||||
### Build
|
||||
|
||||
```bash
|
||||
./build.sh
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
Hebdobot is a free software released on GNU AGPLv3+
|
||||
Hebdobot is a free software released on GNU AGPL 3+
|
||||
|
||||
## History
|
||||
|
||||
TODO
|
||||
|
||||
## Logo
|
||||
|
||||
|
@ -1,3 +1,3 @@
|
||||
#Build Number for ANT. Do not edit!
|
||||
#Fri Dec 31 11:53:11 CET 2021
|
||||
build.number=8
|
||||
#Fri Apr 09 03:19:43 CEST 2021
|
||||
build.number=1
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (C) 2017-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||
* Copyright (C) 2017-2019 Christian Pierre MOMON <cmomon@april.org>
|
||||
* Copyright (C) 2011-2013,2017 Nicolas Vinot <aeris@imirhil.fr>
|
||||
*
|
||||
* This file is part of (April) Hebdobot.
|
||||
@ -22,15 +22,12 @@ package org.april.hebdobot.bot;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.time.LocalDate;
|
||||
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;
|
||||
@ -39,11 +36,10 @@ 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.Hooker;
|
||||
import org.april.hebdobot.bot.hooks.HookManager;
|
||||
import org.april.hebdobot.bot.hooks.IndividualSubjectHook;
|
||||
import org.april.hebdobot.bot.hooks.InputReviewHook;
|
||||
import org.april.hebdobot.bot.hooks.LicenseHook;
|
||||
import org.april.hebdobot.bot.hooks.ListenAlexandrieHook;
|
||||
import org.april.hebdobot.bot.hooks.MissingHook;
|
||||
import org.april.hebdobot.bot.hooks.RecordHook;
|
||||
import org.april.hebdobot.bot.hooks.StartReviewHook;
|
||||
@ -51,6 +47,7 @@ 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;
|
||||
@ -60,7 +57,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.Chrono;
|
||||
import org.april.hebdobot.util.Timekeeper;
|
||||
import org.jibble.pircbot.IrcException;
|
||||
import org.jibble.pircbot.NickAlreadyInUseException;
|
||||
import org.jibble.pircbot.PircBot;
|
||||
@ -68,7 +65,6 @@ import org.quartz.SchedulerException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import fr.devinsy.strings.StringList;
|
||||
import twitter4j.TwitterException;
|
||||
|
||||
/**
|
||||
@ -88,14 +84,14 @@ public class Hebdobot extends PircBot
|
||||
private String reviewFileSuffix;
|
||||
private LocalTime reviewWaitTime;
|
||||
private Review review;
|
||||
private Chrono chrono;
|
||||
private Timekeeper timekeeper;
|
||||
private IdenticaSettings identicaSettings;
|
||||
private PrivatebinSettings privatebinSettings;
|
||||
private TwitterSettings twitterSettings;
|
||||
private CronSettings cronSettings;
|
||||
private UserAliases aliases;
|
||||
private CronManager cronManager;
|
||||
private Hooker hooker;
|
||||
private HookManager hooker;
|
||||
|
||||
/**
|
||||
* Instantiates a new hebdobot.
|
||||
@ -131,7 +127,7 @@ public class Hebdobot extends PircBot
|
||||
this.reviewFileSuffix = null;
|
||||
this.reviewWaitTime = null;
|
||||
this.review = null;
|
||||
this.chrono = new Chrono();
|
||||
this.timekeeper = new Timekeeper();
|
||||
|
||||
this.identicaSettings = new IdenticaSettings();
|
||||
this.privatebinSettings = new PrivatebinSettings();
|
||||
@ -142,11 +138,8 @@ public class Hebdobot extends PircBot
|
||||
this.cronManager = null;
|
||||
|
||||
//
|
||||
this.hooker = new Hooker();
|
||||
this.hooker = new HookManager();
|
||||
|
||||
this.hooker.add(new ListenAlexandrieHook());
|
||||
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());
|
||||
@ -159,8 +152,9 @@ 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 AnnivHook());
|
||||
this.hooker.add(new TimekeeperHook());
|
||||
this.hooker.add(new DateHook());
|
||||
this.hooker.add(new HelloHook());
|
||||
this.hooker.add(new LicenseHook());
|
||||
@ -172,27 +166,6 @@ public class Hebdobot extends PircBot
|
||||
this.hooker.add(new DefaultHook());
|
||||
}
|
||||
|
||||
/**
|
||||
* Check anniversary.
|
||||
*/
|
||||
public void checkReviewAnniversary()
|
||||
{
|
||||
LocalDate now = LocalDate.now();
|
||||
LocalDate creation = LocalDate.of(2010, 04, 30);
|
||||
LocalDate anniv = LocalDate.of(now.getYear(), creation.getMonth(), creation.getDayOfMonth());
|
||||
|
||||
logger.debug("now ={}", now.toString());
|
||||
logger.debug("creation={}", creation.toString());
|
||||
logger.debug("anniv ={}", anniv.toString());
|
||||
|
||||
if ((!now.isBefore(anniv)) && (now.isBefore(anniv.plusDays(7))))
|
||||
{
|
||||
logger.info("Review anniversary detected.");
|
||||
int year = anniv.getYear() - creation.getYear();
|
||||
sendMessage("% \\o/ Joyeux " + year + "e anniversaire la revue hebdo \\o/");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Close.
|
||||
*/
|
||||
@ -202,15 +175,6 @@ public class Hebdobot extends PircBot
|
||||
this.dispose();
|
||||
}
|
||||
|
||||
/**
|
||||
* End review.
|
||||
*/
|
||||
public void endReview()
|
||||
{
|
||||
this.review.endReview();
|
||||
this.chrono.reset();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the aliases.
|
||||
*
|
||||
@ -221,11 +185,6 @@ public class Hebdobot extends PircBot
|
||||
return this.aliases;
|
||||
}
|
||||
|
||||
public Chrono getChrono()
|
||||
{
|
||||
return this.chrono;
|
||||
}
|
||||
|
||||
public CronManager getCronManager()
|
||||
{
|
||||
return this.cronManager;
|
||||
@ -241,32 +200,6 @@ 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.
|
||||
*
|
||||
@ -317,6 +250,11 @@ public class Hebdobot extends PircBot
|
||||
return this.reviewWaitTime;
|
||||
}
|
||||
|
||||
public Timekeeper getTimekeeper()
|
||||
{
|
||||
return this.timekeeper;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the twitter settings.
|
||||
*
|
||||
@ -393,7 +331,7 @@ public class Hebdobot extends PircBot
|
||||
this.review.addRaw(new Message(sender, text));
|
||||
}
|
||||
|
||||
text = text.replaceAll("^" + getName().replace("[", "\\[").replaceAll("]", "\\]") + "[,:]\\s*", "!");
|
||||
text = message.replaceAll("^" + getName().replace("[", "\\[").replaceAll("]", "\\]") + "[,:]\\s*", "!");
|
||||
|
||||
try
|
||||
{
|
||||
@ -417,12 +355,36 @@ public class Hebdobot extends PircBot
|
||||
|
||||
String text = message.trim();
|
||||
|
||||
if (text.startsWith("!"))
|
||||
if (StringUtils.equalsIgnoreCase(text, "!vaten"))
|
||||
{
|
||||
logger.info("!die caught.");
|
||||
|
||||
// Die.
|
||||
if (this.review == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
sendMessage(sender + ", ok bye.");
|
||||
sendMessage(sender, "ok bye.");
|
||||
Thread.sleep(1000);
|
||||
System.exit(0);
|
||||
}
|
||||
catch (InterruptedException exception)
|
||||
{
|
||||
logger.warn("Pause abort: " + exception.getMessage());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sendMessage("% Une revue est en cours, abandon impossible.");
|
||||
}
|
||||
}
|
||||
else if (text.startsWith("!"))
|
||||
{
|
||||
logger.info("!??? caught.");
|
||||
|
||||
// Command unknown.
|
||||
sendMessage(sender, "vos commandes dans le salon public");
|
||||
sendMessage(sender + ", command unknown: " + text);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -438,7 +400,6 @@ public class Hebdobot extends PircBot
|
||||
*/
|
||||
public void run() throws HebdobotException
|
||||
{
|
||||
//
|
||||
try
|
||||
{
|
||||
logger.info("Cron initializing.");
|
||||
@ -447,81 +408,45 @@ public class Hebdobot extends PircBot
|
||||
this.cronManager.start();
|
||||
}
|
||||
logger.info("Cron initialized.");
|
||||
|
||||
logger.info("Bot connection.");
|
||||
this.connect(this.host, this.port);
|
||||
logger.info("Bot connected.");
|
||||
|
||||
if (this.identifyPassword == null)
|
||||
{
|
||||
logger.info("Skipped identify.");
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.info("Apply identify.");
|
||||
sendMessage("NickServ", "identify " + this.identifyNick + " " + this.identifyPassword);
|
||||
logger.info("Applied identify.");
|
||||
}
|
||||
|
||||
logger.info("Bot joining channel ({}).", this.channel);
|
||||
this.joinChannel(this.channel);
|
||||
logger.info("Bot ready.");
|
||||
}
|
||||
catch (SchedulerException | ParseException exception)
|
||||
catch (NickAlreadyInUseException exception)
|
||||
{
|
||||
throw new HebdobotException(exception);
|
||||
}
|
||||
catch (IOException exception)
|
||||
{
|
||||
throw new HebdobotException(exception);
|
||||
}
|
||||
catch (IrcException exception)
|
||||
{
|
||||
throw new HebdobotException(exception);
|
||||
}
|
||||
catch (SchedulerException exception)
|
||||
{
|
||||
throw new HebdobotException("Error in cron settings.", exception);
|
||||
}
|
||||
|
||||
// Manage "Caused by: java.net.UnknownHostException: irc.freenode.org".
|
||||
boolean ended = false;
|
||||
while (!ended)
|
||||
catch (ParseException exception)
|
||||
{
|
||||
try
|
||||
{
|
||||
logger.info("Bot connection.");
|
||||
this.connect(this.host, this.port);
|
||||
logger.info("Bot connected.");
|
||||
ended = true;
|
||||
}
|
||||
catch (NickAlreadyInUseException exception)
|
||||
{
|
||||
throw new HebdobotException(exception);
|
||||
}
|
||||
catch (IOException exception)
|
||||
{
|
||||
logger.error("IOException during connection ", exception);
|
||||
try
|
||||
{
|
||||
Thread.sleep(200000);
|
||||
}
|
||||
catch (InterruptedException subException)
|
||||
{
|
||||
logger.error("Exception during sleep ", subException);
|
||||
}
|
||||
}
|
||||
catch (IrcException exception)
|
||||
{
|
||||
throw new HebdobotException(exception);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
if (this.identifyPassword == null)
|
||||
{
|
||||
logger.info("Skipped identify.");
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.info("Apply identify.");
|
||||
sendMessage("NickServ", "identify " + this.identifyNick + " " + this.identifyPassword);
|
||||
logger.info("Applied identify.");
|
||||
}
|
||||
|
||||
logger.info("Bot joining channel ({}).", this.channel);
|
||||
this.joinChannel(this.channel);
|
||||
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));
|
||||
throw new HebdobotException(exception);
|
||||
}
|
||||
}
|
||||
|
||||
@ -571,13 +496,4 @@ public class Hebdobot extends PircBot
|
||||
{
|
||||
this.reviewWaitTime = reviewWaitTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop review.
|
||||
*/
|
||||
public void stopReview()
|
||||
{
|
||||
setReview(null);
|
||||
this.chrono.reset();
|
||||
}
|
||||
}
|
||||
|
@ -1,103 +0,0 @@
|
||||
/**
|
||||
* 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-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||
* Copyright (C) 2018 Christian Pierre MOMON <cmomon@april.org>
|
||||
*
|
||||
* This file is part of (April) Hebdobot.
|
||||
*
|
||||
@ -18,13 +18,10 @@
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
@ -32,15 +29,6 @@ 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,15 +18,12 @@
|
||||
*/
|
||||
package org.april.hebdobot.bot.hooks;
|
||||
|
||||
import org.april.hebdobot.HebdobotException;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
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;
|
||||
|
||||
/**
|
||||
* The Class CancelPreviousInputHook.
|
||||
*/
|
||||
@ -34,27 +31,6 @@ 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)
|
||||
*/
|
||||
@ -64,9 +40,9 @@ public class CancelPreviousInputHook extends Hook
|
||||
{
|
||||
boolean result;
|
||||
|
||||
if (StringsUtils.equalsAnyIgnoreCase(message, "!cancelprevious", "!oops", "!oups"))
|
||||
if (StringUtils.equalsIgnoreCase(message, "!cancelprevious"))
|
||||
{
|
||||
logger.info("!cancelprevious/!oops caught.");
|
||||
logger.info("!cancelprevious caught.");
|
||||
|
||||
// Missing.
|
||||
if (bot.getReview() == null)
|
||||
@ -82,14 +58,13 @@ public class CancelPreviousInputHook extends Hook
|
||||
}
|
||||
else
|
||||
{
|
||||
String previousMessage = topic.cancelPreviousMessage(sender);
|
||||
if (previousMessage == null)
|
||||
if (bot.getReview().getParticipants().contains(sender))
|
||||
{
|
||||
bot.sendMessage(sender + ", vous n'avez pas d'entrée en cours.");
|
||||
topic.cancelPreviousMessage(sender);
|
||||
}
|
||||
else
|
||||
{
|
||||
bot.sendMessage(sender + ", suppression de votre précédente entrée : " + previousMessage);
|
||||
bot.sendMessage("Vous n'avez pas d'entrée en cours.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,83 +0,0 @@
|
||||
/**
|
||||
* 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 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.
|
||||
*/
|
||||
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)
|
||||
*/
|
||||
@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, "!chrono"))
|
||||
{
|
||||
logger.info("!chrono caught.");
|
||||
// bot.sendChronoMessage();
|
||||
bot.sendMessage(bot.getChrono().format());
|
||||
|
||||
result = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||
* Copyright (C) 2018 Christian Pierre MOMON <cmomon@april.org>
|
||||
*
|
||||
* This file is part of (April) Hebdobot.
|
||||
*
|
||||
@ -19,15 +19,11 @@
|
||||
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.
|
||||
*/
|
||||
@ -35,27 +31,6 @@ 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)
|
||||
*/
|
||||
@ -77,17 +52,16 @@ 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, on va passer à la suite : %s", participants, topic.getTitle()));
|
||||
bot.sendMessage(String.format("%% %s %s, on va passer à la suite : %s", bot.getTimekeeper().format(), 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.getChrono().start();
|
||||
bot.getTimekeeper().start();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||
* Copyright (C) 2018 Christian Pierre MOMON <cmomon@april.org>
|
||||
*
|
||||
* This file is part of (April) Hebdobot.
|
||||
*
|
||||
@ -18,14 +18,10 @@
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
@ -33,27 +29,6 @@ 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-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||
* Copyright (C) 2018-2019 Christian Pierre MOMON <cmomon@april.org>
|
||||
*
|
||||
* This file is part of (April) Hebdobot.
|
||||
*
|
||||
@ -19,7 +19,6 @@
|
||||
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;
|
||||
@ -27,9 +26,6 @@ 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.
|
||||
*/
|
||||
@ -37,27 +33,6 @@ 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-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||
* Copyright (C) 2018 Christian Pierre MOMON <cmomon@april.org>
|
||||
*
|
||||
* This file is part of (April) Hebdobot.
|
||||
*
|
||||
@ -23,14 +23,10 @@ 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.
|
||||
*/
|
||||
@ -38,27 +34,6 @@ 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-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||
* Copyright (C) 2018 Christian Pierre MOMON <cmomon@april.org>
|
||||
*
|
||||
* This file is part of (April) Hebdobot.
|
||||
*
|
||||
@ -18,13 +18,10 @@
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
@ -32,20 +29,6 @@ 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)
|
||||
*/
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||
* Copyright (C) 2018-2019 Christian Pierre MOMON <cmomon@april.org>
|
||||
*
|
||||
* This file is part of (April) Hebdobot.
|
||||
*
|
||||
@ -27,7 +27,6 @@ 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;
|
||||
@ -38,9 +37,6 @@ 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.
|
||||
*/
|
||||
@ -50,27 +46,6 @@ 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)
|
||||
*/
|
||||
@ -105,8 +80,9 @@ public class FinishReviewHook extends Hook
|
||||
else
|
||||
{
|
||||
// End the review.
|
||||
bot.sendChronoMessage();
|
||||
bot.endReview();
|
||||
bot.getReview().endReview();
|
||||
|
||||
bot.sendMessage("%% +%01d:%02d", bot.getTimekeeper().format());
|
||||
|
||||
// Load and update review statistics.
|
||||
ReviewDatas datas;
|
||||
@ -183,13 +159,12 @@ public class FinishReviewHook extends Hook
|
||||
}
|
||||
|
||||
// Send conclusion message in channel.
|
||||
bot.checkReviewAnniversary();
|
||||
bot.sendMessage("% " + ReviewStatsReporter.reportCurrentReviewCount(datas));
|
||||
bot.sendMessage("% " + ReviewStatsReporter.reportReviewCount(datas));
|
||||
bot.sendMessage("% Compte-rendu de la revue : " + pastebinUrl);
|
||||
bot.sendMessage("% Durée de la revue : " + bot.getReview().getDurationInMinutes() + " minutes");
|
||||
bot.sendMessage("% Nombre de personnes participantes : " + bot.getReview().getParticipants().size());
|
||||
|
||||
bot.sendMessage("% " + ReviewStatsReporter.reportCheckUserCountRecord(datas));
|
||||
bot.sendMessage("% " + ReviewStatsReporter.reportNewUserCountRecord(datas));
|
||||
bot.sendMessage(bot.getReview().getOwner(), ReviewStatsReporter.reportUserCount(datas, bot.getReview().getParticipants().size()));
|
||||
bot.sendMessage(bot.getReview().getOwner(), ReviewStatsReporter.reportDuration(datas, bot.getReview().getDurationInMinutes()));
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||
* Copyright (C) 2018 Christian Pierre MOMON <cmomon@april.org>
|
||||
*
|
||||
* This file is part of (April) Hebdobot.
|
||||
*
|
||||
@ -19,12 +19,10 @@
|
||||
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;
|
||||
|
||||
/**
|
||||
@ -34,27 +32,6 @@ 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)
|
||||
*/
|
||||
|
110
src/org/april/hebdobot/bot/hooks/HelpByCommandHook.java
Normal file
110
src/org/april/hebdobot/bot/hooks/HelpByCommandHook.java
Normal file
@ -0,0 +1,110 @@
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||
* Copyright (C) 2018 Christian Pierre MOMON <cmomon@april.org>
|
||||
*
|
||||
* This file is part of (April) Hebdobot.
|
||||
*
|
||||
@ -18,141 +18,60 @@
|
||||
*/
|
||||
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, !aide hebdobot, !help hebdobot : afficher l'aide générale");
|
||||
result.append("!aide commande, !help commande : afficher l'aide de la commande !commande");
|
||||
}
|
||||
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) throws HebdobotException
|
||||
final String message)
|
||||
{
|
||||
boolean result;
|
||||
|
||||
if (StringUtils.equalsAnyIgnoreCase(message, "!aide", "!help", "!aide hebdobot", "!help hebdobot"))
|
||||
if (StringUtils.equalsAnyIgnoreCase(message, "!aide", "!help"))
|
||||
{
|
||||
logger.info("!help caught.");
|
||||
|
||||
// Help.
|
||||
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, "Bienvenue " + sender);
|
||||
bot.sendMessage(sender, "Je suis " + bot.getName() + ", le robot de gestion des revues hebdomadaires de l'APRIL.");
|
||||
bot.sendMessage(sender, "Voici les commandes que je comprends :");
|
||||
bot.sendMessage(sender, " ");
|
||||
bot.sendMessage(sender, " !aide,!help : afficher cette aide");
|
||||
bot.sendMessage(sender, " !aide commande : afficher l'aide de la commande !commande");
|
||||
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, " !oups : annuler la dernière entrée dans un point de revue");
|
||||
bot.sendMessage(sender, " !courant : afficher le sujet en cours");
|
||||
bot.sendMessage(sender, " !fin : terminer la revue en cours");
|
||||
bot.sendMessage(sender, " !stop : abandonner la revue en cours");
|
||||
bot.sendMessage(sender, " !aide,!help : afficher cette aide");
|
||||
bot.sendMessage(sender, " !début : commencer une nouvelle revue");
|
||||
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, " !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 : !anniv, !bonjour, !chrono, !date, !hello, !licence, !manquants, !merci, !record, !salut, !stats, !status, !version");
|
||||
bot.sendMessage(sender, "Autres commandes de dialogue : !bonjour, !date, !hello, !merci, !salut");
|
||||
|
||||
result = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
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;
|
||||
}
|
||||
result = false;
|
||||
}
|
||||
|
||||
//
|
||||
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-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||
* Copyright (C) 2018 Christian Pierre MOMON <cmomon@april.org>
|
||||
*
|
||||
* This file is part of (April) Hebdobot.
|
||||
*
|
||||
@ -21,23 +21,11 @@ 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 string
|
||||
* the string
|
||||
* @return the string list
|
||||
* @throws HebdobotException
|
||||
* the hebdobot exception
|
||||
*/
|
||||
public abstract StringList attemptHelp(final String string) throws HebdobotException;
|
||||
|
||||
/**
|
||||
* Attempt process.
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||
* Copyright (C) 2018-2019 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 class Hooker, a hook manager.
|
||||
* The Interface MessageHook.
|
||||
*/
|
||||
public class Hooker
|
||||
public class HookManager
|
||||
{
|
||||
private static final Logger logger = LoggerFactory.getLogger(Hooker.class);
|
||||
private static final Logger logger = LoggerFactory.getLogger(HookManager.class);
|
||||
|
||||
private ArrayList<Hook> hooks;
|
||||
|
||||
/**
|
||||
* Instantiates a new hook manager.
|
||||
*/
|
||||
public Hooker()
|
||||
public HookManager()
|
||||
{
|
||||
this.hooks = new ArrayList<>(30);
|
||||
}
|
||||
@ -59,46 +59,6 @@ public class Hooker
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt help.
|
||||
*
|
||||
* @param message
|
||||
* the message
|
||||
* @return the string list
|
||||
* @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-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||
* Copyright (C) 2018 Christian Pierre MOMON <cmomon@april.org>
|
||||
*
|
||||
* This file is part of (April) Hebdobot.
|
||||
*
|
||||
@ -19,15 +19,11 @@
|
||||
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.
|
||||
*/
|
||||
@ -35,27 +31,6 @@ 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)
|
||||
*/
|
||||
@ -77,16 +52,15 @@ 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, on va passer à la suite : %s", participants, topic.getTitle()));
|
||||
bot.sendMessage(String.format("%% %s %s, on va passer à la suite : %s", bot.getTimekeeper().format(), 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.getChrono().start();
|
||||
bot.getTimekeeper().start();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||
* Copyright (C) 2018 Christian Pierre MOMON <cmomon@april.org>
|
||||
*
|
||||
* This file is part of (April) Hebdobot.
|
||||
*
|
||||
@ -18,14 +18,11 @@
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
@ -33,20 +30,6 @@ 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-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||
* Copyright (C) 2018 Christian Pierre MOMON <cmomon@april.org>
|
||||
*
|
||||
* This file is part of (April) Hebdobot.
|
||||
*
|
||||
@ -18,12 +18,10 @@
|
||||
*/
|
||||
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;
|
||||
|
||||
/**
|
||||
@ -33,27 +31,6 @@ 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)
|
||||
*/
|
||||
@ -67,8 +44,8 @@ public class LicenseHook extends Hook
|
||||
{
|
||||
logger.info("!licence caught.");
|
||||
|
||||
bot.sendMessage(
|
||||
"Hebdobot est un logiciel libre de l'April sous licence GNU AGPLv3+, sources : https://forge.april.org/adminsys/hebdobot");
|
||||
bot.sendMessage(sender
|
||||
+ ", 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-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||
* Copyright (C) 2018-2019 Christian Pierre MOMON <cmomon@april.org>
|
||||
*
|
||||
* This file is part of (April) Hebdobot.
|
||||
*
|
||||
@ -22,15 +22,12 @@ 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.
|
||||
@ -39,27 +36,6 @@ 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-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||
* Copyright (C) 2018 Christian Pierre MOMON <cmomon@april.org>
|
||||
*
|
||||
* This file is part of (April) Hebdobot.
|
||||
*
|
||||
@ -20,8 +20,6 @@ package org.april.hebdobot.bot.hooks;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
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;
|
||||
@ -29,9 +27,6 @@ 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.
|
||||
*/
|
||||
@ -39,27 +34,6 @@ 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)
|
||||
*/
|
||||
@ -69,7 +43,7 @@ public class RecordHook extends Hook
|
||||
{
|
||||
boolean result;
|
||||
|
||||
if (StringUtils.equalsIgnoreCase(message, "!record"))
|
||||
if (message.equals("!record"))
|
||||
{
|
||||
logger.info("!record caught.");
|
||||
|
||||
@ -81,7 +55,7 @@ public class RecordHook extends Hook
|
||||
{
|
||||
ReviewDatas datas = ReviewDatasFile.load(reviewDataFile);
|
||||
datas.clean();
|
||||
bot.sendMessage(ReviewStatsReporter.reportUserCountRecord(datas));
|
||||
bot.sendMessage("% " + ReviewStatsReporter.reportUserCountRecord(datas));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||
* Copyright (C) 2018 Christian Pierre MOMON <cmomon@april.org>
|
||||
*
|
||||
* This file is part of (April) Hebdobot.
|
||||
*
|
||||
@ -21,16 +21,12 @@ 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.
|
||||
*/
|
||||
@ -38,27 +34,6 @@ 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)
|
||||
*/
|
||||
@ -99,7 +74,6 @@ public class StartReviewHook extends Hook
|
||||
bot.setReview(new Review(sender, bot.getAliases()));
|
||||
bot.sendMessage(sender, "Bonjour " + sender + ", vous êtes le conducteur de réunion.");
|
||||
bot.sendMessage(sender, "Pour terminer la réunion, tapez \"!fin\"");
|
||||
bot.checkReviewAnniversary();
|
||||
bot.sendMessage("% Début de la réunion hebdomadaire");
|
||||
bot.sendMessage(
|
||||
"% rappel : toute ligne commençant par % sera considérée comme un commentaire et non prise en compte dans la synthèse");
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||
* Copyright (C) 2018 Christian Pierre MOMON <cmomon@april.org>
|
||||
*
|
||||
* This file is part of (April) Hebdobot.
|
||||
*
|
||||
@ -20,8 +20,6 @@ package org.april.hebdobot.bot.hooks;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
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;
|
||||
@ -29,9 +27,6 @@ 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.
|
||||
*/
|
||||
@ -39,27 +34,6 @@ 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)
|
||||
*/
|
||||
@ -69,7 +43,7 @@ public class StatsHook extends Hook
|
||||
{
|
||||
boolean result;
|
||||
|
||||
if (StringUtils.equalsIgnoreCase(message, "!stats"))
|
||||
if (message.equals("!stats"))
|
||||
{
|
||||
logger.info("!stats caught.");
|
||||
|
||||
@ -82,9 +56,6 @@ public class StatsHook extends Hook
|
||||
{
|
||||
ReviewDatas datas = ReviewDatasFile.load(reviewDataFile);
|
||||
datas.clean();
|
||||
bot.sendMessage("% " + ReviewStatsReporter.reportReviewCount(datas));
|
||||
bot.sendMessage("% " + ReviewStatsReporter.reportReviewUserCount(datas));
|
||||
bot.sendMessage("% " + ReviewStatsReporter.reportReviewDuration(datas));
|
||||
bot.sendMessage("% " + ReviewStatsReporter.reportUserCountBoard(datas));
|
||||
bot.sendMessage("% " + ReviewStatsReporter.reportDurationBoard(datas));
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||
* Copyright (C) 2018 Christian Pierre MOMON <cmomon@april.org>
|
||||
*
|
||||
* This file is part of (April) Hebdobot.
|
||||
*
|
||||
@ -19,14 +19,10 @@
|
||||
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.
|
||||
*/
|
||||
@ -34,27 +30,6 @@ 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-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||
* Copyright (C) 2018-2019 Christian Pierre MOMON <cmomon@april.org>
|
||||
*
|
||||
* This file is part of (April) Hebdobot.
|
||||
*
|
||||
@ -19,14 +19,10 @@
|
||||
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.
|
||||
*/
|
||||
@ -34,27 +30,6 @@ 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)
|
||||
*/
|
||||
@ -80,7 +55,7 @@ public class StopReviewHook extends Hook
|
||||
else
|
||||
{
|
||||
bot.sendMessage("Abandon de la revue en cours.");
|
||||
bot.stopReview();
|
||||
bot.setReview(null);
|
||||
}
|
||||
|
||||
result = true;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||
* Copyright (C) 2018 Christian Pierre MOMON <cmomon@april.org>
|
||||
*
|
||||
* This file is part of (April) Hebdobot.
|
||||
*
|
||||
@ -19,12 +19,10 @@
|
||||
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;
|
||||
|
||||
/**
|
||||
@ -34,27 +32,6 @@ 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)
|
||||
*/
|
||||
|
@ -19,36 +19,16 @@
|
||||
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;
|
||||
|
||||
/**
|
||||
* The Class ListenAlexandrieHook.
|
||||
*
|
||||
* This hook is listening Alexandrie messages and do not answer.
|
||||
*
|
||||
* The Class TimekeeperHook.
|
||||
*/
|
||||
public class ListenAlexandrieHook extends Hook
|
||||
public class TimekeeperHook extends Hook
|
||||
{
|
||||
private static final Logger logger = LoggerFactory.getLogger(ListenAlexandrieHook.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;
|
||||
}
|
||||
private static final Logger logger = LoggerFactory.getLogger(TimekeeperHook.class);
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.april.hebdobot.bot.hooks.Hook#attemptProcess(org.april.hebdobot.bot.Hebdobot, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
|
||||
@ -59,8 +39,11 @@ public class ListenAlexandrieHook extends Hook
|
||||
{
|
||||
boolean result;
|
||||
|
||||
if (StringUtils.equalsIgnoreCase(sender, "alexandrie"))
|
||||
if (StringUtils.equalsAnyIgnoreCase(message, "!timekeeper", "!chrono"))
|
||||
{
|
||||
logger.info("!chrono caught.");
|
||||
bot.sendMessage(bot.getTimekeeper().format());
|
||||
|
||||
result = true;
|
||||
}
|
||||
else
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||
* Copyright (C) 2018 Christian Pierre MOMON <cmomon@april.org>
|
||||
*
|
||||
* This file is part of (April) Hebdobot.
|
||||
*
|
||||
@ -18,16 +18,11 @@
|
||||
*/
|
||||
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.util.BuildInformation;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import fr.devinsy.strings.StringList;
|
||||
import fr.devinsy.strings.StringsUtils;
|
||||
|
||||
/**
|
||||
* The Class VersionHook.
|
||||
*/
|
||||
@ -35,27 +30,6 @@ 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)
|
||||
*/
|
||||
@ -65,7 +39,7 @@ public class VersionHook extends Hook
|
||||
{
|
||||
boolean result;
|
||||
|
||||
if (StringUtils.equalsIgnoreCase(message, "!version"))
|
||||
if (message.equals("!version"))
|
||||
{
|
||||
logger.info("!version caught.");
|
||||
bot.sendMessage(new BuildInformation().toString());
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (C) 2017-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||
* Copyright (C) 2017-2019 Christian Pierre MOMON <cmomon@april.org>
|
||||
* Copyright (C) 2011-2013 Nicolas Vinot <aeris@imirhil.fr>
|
||||
*
|
||||
* This file is part of (April) Hebdobot.
|
||||
@ -56,25 +56,13 @@ public class CollectiveTopic extends Topic
|
||||
* @see org.april.hebdobot.bot.review.Topic#cancelPrevious(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public String cancelPreviousMessage(final String author)
|
||||
public void cancelPreviousMessage(final String author)
|
||||
{
|
||||
String result;
|
||||
|
||||
Messages authorMessages = this.messages.getByAuthor(author);
|
||||
|
||||
if (authorMessages.isEmpty())
|
||||
Message previousMessage = this.messages.getByAuthor(author).getLast();
|
||||
if (previousMessage != null)
|
||||
{
|
||||
result = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
Message previousMessage = authorMessages.getLast();
|
||||
this.messages.remove(previousMessage);
|
||||
result = previousMessage.getContent();
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -102,23 +90,4 @@ public class CollectiveTopic extends Topic
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for message.
|
||||
*
|
||||
* @param author
|
||||
* the author
|
||||
* @return true, if successful
|
||||
*/
|
||||
@Override
|
||||
public boolean hasMessage(final String author)
|
||||
{
|
||||
boolean result;
|
||||
|
||||
Messages authorMessage = this.messages.getByAuthor(author);
|
||||
result = authorMessage.isEmpty();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (C) 2017-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||
* Copyright (C) 2017-2019 Christian Pierre MOMON <cmomon@april.org>
|
||||
* Copyright (C) 2011-2013 Nicolas Vinot <aeris@imirhil.fr>
|
||||
*
|
||||
* This file is part of (April) Hebdobot.
|
||||
@ -19,6 +19,9 @@
|
||||
*/
|
||||
package org.april.hebdobot.bot.review;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import fr.devinsy.strings.StringSet;
|
||||
|
||||
/**
|
||||
@ -26,7 +29,7 @@ import fr.devinsy.strings.StringSet;
|
||||
*/
|
||||
public class IndividualTopic extends Topic
|
||||
{
|
||||
private final MessageMap messages;
|
||||
private final Map<String, Messages> messages;
|
||||
|
||||
/**
|
||||
* Instantiates a new individual topic.
|
||||
@ -38,7 +41,7 @@ public class IndividualTopic extends Topic
|
||||
{
|
||||
super(title);
|
||||
|
||||
this.messages = new MessageMap();
|
||||
this.messages = new HashMap<>();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@ -59,23 +62,13 @@ public class IndividualTopic extends Topic
|
||||
* @see org.april.hebdobot.bot.review.Topic#cancelPrevious(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public String cancelPreviousMessage(final String participant)
|
||||
public void cancelPreviousMessage(final String participant)
|
||||
{
|
||||
String result;
|
||||
|
||||
Messages authorMessages = this.messages.get(participant);
|
||||
if ((authorMessages == null) || (authorMessages.isEmpty()))
|
||||
if (authorMessages != null)
|
||||
{
|
||||
result = null;
|
||||
authorMessages.removeLast();
|
||||
}
|
||||
else
|
||||
{
|
||||
Message removed = authorMessages.removeLast();
|
||||
result = removed.getContent();
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -109,33 +102,6 @@ public class IndividualTopic extends Topic
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for message.
|
||||
*
|
||||
* @param participant
|
||||
* the participant
|
||||
* @return true, if successful
|
||||
*/
|
||||
@Override
|
||||
public boolean hasMessage(final String participant)
|
||||
{
|
||||
boolean result;
|
||||
|
||||
Messages messages = this.messages.get(participant);
|
||||
|
||||
if ((messages == null) || (messages.isEmpty()))
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for participant.
|
||||
*
|
||||
|
@ -1,37 +0,0 @@
|
||||
/**
|
||||
* 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.review;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* The Class MessageMap.
|
||||
*/
|
||||
public class MessageMap extends HashMap<String, Messages>
|
||||
{
|
||||
private static final long serialVersionUID = 2324236890989710448L;
|
||||
|
||||
/**
|
||||
* Instantiates a new message map.
|
||||
*/
|
||||
public MessageMap()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
@ -282,7 +282,7 @@ public class ReviewReporter
|
||||
//
|
||||
addLine(buffer, '=');
|
||||
addEmpty(buffer);
|
||||
addCenter(buffer, "Personnes participantes", '-');
|
||||
addCenter(buffer, "Participants", '-');
|
||||
for (final String participant : review.getParticipants())
|
||||
{
|
||||
addChunk(buffer, "* " + review.getAliases().getRealName(participant));
|
||||
@ -343,12 +343,12 @@ public class ReviewReporter
|
||||
addEmpty(buffer);
|
||||
addCenter(buffer, "Statistiques");
|
||||
addEmpty(buffer);
|
||||
addChunk(buffer, ReviewStatsReporter.reportCurrentReviewCount(datas));
|
||||
addChunk(buffer, ReviewStatsReporter.reportReviewCount(datas));
|
||||
addChunk(buffer, "Horaire de début de la revue : " + review.getFormattedStartTime());
|
||||
addChunk(buffer, "Horaire de fin de la revue : " + review.getFormattedEndTime());
|
||||
addChunk(buffer, "Durée de la revue : " + review.getDurationInMinutes() + " minutes");
|
||||
addChunk(buffer, "Nombre de personnes participantes : " + review.getParticipants().size());
|
||||
addChunk(buffer, ReviewStatsReporter.reportCheckUserCountRecord(datas));
|
||||
addChunk(buffer, ReviewStatsReporter.reportNewUserCountRecord(datas));
|
||||
addChunk(buffer, ReviewStatsReporter.reportUserCount(datas, review.getParticipants().size()));
|
||||
addChunk(buffer, ReviewStatsReporter.reportDuration(datas, review.getDurationInMinutes()));
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (C) 2017-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||
* Copyright (C) 2017-2019 Christian Pierre MOMON <cmomon@april.org>
|
||||
* Copyright (C) 2011-2013 Nicolas Vinot <aeris@imirhil.fr>
|
||||
*
|
||||
* This file is part of (April) Hebdobot.
|
||||
@ -53,7 +53,7 @@ public abstract class Topic
|
||||
* @param participant
|
||||
* the participant
|
||||
*/
|
||||
public abstract String cancelPreviousMessage(final String participant);
|
||||
public abstract void cancelPreviousMessage(final String participant);
|
||||
|
||||
/**
|
||||
* Gets the participants.
|
||||
@ -71,13 +71,4 @@ public abstract class Topic
|
||||
{
|
||||
return this.title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for message from.
|
||||
*
|
||||
* @param author
|
||||
* the author
|
||||
* @return true, if successful
|
||||
*/
|
||||
public abstract boolean hasMessage(String author);
|
||||
}
|
||||
|
@ -106,70 +106,6 @@ public class ReviewDatas extends ArrayList<ReviewData>
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the averatge duration.
|
||||
*
|
||||
* @return the averatge duration
|
||||
*/
|
||||
public double getAveratgeDuration()
|
||||
{
|
||||
double result;
|
||||
|
||||
if (isEmpty())
|
||||
{
|
||||
result = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = 0;
|
||||
int count = 0;
|
||||
for (ReviewData data : this)
|
||||
{
|
||||
if (data.getDuration() != null)
|
||||
{
|
||||
count += 1;
|
||||
result += data.getDuration();
|
||||
}
|
||||
}
|
||||
|
||||
if (count != 0)
|
||||
{
|
||||
result = result / count;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the averatge user count.
|
||||
*
|
||||
* @return the averatge user count
|
||||
*/
|
||||
public double getAveratgeUserCount()
|
||||
{
|
||||
double result;
|
||||
|
||||
if (isEmpty())
|
||||
{
|
||||
result = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = 0;
|
||||
for (ReviewData data : this)
|
||||
{
|
||||
result += data.getUserCount();
|
||||
}
|
||||
|
||||
result = result / size();
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the by year.
|
||||
*
|
||||
@ -247,35 +183,6 @@ public class ReviewDatas extends ArrayList<ReviewData>
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the max duration.
|
||||
*
|
||||
* @return the max duration
|
||||
*/
|
||||
public long getMaxDuration()
|
||||
{
|
||||
long result;
|
||||
|
||||
if (isEmpty())
|
||||
{
|
||||
result = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = Long.MIN_VALUE;
|
||||
for (ReviewData data : this)
|
||||
{
|
||||
if ((data.getDuration() != null) && (data.getUserCount() > result))
|
||||
{
|
||||
result = data.getDuration();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the max user count.
|
||||
*
|
||||
@ -305,35 +212,6 @@ public class ReviewDatas extends ArrayList<ReviewData>
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the min duration.
|
||||
*
|
||||
* @return the min duration
|
||||
*/
|
||||
public long getMinDuration()
|
||||
{
|
||||
long result;
|
||||
|
||||
if (isEmpty())
|
||||
{
|
||||
result = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = Long.MAX_VALUE;
|
||||
for (ReviewData data : this)
|
||||
{
|
||||
if ((data.getDuration() != null) && (data.getDuration() < result))
|
||||
{
|
||||
result = data.getDuration();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the min user count.
|
||||
*
|
||||
@ -420,60 +298,32 @@ public class ReviewDatas extends ArrayList<ReviewData>
|
||||
/**
|
||||
* Reverse.
|
||||
*/
|
||||
public ReviewDatas reverse()
|
||||
public void reverse()
|
||||
{
|
||||
ReviewDatas result;
|
||||
|
||||
Collections.reverse(this);
|
||||
|
||||
result = this;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort by date.
|
||||
*/
|
||||
public ReviewDatas sortByDate()
|
||||
public void sortByDate()
|
||||
{
|
||||
ReviewDatas result;
|
||||
|
||||
Collections.sort(this, new ReviewDataComparator(Sorting.DATE));
|
||||
|
||||
result = this;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort by duration.
|
||||
*/
|
||||
public ReviewDatas sortByDuration()
|
||||
public void sortByDuration()
|
||||
{
|
||||
ReviewDatas result;
|
||||
|
||||
Collections.sort(this, new ReviewDataComparator(Sorting.DURATION));
|
||||
|
||||
result = this;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort by user count.
|
||||
*/
|
||||
public ReviewDatas sortByUserCount()
|
||||
public void sortByUserCount()
|
||||
{
|
||||
ReviewDatas result;
|
||||
|
||||
Collections.sort(this, new ReviewDataComparator(Sorting.USERCOUNT));
|
||||
|
||||
result = this;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -108,82 +108,6 @@ public class ReviewStatsReporter
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Report new max. The current user count is found in last review by date.
|
||||
*
|
||||
* @param datas
|
||||
* the datas
|
||||
* @return the string
|
||||
*/
|
||||
public static String reportCheckUserCountRecord(final ReviewDatas datas)
|
||||
{
|
||||
String result;
|
||||
|
||||
if ((datas == null) || (datas.isEmpty()) || (datas.size() == 1))
|
||||
{
|
||||
result = "Absence de statistique sur la participation.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ReviewDatas reviews = new ReviewDatas(datas);
|
||||
reviews.sortByDate();
|
||||
ReviewData lastReview = datas.getLastByIndex();
|
||||
reviews.removeLast();
|
||||
reviews.sortByUserCount();
|
||||
ReviewData recordReview = reviews.getLastByIndex();
|
||||
|
||||
if (lastReview.getUserCount() < recordReview.getUserCount())
|
||||
{
|
||||
double averageUserCount = reviews.getAveratgeUserCount();
|
||||
result = String.format("La participation moyenne aux revues est de %02.1f personnes.", averageUserCount);
|
||||
}
|
||||
else if (lastReview.getUserCount() == recordReview.getUserCount())
|
||||
{
|
||||
String lastRecordDate = recordReview.getDate().format(DateTimeFormatter.ofPattern("EEEE dd MMMM yyyy", Locale.FRENCH));
|
||||
result = String.format("\\o/ Record de participation égalé \\o/ Le précédent record de %d personnes était le %s.",
|
||||
recordReview.getUserCount(), lastRecordDate);
|
||||
}
|
||||
else
|
||||
{
|
||||
String lastRecordDate = recordReview.getDate().format(DateTimeFormatter.ofPattern("EEEE dd MMMM yyyy", Locale.FRENCH));
|
||||
result = String.format(
|
||||
"*\\o/* Nouveau record de participation : %d personnes ! *\\o/* Le précédent record était de %d personnes le %s.",
|
||||
lastReview.getUserCount(), recordReview.getUserCount(), lastRecordDate);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Report review count.
|
||||
*
|
||||
* @param datas
|
||||
* the datas
|
||||
* @return the string
|
||||
*/
|
||||
public static String reportCurrentReviewCount(final ReviewDatas datas)
|
||||
{
|
||||
String result;
|
||||
|
||||
if ((datas == null) || (datas.isEmpty()))
|
||||
{
|
||||
result = "Pas de statistique sur le nombre de revues.";
|
||||
}
|
||||
else
|
||||
{
|
||||
long currentYear = LocalDateTime.now().getYear();
|
||||
long reviewYearCount = datas.countByYear(currentYear);
|
||||
|
||||
result = String.format("C'était la %d%s revue hebdomadaire de l'April, la %d%s de l'année %d.", datas.size(), numberSuffix(datas.size()),
|
||||
reviewYearCount, numberSuffix(reviewYearCount), currentYear);
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Report duration.
|
||||
*
|
||||
@ -245,6 +169,55 @@ public class ReviewStatsReporter
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Report new max. The current user count is found in last review by date.
|
||||
*
|
||||
* @param datas
|
||||
* the datas
|
||||
* @return the string
|
||||
*/
|
||||
public static String reportNewUserCountRecord(final ReviewDatas datas)
|
||||
{
|
||||
String result;
|
||||
|
||||
if ((datas == null) || (datas.isEmpty()) || (datas.size() == 1))
|
||||
{
|
||||
result = "Absence de statistique sur la participation.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ReviewDatas reviews = new ReviewDatas(datas);
|
||||
reviews.sortByDate();
|
||||
ReviewData lastReview = datas.getLastByIndex();
|
||||
reviews.removeLast();
|
||||
reviews.sortByUserCount();
|
||||
ReviewData recordReview = reviews.getLastByIndex();
|
||||
|
||||
if (lastReview.getUserCount() < recordReview.getUserCount())
|
||||
{
|
||||
String lastRecordDate = recordReview.getDate().format(DateTimeFormatter.ofPattern("EEEE dd MMMM yyyy", Locale.FRENCH));
|
||||
result = String.format("Le dernier record de participation est de %d personnes le %s.", recordReview.getUserCount(), lastRecordDate);
|
||||
}
|
||||
else if (lastReview.getUserCount() == recordReview.getUserCount())
|
||||
{
|
||||
result = "Record de participation égalé.";
|
||||
String lastRecordDate = recordReview.getDate().format(DateTimeFormatter.ofPattern("EEEE dd MMMM yyyy", Locale.FRENCH));
|
||||
result = String.format("\\o/ Record de participation égalé \\o/ Le précédent record était de %d personnes le %s.",
|
||||
recordReview.getUserCount(), lastRecordDate);
|
||||
}
|
||||
else
|
||||
{
|
||||
String lastRecordDate = recordReview.getDate().format(DateTimeFormatter.ofPattern("EEEE dd MMMM yyyy", Locale.FRENCH));
|
||||
result = String.format(
|
||||
"*\\o/* Nouveau record de participation : %d personnes ! *\\o/* Le précédent record était de %d personnes le %s.",
|
||||
lastReview.getUserCount(), recordReview.getUserCount(), lastRecordDate);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Report review count.
|
||||
*
|
||||
@ -262,61 +235,11 @@ public class ReviewStatsReporter
|
||||
}
|
||||
else
|
||||
{
|
||||
ReviewData firstReview = datas.sortByDate().get(0);
|
||||
long reviewCount = datas.size();
|
||||
String firstDate = firstReview.getDate().format(DateTimeFormatter.ofPattern("EEEE dd MMMM yyyy", Locale.FRENCH));
|
||||
long currentYear = LocalDateTime.now().getYear();
|
||||
long reviewYearCount = datas.countByYear(currentYear);
|
||||
|
||||
result = String.format("Il y a eu %d revues. La première date du %s.", reviewCount, firstDate);
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Report review duration.
|
||||
*
|
||||
* @param datas
|
||||
* the datas
|
||||
* @return the string
|
||||
*/
|
||||
public static String reportReviewDuration(final ReviewDatas datas)
|
||||
{
|
||||
String result;
|
||||
|
||||
if ((datas == null) || (datas.isEmpty()))
|
||||
{
|
||||
result = "Pas de statistique sur la durée des revues.";
|
||||
}
|
||||
else
|
||||
{
|
||||
result = String.format("Durée des revues : min.=%d min, moy.=%.1f min, max=%d min", datas.getMinDuration(), datas.getAveratgeDuration(),
|
||||
datas.getMaxDuration());
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Report review user count.
|
||||
*
|
||||
* @param datas
|
||||
* the datas
|
||||
* @return the string
|
||||
*/
|
||||
public static String reportReviewUserCount(final ReviewDatas datas)
|
||||
{
|
||||
String result;
|
||||
|
||||
if ((datas == null) || (datas.isEmpty()))
|
||||
{
|
||||
result = "Absence de statistique sur les participations.";
|
||||
}
|
||||
else
|
||||
{
|
||||
result = String.format("Participation aux revues : min.=%d, moy.=%.1f, max=%d", datas.getMinUserCount(), datas.getAveratgeUserCount(),
|
||||
datas.getMaxUserCount());
|
||||
result = String.format("C'était la %d%s revue hebdomadaire de l'April, la %d%s de l'année %d.", datas.size(), numberSuffix(datas.size()),
|
||||
reviewYearCount, numberSuffix(reviewYearCount), currentYear);
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -220,7 +220,7 @@ public class PrivatebinClient extends PrivatebinSettings
|
||||
String deleteToken = parser.get("deletetoken").toString();
|
||||
String finalURL = this.serverUrl + pasteURL + "#" + Base58.encode(randomPassword.getBytes());
|
||||
String deleteURL = this.serverUrl + pasteURL + "&deletetoken=" + deleteToken;
|
||||
logger.info("Pastebin SUCCESS");
|
||||
logger.info("Pastebin SUCESS");
|
||||
logger.debug("Paste URL: {}", finalURL);
|
||||
logger.debug("Delete URL: {}", deleteURL);
|
||||
result = finalURL;
|
||||
|
@ -22,18 +22,18 @@ import java.time.Duration;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* The Class Chrono.
|
||||
* The Class TimeKeeper.
|
||||
*/
|
||||
public class Chrono
|
||||
public class Timekeeper
|
||||
{
|
||||
private LocalDateTime start;
|
||||
|
||||
/**
|
||||
* Instantiates a new time keeper.
|
||||
*/
|
||||
public Chrono()
|
||||
public Timekeeper()
|
||||
{
|
||||
reset();
|
||||
this.start = null;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -61,14 +61,6 @@ public class Chrono
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset.
|
||||
*/
|
||||
public void reset()
|
||||
{
|
||||
this.start = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Start.
|
||||
*/
|
||||
@ -76,20 +68,4 @@ public class Chrono
|
||||
{
|
||||
this.start = LocalDateTime.now();
|
||||
}
|
||||
|
||||
/**
|
||||
* To string.
|
||||
*
|
||||
* @return the string
|
||||
*/
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
String result;
|
||||
|
||||
result = format();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
}
|
@ -72,7 +72,7 @@ public class ReviewStatsReporterTest
|
||||
logger.debug("File loaded.");
|
||||
ReviewData currentReview = new ReviewData(LocalDateTime.now(), 12, 17L);
|
||||
datas.add(currentReview);
|
||||
String report = ReviewStatsReporter.reportCheckUserCountRecord(datas);
|
||||
String report = ReviewStatsReporter.reportNewUserCountRecord(datas);
|
||||
logger.debug("Report=" + report);
|
||||
Assert.assertTrue(StringUtils.startsWith(report, "Le dernier record de"));
|
||||
}
|
||||
@ -92,7 +92,7 @@ public class ReviewStatsReporterTest
|
||||
logger.debug("File loaded.");
|
||||
ReviewData currentReview = new ReviewData(LocalDateTime.now(), 42000, 17L);
|
||||
datas.add(currentReview);
|
||||
String report = ReviewStatsReporter.reportCheckUserCountRecord(datas);
|
||||
String report = ReviewStatsReporter.reportNewUserCountRecord(datas);
|
||||
logger.debug("Report=" + report);
|
||||
Assert.assertTrue(StringUtils.startsWith(report, "*\\o/* Nouveau record de participation"));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user