Compare commits
35 Commits
2.11.0
...
Hebdobot-v
Author | SHA1 | Date | |
---|---|---|---|
89321c9203 | |||
4f7f9902e8 | |||
13abc16e41 | |||
fbd6543aa2 | |||
959d947563 | |||
d0bedf3d31 | |||
ba417d60d8 | |||
e04bfdcf84 | |||
8b3784e7d5 | |||
5f449b66e5 | |||
03103efa35 | |||
ef22bbc593 | |||
d00ba4c40a | |||
9f0e09b8e6 | |||
31bca36d49 | |||
cbdef8e674 | |||
483732382b | |||
925bc0a805 | |||
d709328666 | |||
54669590ab | |||
66bb09ef87 | |||
f5da3a6ae4 | |||
534d335df1 | |||
216db84883 | |||
47fd4b58e8 | |||
c469fd5c7b | |||
4382db9e8b | |||
de0d8a4d5e | |||
58d8bcc3a8 | |||
caba69fc75 | |||
cd319dbacc | |||
b5fd23533f | |||
03e346554f | |||
9a3bf64417 | |||
8e51e5c25b |
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 :
|
Le 08/01/2018 à 01:07, aeris a écrit :
|
||||||
> From: aeris <aeris@imirhil.fr>
|
> 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.
|
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 AGPL é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 AGPLv3+ édité par l'April dont le projet est géré ici : https://agir.april.org/projects/hebdobot.
|
||||||
|
|
||||||
Résultat de la commande !aide :
|
Résultat de la commande !aide :
|
||||||
|
|
||||||
@ -35,13 +35,23 @@ 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.
|
À 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
|
## License
|
||||||
|
|
||||||
Hebdobot is a free software released on GNU AGPL 3+
|
Hebdobot is a free software released on GNU AGPLv3+
|
||||||
|
|
||||||
## History
|
|
||||||
|
|
||||||
TODO
|
|
||||||
|
|
||||||
## Logo
|
## Logo
|
||||||
|
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
#Build Number for ANT. Do not edit!
|
#Build Number for ANT. Do not edit!
|
||||||
#Fri Apr 09 03:19:43 CEST 2021
|
#Fri Dec 31 11:53:11 CET 2021
|
||||||
build.number=1
|
build.number=8
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (C) 2017-2019 Christian Pierre MOMON <cmomon@april.org>
|
* Copyright (C) 2017-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||||
* Copyright (C) 2011-2013,2017 Nicolas Vinot <aeris@imirhil.fr>
|
* Copyright (C) 2011-2013,2017 Nicolas Vinot <aeris@imirhil.fr>
|
||||||
*
|
*
|
||||||
* This file is part of (April) Hebdobot.
|
* This file is part of (April) Hebdobot.
|
||||||
@ -22,12 +22,15 @@ package org.april.hebdobot.bot;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
|
import java.time.LocalDate;
|
||||||
import java.time.LocalTime;
|
import java.time.LocalTime;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.april.hebdobot.HebdobotException;
|
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.BadCommandHook;
|
||||||
import org.april.hebdobot.bot.hooks.CancelPreviousInputHook;
|
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.CollectiveSubjectHook;
|
||||||
import org.april.hebdobot.bot.hooks.CommentHook;
|
import org.april.hebdobot.bot.hooks.CommentHook;
|
||||||
import org.april.hebdobot.bot.hooks.CurrentHook;
|
import org.april.hebdobot.bot.hooks.CurrentHook;
|
||||||
@ -36,10 +39,11 @@ import org.april.hebdobot.bot.hooks.DefaultHook;
|
|||||||
import org.april.hebdobot.bot.hooks.FinishReviewHook;
|
import org.april.hebdobot.bot.hooks.FinishReviewHook;
|
||||||
import org.april.hebdobot.bot.hooks.HelloHook;
|
import org.april.hebdobot.bot.hooks.HelloHook;
|
||||||
import org.april.hebdobot.bot.hooks.HelpHook;
|
import org.april.hebdobot.bot.hooks.HelpHook;
|
||||||
import org.april.hebdobot.bot.hooks.HookManager;
|
import org.april.hebdobot.bot.hooks.Hooker;
|
||||||
import org.april.hebdobot.bot.hooks.IndividualSubjectHook;
|
import org.april.hebdobot.bot.hooks.IndividualSubjectHook;
|
||||||
import org.april.hebdobot.bot.hooks.InputReviewHook;
|
import org.april.hebdobot.bot.hooks.InputReviewHook;
|
||||||
import org.april.hebdobot.bot.hooks.LicenseHook;
|
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.MissingHook;
|
||||||
import org.april.hebdobot.bot.hooks.RecordHook;
|
import org.april.hebdobot.bot.hooks.RecordHook;
|
||||||
import org.april.hebdobot.bot.hooks.StartReviewHook;
|
import org.april.hebdobot.bot.hooks.StartReviewHook;
|
||||||
@ -47,7 +51,6 @@ import org.april.hebdobot.bot.hooks.StatsHook;
|
|||||||
import org.april.hebdobot.bot.hooks.StatusHook;
|
import org.april.hebdobot.bot.hooks.StatusHook;
|
||||||
import org.april.hebdobot.bot.hooks.StopReviewHook;
|
import org.april.hebdobot.bot.hooks.StopReviewHook;
|
||||||
import org.april.hebdobot.bot.hooks.ThanksHook;
|
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.hooks.VersionHook;
|
||||||
import org.april.hebdobot.bot.review.Message;
|
import org.april.hebdobot.bot.review.Message;
|
||||||
import org.april.hebdobot.bot.review.Review;
|
import org.april.hebdobot.bot.review.Review;
|
||||||
@ -57,7 +60,7 @@ import org.april.hebdobot.identica.IdenticaSettings;
|
|||||||
import org.april.hebdobot.privatebin.PrivatebinSettings;
|
import org.april.hebdobot.privatebin.PrivatebinSettings;
|
||||||
import org.april.hebdobot.twitter.TwitterClient;
|
import org.april.hebdobot.twitter.TwitterClient;
|
||||||
import org.april.hebdobot.twitter.TwitterSettings;
|
import org.april.hebdobot.twitter.TwitterSettings;
|
||||||
import org.april.hebdobot.util.Timekeeper;
|
import org.april.hebdobot.util.Chrono;
|
||||||
import org.jibble.pircbot.IrcException;
|
import org.jibble.pircbot.IrcException;
|
||||||
import org.jibble.pircbot.NickAlreadyInUseException;
|
import org.jibble.pircbot.NickAlreadyInUseException;
|
||||||
import org.jibble.pircbot.PircBot;
|
import org.jibble.pircbot.PircBot;
|
||||||
@ -65,6 +68,7 @@ import org.quartz.SchedulerException;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import fr.devinsy.strings.StringList;
|
||||||
import twitter4j.TwitterException;
|
import twitter4j.TwitterException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -84,14 +88,14 @@ public class Hebdobot extends PircBot
|
|||||||
private String reviewFileSuffix;
|
private String reviewFileSuffix;
|
||||||
private LocalTime reviewWaitTime;
|
private LocalTime reviewWaitTime;
|
||||||
private Review review;
|
private Review review;
|
||||||
private Timekeeper timekeeper;
|
private Chrono chrono;
|
||||||
private IdenticaSettings identicaSettings;
|
private IdenticaSettings identicaSettings;
|
||||||
private PrivatebinSettings privatebinSettings;
|
private PrivatebinSettings privatebinSettings;
|
||||||
private TwitterSettings twitterSettings;
|
private TwitterSettings twitterSettings;
|
||||||
private CronSettings cronSettings;
|
private CronSettings cronSettings;
|
||||||
private UserAliases aliases;
|
private UserAliases aliases;
|
||||||
private CronManager cronManager;
|
private CronManager cronManager;
|
||||||
private HookManager hooker;
|
private Hooker hooker;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new hebdobot.
|
* Instantiates a new hebdobot.
|
||||||
@ -127,7 +131,7 @@ public class Hebdobot extends PircBot
|
|||||||
this.reviewFileSuffix = null;
|
this.reviewFileSuffix = null;
|
||||||
this.reviewWaitTime = null;
|
this.reviewWaitTime = null;
|
||||||
this.review = null;
|
this.review = null;
|
||||||
this.timekeeper = new Timekeeper();
|
this.chrono = new Chrono();
|
||||||
|
|
||||||
this.identicaSettings = new IdenticaSettings();
|
this.identicaSettings = new IdenticaSettings();
|
||||||
this.privatebinSettings = new PrivatebinSettings();
|
this.privatebinSettings = new PrivatebinSettings();
|
||||||
@ -138,8 +142,11 @@ public class Hebdobot extends PircBot
|
|||||||
this.cronManager = null;
|
this.cronManager = null;
|
||||||
|
|
||||||
//
|
//
|
||||||
this.hooker = new HookManager();
|
this.hooker = new Hooker();
|
||||||
|
|
||||||
|
this.hooker.add(new ListenAlexandrieHook());
|
||||||
|
this.hooker.add(new CancelPreviousInputHook());
|
||||||
|
this.hooker.add(new ChronoHook());
|
||||||
this.hooker.add(new CollectiveSubjectHook());
|
this.hooker.add(new CollectiveSubjectHook());
|
||||||
this.hooker.add(new CommentHook());
|
this.hooker.add(new CommentHook());
|
||||||
this.hooker.add(new CurrentHook());
|
this.hooker.add(new CurrentHook());
|
||||||
@ -152,9 +159,8 @@ public class Hebdobot extends PircBot
|
|||||||
this.hooker.add(new StopReviewHook());
|
this.hooker.add(new StopReviewHook());
|
||||||
this.hooker.add(new StatsHook());
|
this.hooker.add(new StatsHook());
|
||||||
this.hooker.add(new StatusHook());
|
this.hooker.add(new StatusHook());
|
||||||
this.hooker.add(new CancelPreviousInputHook());
|
|
||||||
|
|
||||||
this.hooker.add(new TimekeeperHook());
|
this.hooker.add(new AnnivHook());
|
||||||
this.hooker.add(new DateHook());
|
this.hooker.add(new DateHook());
|
||||||
this.hooker.add(new HelloHook());
|
this.hooker.add(new HelloHook());
|
||||||
this.hooker.add(new LicenseHook());
|
this.hooker.add(new LicenseHook());
|
||||||
@ -166,6 +172,27 @@ public class Hebdobot extends PircBot
|
|||||||
this.hooker.add(new DefaultHook());
|
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.
|
* Close.
|
||||||
*/
|
*/
|
||||||
@ -175,6 +202,15 @@ public class Hebdobot extends PircBot
|
|||||||
this.dispose();
|
this.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* End review.
|
||||||
|
*/
|
||||||
|
public void endReview()
|
||||||
|
{
|
||||||
|
this.review.endReview();
|
||||||
|
this.chrono.reset();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the aliases.
|
* Gets the aliases.
|
||||||
*
|
*
|
||||||
@ -185,6 +221,11 @@ public class Hebdobot extends PircBot
|
|||||||
return this.aliases;
|
return this.aliases;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Chrono getChrono()
|
||||||
|
{
|
||||||
|
return this.chrono;
|
||||||
|
}
|
||||||
|
|
||||||
public CronManager getCronManager()
|
public CronManager getCronManager()
|
||||||
{
|
{
|
||||||
return this.cronManager;
|
return this.cronManager;
|
||||||
@ -200,6 +241,32 @@ public class Hebdobot extends PircBot
|
|||||||
return this.cronSettings;
|
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.
|
* Gets the home directory.
|
||||||
*
|
*
|
||||||
@ -250,11 +317,6 @@ public class Hebdobot extends PircBot
|
|||||||
return this.reviewWaitTime;
|
return this.reviewWaitTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Timekeeper getTimekeeper()
|
|
||||||
{
|
|
||||||
return this.timekeeper;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the twitter settings.
|
* Gets the twitter settings.
|
||||||
*
|
*
|
||||||
@ -331,7 +393,7 @@ public class Hebdobot extends PircBot
|
|||||||
this.review.addRaw(new Message(sender, text));
|
this.review.addRaw(new Message(sender, text));
|
||||||
}
|
}
|
||||||
|
|
||||||
text = message.replaceAll("^" + getName().replace("[", "\\[").replaceAll("]", "\\]") + "[,:]\\s*", "!");
|
text = text.replaceAll("^" + getName().replace("[", "\\[").replaceAll("]", "\\]") + "[,:]\\s*", "!");
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -355,36 +417,12 @@ public class Hebdobot extends PircBot
|
|||||||
|
|
||||||
String text = message.trim();
|
String text = message.trim();
|
||||||
|
|
||||||
if (StringUtils.equalsIgnoreCase(text, "!vaten"))
|
if (text.startsWith("!"))
|
||||||
{
|
|
||||||
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.");
|
logger.info("!??? caught.");
|
||||||
|
|
||||||
// Command unknown.
|
// Command unknown.
|
||||||
sendMessage(sender + ", command unknown: " + text);
|
sendMessage(sender, "vos commandes dans le salon public");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -400,6 +438,7 @@ public class Hebdobot extends PircBot
|
|||||||
*/
|
*/
|
||||||
public void run() throws HebdobotException
|
public void run() throws HebdobotException
|
||||||
{
|
{
|
||||||
|
//
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
logger.info("Cron initializing.");
|
logger.info("Cron initializing.");
|
||||||
@ -408,11 +447,46 @@ public class Hebdobot extends PircBot
|
|||||||
this.cronManager.start();
|
this.cronManager.start();
|
||||||
}
|
}
|
||||||
logger.info("Cron initialized.");
|
logger.info("Cron initialized.");
|
||||||
|
}
|
||||||
|
catch (SchedulerException | ParseException exception)
|
||||||
|
{
|
||||||
|
throw new HebdobotException("Error in cron settings.", exception);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Manage "Caused by: java.net.UnknownHostException: irc.freenode.org".
|
||||||
|
boolean ended = false;
|
||||||
|
while (!ended)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
logger.info("Bot connection.");
|
logger.info("Bot connection.");
|
||||||
this.connect(this.host, this.port);
|
this.connect(this.host, this.port);
|
||||||
logger.info("Bot connected.");
|
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)
|
if (this.identifyPassword == null)
|
||||||
{
|
{
|
||||||
logger.info("Skipped identify.");
|
logger.info("Skipped identify.");
|
||||||
@ -428,25 +502,26 @@ public class Hebdobot extends PircBot
|
|||||||
this.joinChannel(this.channel);
|
this.joinChannel(this.channel);
|
||||||
logger.info("Bot ready.");
|
logger.info("Bot ready.");
|
||||||
}
|
}
|
||||||
catch (NickAlreadyInUseException exception)
|
|
||||||
|
/**
|
||||||
|
* Send chrono message.
|
||||||
|
*/
|
||||||
|
public void sendChronoMessage()
|
||||||
{
|
{
|
||||||
throw new HebdobotException(exception);
|
if (this.review == null)
|
||||||
|
{
|
||||||
|
sendMessage("% durée du point : pas de revue en cours.");
|
||||||
}
|
}
|
||||||
catch (IOException exception)
|
else if (this.review.isEmpty())
|
||||||
{
|
{
|
||||||
throw new HebdobotException(exception);
|
sendMessage("% durée du point : pas de point en cours.");
|
||||||
}
|
}
|
||||||
catch (IrcException exception)
|
else
|
||||||
{
|
{
|
||||||
throw new HebdobotException(exception);
|
String topicTitle = this.review.getCurrentTopic().getTitle();
|
||||||
}
|
String chronoValue = this.chrono.toString();
|
||||||
catch (SchedulerException exception)
|
|
||||||
{
|
sendMessage(String.format("%% durée du point %s : %s", topicTitle, chronoValue));
|
||||||
throw new HebdobotException("Error in cron settings.", exception);
|
|
||||||
}
|
|
||||||
catch (ParseException exception)
|
|
||||||
{
|
|
||||||
throw new HebdobotException(exception);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -496,4 +571,13 @@ public class Hebdobot extends PircBot
|
|||||||
{
|
{
|
||||||
this.reviewWaitTime = reviewWaitTime;
|
this.reviewWaitTime = reviewWaitTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stop review.
|
||||||
|
*/
|
||||||
|
public void stopReview()
|
||||||
|
{
|
||||||
|
setReview(null);
|
||||||
|
this.chrono.reset();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
103
src/org/april/hebdobot/bot/hooks/AnnivHook.java
Normal file
103
src/org/april/hebdobot/bot/hooks/AnnivHook.java
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (C) 2021 Christian Pierre MOMON <cmomon@april.org>
|
||||||
|
*
|
||||||
|
* This file is part of (April) Hebdobot.
|
||||||
|
*
|
||||||
|
* Hebdobot is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Hebdobot is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with Hebdobot. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*/
|
||||||
|
package org.april.hebdobot.bot.hooks;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.Period;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.april.hebdobot.HebdobotException;
|
||||||
|
import org.april.hebdobot.bot.Hebdobot;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import fr.devinsy.strings.StringList;
|
||||||
|
import fr.devinsy.strings.StringsUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Class AnnivHook.
|
||||||
|
*/
|
||||||
|
public class AnnivHook extends Hook
|
||||||
|
{
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(AnnivHook.class);
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.april.hebdobot.bot.hooks.Hook#attemptHelp(java.lang.String)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public StringList attemptHelp(final String token) throws HebdobotException
|
||||||
|
{
|
||||||
|
StringList result;
|
||||||
|
|
||||||
|
if (StringsUtils.equalsAnyIgnoreCase(token, "anniv"))
|
||||||
|
{
|
||||||
|
result = new StringList("!anniv : afficher des anniversaires");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.april.hebdobot.bot.hooks.Hook#attemptProcess(org.april.hebdobot.bot.Hebdobot, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean attemptProcess(final Hebdobot bot, final String channel, final String sender, final String login, final String hostname,
|
||||||
|
final String message)
|
||||||
|
{
|
||||||
|
boolean result;
|
||||||
|
|
||||||
|
if (StringUtils.equalsAnyIgnoreCase(message, "!anniv"))
|
||||||
|
{
|
||||||
|
logger.info("!anniv caught.");
|
||||||
|
|
||||||
|
LocalDate now = LocalDate.now();
|
||||||
|
LocalDate revueBirthdate = LocalDate.of(2010, 04, 30);
|
||||||
|
String birthdate = revueBirthdate.format(DateTimeFormatter.ofPattern("EEEE dd MMMM yyyy", Locale.FRENCH));
|
||||||
|
int years = Period.between(revueBirthdate, now).getYears();
|
||||||
|
|
||||||
|
bot.sendMessage(String.format("La revue hebdomadaire est née le %s et a %d ans", birthdate, years));
|
||||||
|
|
||||||
|
LocalDate hebdobotBirthdate = LocalDate.of(2011, 9, 9);
|
||||||
|
years = Period.between(hebdobotBirthdate, now).getYears();
|
||||||
|
birthdate = hebdobotBirthdate.format(DateTimeFormatter.ofPattern("EEEE dd MMMM yyyy", Locale.FRENCH));
|
||||||
|
bot.sendMessage(String.format("Hebdobot a géré sa première revue le %s et a %d ans", birthdate, years));
|
||||||
|
|
||||||
|
LocalDate aprilBirthdate = LocalDate.of(1996, 11, 20);
|
||||||
|
birthdate = aprilBirthdate.format(DateTimeFormatter.ofPattern("EEEE dd MMMM yyyy", Locale.FRENCH));
|
||||||
|
years = Period.between(aprilBirthdate, now).getYears();
|
||||||
|
bot.sendMessage(String.format("L'April a été déclarée en préférecture le %s et a %d ans", birthdate, years));
|
||||||
|
|
||||||
|
result = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (C) 2018 Christian Pierre MOMON <cmomon@april.org>
|
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||||
*
|
*
|
||||||
* This file is part of (April) Hebdobot.
|
* This file is part of (April) Hebdobot.
|
||||||
*
|
*
|
||||||
@ -18,10 +18,13 @@
|
|||||||
*/
|
*/
|
||||||
package org.april.hebdobot.bot.hooks;
|
package org.april.hebdobot.bot.hooks;
|
||||||
|
|
||||||
|
import org.april.hebdobot.HebdobotException;
|
||||||
import org.april.hebdobot.bot.Hebdobot;
|
import org.april.hebdobot.bot.Hebdobot;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import fr.devinsy.strings.StringList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class DefaultHook.
|
* The Class DefaultHook.
|
||||||
*/
|
*/
|
||||||
@ -29,6 +32,15 @@ public class BadCommandHook extends Hook
|
|||||||
{
|
{
|
||||||
private static final Logger logger = LoggerFactory.getLogger(BadCommandHook.class);
|
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)
|
/* (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)
|
* @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,12 +18,15 @@
|
|||||||
*/
|
*/
|
||||||
package org.april.hebdobot.bot.hooks;
|
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.Hebdobot;
|
||||||
import org.april.hebdobot.bot.review.Topic;
|
import org.april.hebdobot.bot.review.Topic;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import fr.devinsy.strings.StringList;
|
||||||
|
import fr.devinsy.strings.StringsUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class CancelPreviousInputHook.
|
* The Class CancelPreviousInputHook.
|
||||||
*/
|
*/
|
||||||
@ -31,6 +34,27 @@ public class CancelPreviousInputHook extends Hook
|
|||||||
{
|
{
|
||||||
private static final Logger logger = LoggerFactory.getLogger(CancelPreviousInputHook.class);
|
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)
|
/* (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)
|
* @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)
|
||||||
*/
|
*/
|
||||||
@ -40,9 +64,9 @@ public class CancelPreviousInputHook extends Hook
|
|||||||
{
|
{
|
||||||
boolean result;
|
boolean result;
|
||||||
|
|
||||||
if (StringUtils.equalsIgnoreCase(message, "!cancelprevious"))
|
if (StringsUtils.equalsAnyIgnoreCase(message, "!cancelprevious", "!oops", "!oups"))
|
||||||
{
|
{
|
||||||
logger.info("!cancelprevious caught.");
|
logger.info("!cancelprevious/!oops caught.");
|
||||||
|
|
||||||
// Missing.
|
// Missing.
|
||||||
if (bot.getReview() == null)
|
if (bot.getReview() == null)
|
||||||
@ -58,13 +82,14 @@ public class CancelPreviousInputHook extends Hook
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (bot.getReview().getParticipants().contains(sender))
|
String previousMessage = topic.cancelPreviousMessage(sender);
|
||||||
|
if (previousMessage == null)
|
||||||
{
|
{
|
||||||
topic.cancelPreviousMessage(sender);
|
bot.sendMessage(sender + ", vous n'avez pas d'entrée en cours.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bot.sendMessage("Vous n'avez pas d'entrée en cours.");
|
bot.sendMessage(sender + ", suppression de votre précédente entrée : " + previousMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
83
src/org/april/hebdobot/bot/hooks/ChronoHook.java
Normal file
83
src/org/april/hebdobot/bot/hooks/ChronoHook.java
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
/**
|
||||||
|
* 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 Christian Pierre MOMON <cmomon@april.org>
|
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||||
*
|
*
|
||||||
* This file is part of (April) Hebdobot.
|
* This file is part of (April) Hebdobot.
|
||||||
*
|
*
|
||||||
@ -19,11 +19,15 @@
|
|||||||
package org.april.hebdobot.bot.hooks;
|
package org.april.hebdobot.bot.hooks;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.april.hebdobot.HebdobotException;
|
||||||
import org.april.hebdobot.bot.Hebdobot;
|
import org.april.hebdobot.bot.Hebdobot;
|
||||||
import org.april.hebdobot.bot.review.CollectiveTopic;
|
import org.april.hebdobot.bot.review.CollectiveTopic;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import fr.devinsy.strings.StringList;
|
||||||
|
import fr.devinsy.strings.StringsUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class CollectiveSubjectHook.
|
* The Class CollectiveSubjectHook.
|
||||||
*/
|
*/
|
||||||
@ -31,6 +35,27 @@ public class CollectiveSubjectHook extends Hook
|
|||||||
{
|
{
|
||||||
private static final Logger logger = LoggerFactory.getLogger(CollectiveSubjectHook.class);
|
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)
|
/* (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)
|
* @see org.april.hebdobot.bot.hooks.Hook#attemptProcess(org.april.hebdobot.bot.Hebdobot, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
|
||||||
*/
|
*/
|
||||||
@ -52,16 +77,17 @@ public class CollectiveSubjectHook extends Hook
|
|||||||
CollectiveTopic topic = new CollectiveTopic(message.replaceFirst("##", "").trim());
|
CollectiveTopic topic = new CollectiveTopic(message.replaceFirst("##", "").trim());
|
||||||
if (!bot.getReview().isEmpty())
|
if (!bot.getReview().isEmpty())
|
||||||
{
|
{
|
||||||
|
bot.sendChronoMessage();
|
||||||
|
|
||||||
String participants = StringUtils.join(bot.getReview().getParticipants(), " ");
|
String participants = StringUtils.join(bot.getReview().getParticipants(), " ");
|
||||||
bot.sendMessage(String.format("%% %s %s, on va passer à la suite : %s", bot.getTimekeeper().format(), participants,
|
bot.sendMessage(String.format("%% %s, on va passer à la suite : %s", participants, topic.getTitle()));
|
||||||
topic.getTitle()));
|
|
||||||
}
|
}
|
||||||
bot.getReview().begin(topic);
|
bot.getReview().begin(topic);
|
||||||
bot.sendMessage("Sujet collectif : " + topic.getTitle());
|
bot.sendMessage("Sujet collectif : " + topic.getTitle());
|
||||||
bot.sendMessage("% 1 minute max");
|
bot.sendMessage("% 1 minute max");
|
||||||
bot.sendMessage("% si rien à signaler vous pouvez écrire % ras");
|
bot.sendMessage("% si rien à signaler vous pouvez écrire % ras");
|
||||||
bot.sendMessage("% quand vous avez fini vous le dites par % fini");
|
bot.sendMessage("% quand vous avez fini vous le dites par % fini");
|
||||||
bot.getTimekeeper().start();
|
bot.getChrono().start();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (C) 2018 Christian Pierre MOMON <cmomon@april.org>
|
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||||
*
|
*
|
||||||
* This file is part of (April) Hebdobot.
|
* This file is part of (April) Hebdobot.
|
||||||
*
|
*
|
||||||
@ -18,10 +18,14 @@
|
|||||||
*/
|
*/
|
||||||
package org.april.hebdobot.bot.hooks;
|
package org.april.hebdobot.bot.hooks;
|
||||||
|
|
||||||
|
import org.april.hebdobot.HebdobotException;
|
||||||
import org.april.hebdobot.bot.Hebdobot;
|
import org.april.hebdobot.bot.Hebdobot;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import fr.devinsy.strings.StringList;
|
||||||
|
import fr.devinsy.strings.StringsUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class CommentHook.
|
* The Class CommentHook.
|
||||||
*/
|
*/
|
||||||
@ -29,6 +33,27 @@ public class CommentHook extends Hook
|
|||||||
{
|
{
|
||||||
private static final Logger logger = LoggerFactory.getLogger(CommentHook.class);
|
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)
|
/* (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)
|
* @see org.april.hebdobot.bot.hooks.Hook#attemptProcess(org.april.hebdobot.bot.Hebdobot, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
|
||||||
*/
|
*/
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (C) 2018-2019 Christian Pierre MOMON <cmomon@april.org>
|
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||||
*
|
*
|
||||||
* This file is part of (April) Hebdobot.
|
* This file is part of (April) Hebdobot.
|
||||||
*
|
*
|
||||||
@ -19,6 +19,7 @@
|
|||||||
package org.april.hebdobot.bot.hooks;
|
package org.april.hebdobot.bot.hooks;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.april.hebdobot.HebdobotException;
|
||||||
import org.april.hebdobot.bot.Hebdobot;
|
import org.april.hebdobot.bot.Hebdobot;
|
||||||
import org.april.hebdobot.bot.review.CollectiveTopic;
|
import org.april.hebdobot.bot.review.CollectiveTopic;
|
||||||
import org.april.hebdobot.bot.review.IndividualTopic;
|
import org.april.hebdobot.bot.review.IndividualTopic;
|
||||||
@ -26,6 +27,9 @@ import org.april.hebdobot.bot.review.Topic;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import fr.devinsy.strings.StringList;
|
||||||
|
import fr.devinsy.strings.StringsUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class CurrentHook.
|
* The Class CurrentHook.
|
||||||
*/
|
*/
|
||||||
@ -33,6 +37,27 @@ public class CurrentHook extends Hook
|
|||||||
{
|
{
|
||||||
private static final Logger logger = LoggerFactory.getLogger(CurrentHook.class);
|
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)
|
/* (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)
|
* @see org.april.hebdobot.bot.hooks.Hook#attemptProcess(org.april.hebdobot.bot.Hebdobot, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
|
||||||
*/
|
*/
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (C) 2018 Christian Pierre MOMON <cmomon@april.org>
|
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||||
*
|
*
|
||||||
* This file is part of (April) Hebdobot.
|
* This file is part of (April) Hebdobot.
|
||||||
*
|
*
|
||||||
@ -23,10 +23,14 @@ import java.time.format.DateTimeFormatter;
|
|||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.april.hebdobot.HebdobotException;
|
||||||
import org.april.hebdobot.bot.Hebdobot;
|
import org.april.hebdobot.bot.Hebdobot;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import fr.devinsy.strings.StringList;
|
||||||
|
import fr.devinsy.strings.StringsUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class DateHook.
|
* The Class DateHook.
|
||||||
*/
|
*/
|
||||||
@ -34,6 +38,27 @@ public class DateHook extends Hook
|
|||||||
{
|
{
|
||||||
private static final Logger logger = LoggerFactory.getLogger(DateHook.class);
|
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)
|
/* (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)
|
* @see org.april.hebdobot.bot.hooks.Hook#attemptProcess(org.april.hebdobot.bot.Hebdobot, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
|
||||||
*/
|
*/
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (C) 2018 Christian Pierre MOMON <cmomon@april.org>
|
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||||
*
|
*
|
||||||
* This file is part of (April) Hebdobot.
|
* This file is part of (April) Hebdobot.
|
||||||
*
|
*
|
||||||
@ -18,10 +18,13 @@
|
|||||||
*/
|
*/
|
||||||
package org.april.hebdobot.bot.hooks;
|
package org.april.hebdobot.bot.hooks;
|
||||||
|
|
||||||
|
import org.april.hebdobot.HebdobotException;
|
||||||
import org.april.hebdobot.bot.Hebdobot;
|
import org.april.hebdobot.bot.Hebdobot;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import fr.devinsy.strings.StringList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class DefaultHook.
|
* The Class DefaultHook.
|
||||||
*/
|
*/
|
||||||
@ -29,6 +32,20 @@ public class DefaultHook extends Hook
|
|||||||
{
|
{
|
||||||
private static final Logger logger = LoggerFactory.getLogger(DefaultHook.class);
|
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)
|
/* (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)
|
* @see org.april.hebdobot.bot.hooks.Hook#attemptProcess(org.april.hebdobot.bot.Hebdobot, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
|
||||||
*/
|
*/
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (C) 2018-2019 Christian Pierre MOMON <cmomon@april.org>
|
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||||
*
|
*
|
||||||
* This file is part of (April) Hebdobot.
|
* This file is part of (April) Hebdobot.
|
||||||
*
|
*
|
||||||
@ -27,6 +27,7 @@ import java.time.format.DateTimeFormatter;
|
|||||||
|
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.april.hebdobot.HebdobotException;
|
||||||
import org.april.hebdobot.bot.Hebdobot;
|
import org.april.hebdobot.bot.Hebdobot;
|
||||||
import org.april.hebdobot.bot.review.ReviewReporter;
|
import org.april.hebdobot.bot.review.ReviewReporter;
|
||||||
import org.april.hebdobot.bot.stats.ReviewData;
|
import org.april.hebdobot.bot.stats.ReviewData;
|
||||||
@ -37,6 +38,9 @@ import org.april.hebdobot.privatebin.PrivatebinClient;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import fr.devinsy.strings.StringList;
|
||||||
|
import fr.devinsy.strings.StringsUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class FinishReviewHook.
|
* The Class FinishReviewHook.
|
||||||
*/
|
*/
|
||||||
@ -46,6 +50,27 @@ public class FinishReviewHook extends Hook
|
|||||||
|
|
||||||
public static String DEFAULT_SUFFIX = "-log-irc-revue-hebdomadaire.txt";
|
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)
|
/* (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)
|
* @see org.april.hebdobot.bot.hooks.Hook#attemptProcess(org.april.hebdobot.bot.Hebdobot, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
|
||||||
*/
|
*/
|
||||||
@ -80,9 +105,8 @@ public class FinishReviewHook extends Hook
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// End the review.
|
// End the review.
|
||||||
bot.getReview().endReview();
|
bot.sendChronoMessage();
|
||||||
|
bot.endReview();
|
||||||
bot.sendMessage("%% +%01d:%02d", bot.getTimekeeper().format());
|
|
||||||
|
|
||||||
// Load and update review statistics.
|
// Load and update review statistics.
|
||||||
ReviewDatas datas;
|
ReviewDatas datas;
|
||||||
@ -159,12 +183,13 @@ public class FinishReviewHook extends Hook
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Send conclusion message in channel.
|
// Send conclusion message in channel.
|
||||||
bot.sendMessage("% " + ReviewStatsReporter.reportReviewCount(datas));
|
bot.checkReviewAnniversary();
|
||||||
|
bot.sendMessage("% " + ReviewStatsReporter.reportCurrentReviewCount(datas));
|
||||||
bot.sendMessage("% Compte-rendu de la revue : " + pastebinUrl);
|
bot.sendMessage("% Compte-rendu de la revue : " + pastebinUrl);
|
||||||
bot.sendMessage("% Durée de la revue : " + bot.getReview().getDurationInMinutes() + " minutes");
|
bot.sendMessage("% Durée de la revue : " + bot.getReview().getDurationInMinutes() + " minutes");
|
||||||
bot.sendMessage("% Nombre de personnes participantes : " + bot.getReview().getParticipants().size());
|
bot.sendMessage("% Nombre de personnes participantes : " + bot.getReview().getParticipants().size());
|
||||||
|
|
||||||
bot.sendMessage("% " + ReviewStatsReporter.reportNewUserCountRecord(datas));
|
bot.sendMessage("% " + ReviewStatsReporter.reportCheckUserCountRecord(datas));
|
||||||
bot.sendMessage(bot.getReview().getOwner(), ReviewStatsReporter.reportUserCount(datas, bot.getReview().getParticipants().size()));
|
bot.sendMessage(bot.getReview().getOwner(), ReviewStatsReporter.reportUserCount(datas, bot.getReview().getParticipants().size()));
|
||||||
bot.sendMessage(bot.getReview().getOwner(), ReviewStatsReporter.reportDuration(datas, bot.getReview().getDurationInMinutes()));
|
bot.sendMessage(bot.getReview().getOwner(), ReviewStatsReporter.reportDuration(datas, bot.getReview().getDurationInMinutes()));
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (C) 2018 Christian Pierre MOMON <cmomon@april.org>
|
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||||
*
|
*
|
||||||
* This file is part of (April) Hebdobot.
|
* This file is part of (April) Hebdobot.
|
||||||
*
|
*
|
||||||
@ -19,10 +19,12 @@
|
|||||||
package org.april.hebdobot.bot.hooks;
|
package org.april.hebdobot.bot.hooks;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.april.hebdobot.HebdobotException;
|
||||||
import org.april.hebdobot.bot.Hebdobot;
|
import org.april.hebdobot.bot.Hebdobot;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import fr.devinsy.strings.StringList;
|
||||||
import fr.devinsy.strings.StringsUtils;
|
import fr.devinsy.strings.StringsUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -32,6 +34,27 @@ public class HelloHook extends Hook
|
|||||||
{
|
{
|
||||||
private static final Logger logger = LoggerFactory.getLogger(HelloHook.class);
|
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)
|
/* (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)
|
* @see org.april.hebdobot.bot.hooks.Hook#attemptProcess(org.april.hebdobot.bot.Hebdobot, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
|
||||||
*/
|
*/
|
||||||
|
@ -1,110 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (C) 2018 Christian Pierre MOMON <cmomon@april.org>
|
|
||||||
*
|
|
||||||
* This file is part of (April) Hebdobot.
|
|
||||||
*
|
|
||||||
* Hebdobot is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Hebdobot is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with Hebdobot. If not, see <http://www.gnu.org/licenses/>
|
|
||||||
*/
|
|
||||||
package org.april.hebdobot.bot.hooks;
|
|
||||||
|
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.april.hebdobot.bot.Hebdobot;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The Class HelpByCommandHook.
|
|
||||||
*/
|
|
||||||
public class HelpByCommandHook extends Hook
|
|
||||||
{
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(HelpByCommandHook.class);
|
|
||||||
|
|
||||||
private static final Pattern PATTERN = Pattern.compile("^!help\\s+(\\S+)$");
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.april.hebdobot.bot.hooks.Hook#attemptProcess(org.april.hebdobot.bot.Hebdobot, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean attemptProcess(final Hebdobot bot, final String channel, final String sender, final String login, final String hostname,
|
|
||||||
final String message)
|
|
||||||
{
|
|
||||||
boolean result;
|
|
||||||
|
|
||||||
Matcher matcher = PATTERN.matcher(message);
|
|
||||||
|
|
||||||
if (matcher.find())
|
|
||||||
{
|
|
||||||
String command = matcher.group(1);
|
|
||||||
|
|
||||||
if (StringUtils.equals(command, "help"))
|
|
||||||
{
|
|
||||||
bot.sendMessage(sender + ": help display help commands");
|
|
||||||
bot.sendMessage(sender + ": help command display help on specific command");
|
|
||||||
}
|
|
||||||
else if (StringUtils.equals(command, "ignore"))
|
|
||||||
{
|
|
||||||
bot.sendMessage(sender + ": ignore host:service ignore a specific probe");
|
|
||||||
bot.sendMessage(sender + ": ignore list ignore probes");
|
|
||||||
}
|
|
||||||
else if (StringUtils.equals(command, "unignore"))
|
|
||||||
{
|
|
||||||
bot.sendMessage(sender + ": unignore host:service ignore a specific probe");
|
|
||||||
}
|
|
||||||
else if (StringUtils.equals(command, "ack"))
|
|
||||||
{
|
|
||||||
bot.sendMessage(sender + ": ack unack an alert");
|
|
||||||
}
|
|
||||||
else if (StringUtils.equals(command, "unack"))
|
|
||||||
{
|
|
||||||
bot.sendMessage(sender + ": unack unack an alert");
|
|
||||||
}
|
|
||||||
else if (StringUtils.equalsAnyIgnoreCase(command, "!mute", "!tagueule", "!ta gueule", "!chut", "!sieste"))
|
|
||||||
{
|
|
||||||
bot.sendMessage(sender + ": mute|tagueule|chut|sieste mute alert display");
|
|
||||||
}
|
|
||||||
else if (StringUtils.equalsAnyIgnoreCase(command, "!unmute"))
|
|
||||||
{
|
|
||||||
bot.sendMessage(sender + ": unmute mute alert display");
|
|
||||||
}
|
|
||||||
else if (StringUtils.equals(command, "list"))
|
|
||||||
{
|
|
||||||
bot.sendMessage(sender + ": list display current alerts");
|
|
||||||
}
|
|
||||||
else if (StringUtils.equals(command, "refresh"))
|
|
||||||
{
|
|
||||||
bot.sendMessage(sender + ": refresh update alert list");
|
|
||||||
}
|
|
||||||
else if (StringUtils.equals(command, "recheck"))
|
|
||||||
{
|
|
||||||
bot.sendMessage(sender + ": recheck reschedule current alerts");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
bot.sendMessage(sender + ": no help available for this command");
|
|
||||||
}
|
|
||||||
|
|
||||||
result = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
result = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (C) 2018 Christian Pierre MOMON <cmomon@april.org>
|
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||||
*
|
*
|
||||||
* This file is part of (April) Hebdobot.
|
* This file is part of (April) Hebdobot.
|
||||||
*
|
*
|
||||||
@ -18,60 +18,141 @@
|
|||||||
*/
|
*/
|
||||||
package org.april.hebdobot.bot.hooks;
|
package org.april.hebdobot.bot.hooks;
|
||||||
|
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.april.hebdobot.HebdobotException;
|
||||||
import org.april.hebdobot.bot.Hebdobot;
|
import org.april.hebdobot.bot.Hebdobot;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import fr.devinsy.strings.StringList;
|
||||||
|
import fr.devinsy.strings.StringsUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class HelpHook.
|
* The Class HelpHook.
|
||||||
*/
|
*/
|
||||||
public class HelpHook extends Hook
|
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);
|
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)
|
/* (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)
|
* @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
|
@Override
|
||||||
public boolean attemptProcess(final Hebdobot bot, final String channel, final String sender, final String login, final String hostname,
|
public boolean attemptProcess(final Hebdobot bot, final String channel, final String sender, final String login, final String hostname,
|
||||||
final String message)
|
final String message) throws HebdobotException
|
||||||
{
|
{
|
||||||
boolean result;
|
boolean result;
|
||||||
|
|
||||||
if (StringUtils.equalsAnyIgnoreCase(message, "!aide", "!help"))
|
if (StringUtils.equalsAnyIgnoreCase(message, "!aide", "!help", "!aide hebdobot", "!help hebdobot"))
|
||||||
{
|
{
|
||||||
logger.info("!help caught.");
|
logger.info("!help caught.");
|
||||||
|
|
||||||
// Help.
|
// Help.
|
||||||
bot.sendMessage(sender, "Bienvenue " + sender);
|
bot.sendMessage(sender,
|
||||||
bot.sendMessage(sender, "Je suis " + bot.getName() + ", le robot de gestion des revues hebdomadaires de l'APRIL.");
|
String.format("Bienvenue %s. Je suis %s, le robot de gestion des revues hebdomadaires de l'April.", sender, bot.getName()));
|
||||||
bot.sendMessage(sender, "Voici les commandes que je comprends :");
|
bot.sendMessage(sender, "Voici les commandes que je comprends :");
|
||||||
bot.sendMessage(sender, " ");
|
bot.sendMessage(sender, " ");
|
||||||
bot.sendMessage(sender, " !aide,!help : afficher cette aide");
|
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, " !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 individuel");
|
||||||
bot.sendMessage(sender, " ## titre : démarrer un sujet collectif");
|
bot.sendMessage(sender, " ## titre : démarrer un sujet collectif");
|
||||||
bot.sendMessage(sender, " % message : traiter comme un commentaire");
|
bot.sendMessage(sender, " !oups : annuler la dernière entrée dans un point de revue");
|
||||||
bot.sendMessage(sender, " !courant : afficher le sujet en cours");
|
bot.sendMessage(sender, " !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, " !fin : terminer la revue en cours");
|
||||||
bot.sendMessage(sender, " !stop : abandonner 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, " ");
|
||||||
bot.sendMessage(sender, "Autres commandes de dialogue : !bonjour, !date, !hello, !merci, !salut");
|
bot.sendMessage(sender,
|
||||||
|
"Autres commandes : !anniv, !bonjour, !chrono, !date, !hello, !licence, !manquants, !merci, !record, !salut, !stats, !status, !version");
|
||||||
|
|
||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
String token = extractTargetHelp(message);
|
||||||
|
|
||||||
|
if (token == null)
|
||||||
{
|
{
|
||||||
result = false;
|
result = false;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
StringList help = bot.getHelp(token);
|
||||||
|
if (help == null)
|
||||||
|
{
|
||||||
|
bot.sendMessage("aide indisponible pour la commande " + token);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (String line : help)
|
||||||
|
{
|
||||||
|
bot.sendMessage(line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
result = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract target help.
|
||||||
|
*
|
||||||
|
* @return the string
|
||||||
|
*/
|
||||||
|
private String extractTargetHelp(final String message)
|
||||||
|
{
|
||||||
|
String result;
|
||||||
|
|
||||||
|
Matcher matcher = COMMAND_HELP_PATTERN.matcher(message);
|
||||||
|
if (matcher.find())
|
||||||
|
{
|
||||||
|
result = matcher.group("token");
|
||||||
|
|
||||||
|
if (StringUtils.startsWith(result, "!"))
|
||||||
|
{
|
||||||
|
result = result.substring(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (C) 2018 Christian Pierre MOMON <cmomon@april.org>
|
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||||
*
|
*
|
||||||
* This file is part of (April) Hebdobot.
|
* This file is part of (April) Hebdobot.
|
||||||
*
|
*
|
||||||
@ -21,11 +21,23 @@ package org.april.hebdobot.bot.hooks;
|
|||||||
import org.april.hebdobot.HebdobotException;
|
import org.april.hebdobot.HebdobotException;
|
||||||
import org.april.hebdobot.bot.Hebdobot;
|
import org.april.hebdobot.bot.Hebdobot;
|
||||||
|
|
||||||
|
import fr.devinsy.strings.StringList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class Hook.
|
* The Class Hook.
|
||||||
*/
|
*/
|
||||||
public abstract 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.
|
* Attempt process.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (C) 2018-2019 Christian Pierre MOMON <cmomon@april.org>
|
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||||
*
|
*
|
||||||
* This file is part of (April) Hebdobot.
|
* This file is part of (April) Hebdobot.
|
||||||
*
|
*
|
||||||
@ -29,18 +29,18 @@ import org.slf4j.LoggerFactory;
|
|||||||
import fr.devinsy.strings.StringList;
|
import fr.devinsy.strings.StringList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Interface MessageHook.
|
* The class Hooker, a hook manager.
|
||||||
*/
|
*/
|
||||||
public class HookManager
|
public class Hooker
|
||||||
{
|
{
|
||||||
private static final Logger logger = LoggerFactory.getLogger(HookManager.class);
|
private static final Logger logger = LoggerFactory.getLogger(Hooker.class);
|
||||||
|
|
||||||
private ArrayList<Hook> hooks;
|
private ArrayList<Hook> hooks;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new hook manager.
|
* Instantiates a new hook manager.
|
||||||
*/
|
*/
|
||||||
public HookManager()
|
public Hooker()
|
||||||
{
|
{
|
||||||
this.hooks = new ArrayList<>(30);
|
this.hooks = new ArrayList<>(30);
|
||||||
}
|
}
|
||||||
@ -59,6 +59,46 @@ public class HookManager
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
* Attempt process.
|
||||||
*
|
*
|
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (C) 2018 Christian Pierre MOMON <cmomon@april.org>
|
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||||
*
|
*
|
||||||
* This file is part of (April) Hebdobot.
|
* This file is part of (April) Hebdobot.
|
||||||
*
|
*
|
||||||
@ -19,11 +19,15 @@
|
|||||||
package org.april.hebdobot.bot.hooks;
|
package org.april.hebdobot.bot.hooks;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.april.hebdobot.HebdobotException;
|
||||||
import org.april.hebdobot.bot.Hebdobot;
|
import org.april.hebdobot.bot.Hebdobot;
|
||||||
import org.april.hebdobot.bot.review.IndividualTopic;
|
import org.april.hebdobot.bot.review.IndividualTopic;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import fr.devinsy.strings.StringList;
|
||||||
|
import fr.devinsy.strings.StringsUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class IndividualSubjectHook.
|
* The Class IndividualSubjectHook.
|
||||||
*/
|
*/
|
||||||
@ -31,6 +35,27 @@ public class IndividualSubjectHook extends Hook
|
|||||||
{
|
{
|
||||||
private static final Logger logger = LoggerFactory.getLogger(IndividualSubjectHook.class);
|
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)
|
/* (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)
|
* @see org.april.hebdobot.bot.hooks.Hook#attemptProcess(org.april.hebdobot.bot.Hebdobot, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
|
||||||
*/
|
*/
|
||||||
@ -52,15 +77,16 @@ public class IndividualSubjectHook extends Hook
|
|||||||
IndividualTopic topic = new IndividualTopic(message.replaceFirst("#", "").trim());
|
IndividualTopic topic = new IndividualTopic(message.replaceFirst("#", "").trim());
|
||||||
if (!bot.getReview().isEmpty())
|
if (!bot.getReview().isEmpty())
|
||||||
{
|
{
|
||||||
|
bot.sendChronoMessage();
|
||||||
|
|
||||||
String participants = StringUtils.join(bot.getReview().getParticipants(), " ");
|
String participants = StringUtils.join(bot.getReview().getParticipants(), " ");
|
||||||
bot.sendMessage(String.format("%% %s %s, on va passer à la suite : %s", bot.getTimekeeper().format(), participants,
|
bot.sendMessage(String.format("%% %s, on va passer à la suite : %s", participants, topic.getTitle()));
|
||||||
topic.getTitle()));
|
|
||||||
}
|
}
|
||||||
bot.getReview().begin(topic);
|
bot.getReview().begin(topic);
|
||||||
bot.sendMessage("Sujet individuel : " + topic.getTitle());
|
bot.sendMessage("Sujet individuel : " + topic.getTitle());
|
||||||
bot.sendMessage("% si rien à signaler vous pouvez écrire % ras");
|
bot.sendMessage("% si rien à signaler vous pouvez écrire % ras");
|
||||||
bot.sendMessage("% quand vous avez fini vous le dites par % fini");
|
bot.sendMessage("% quand vous avez fini vous le dites par % fini");
|
||||||
bot.getTimekeeper().start();
|
bot.getChrono().start();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (C) 2018 Christian Pierre MOMON <cmomon@april.org>
|
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||||
*
|
*
|
||||||
* This file is part of (April) Hebdobot.
|
* This file is part of (April) Hebdobot.
|
||||||
*
|
*
|
||||||
@ -18,11 +18,14 @@
|
|||||||
*/
|
*/
|
||||||
package org.april.hebdobot.bot.hooks;
|
package org.april.hebdobot.bot.hooks;
|
||||||
|
|
||||||
|
import org.april.hebdobot.HebdobotException;
|
||||||
import org.april.hebdobot.bot.Hebdobot;
|
import org.april.hebdobot.bot.Hebdobot;
|
||||||
import org.april.hebdobot.bot.review.Message;
|
import org.april.hebdobot.bot.review.Message;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import fr.devinsy.strings.StringList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class DefaultHook.
|
* The Class DefaultHook.
|
||||||
*/
|
*/
|
||||||
@ -30,6 +33,20 @@ public class InputReviewHook extends Hook
|
|||||||
{
|
{
|
||||||
private static final Logger logger = LoggerFactory.getLogger(InputReviewHook.class);
|
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)
|
/* (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)
|
* @see org.april.hebdobot.bot.hooks.Hook#attemptProcess(org.april.hebdobot.bot.Hebdobot, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
|
||||||
*/
|
*/
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (C) 2018 Christian Pierre MOMON <cmomon@april.org>
|
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||||
*
|
*
|
||||||
* This file is part of (April) Hebdobot.
|
* This file is part of (April) Hebdobot.
|
||||||
*
|
*
|
||||||
@ -18,10 +18,12 @@
|
|||||||
*/
|
*/
|
||||||
package org.april.hebdobot.bot.hooks;
|
package org.april.hebdobot.bot.hooks;
|
||||||
|
|
||||||
|
import org.april.hebdobot.HebdobotException;
|
||||||
import org.april.hebdobot.bot.Hebdobot;
|
import org.april.hebdobot.bot.Hebdobot;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import fr.devinsy.strings.StringList;
|
||||||
import fr.devinsy.strings.StringsUtils;
|
import fr.devinsy.strings.StringsUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -31,6 +33,27 @@ public class LicenseHook extends Hook
|
|||||||
{
|
{
|
||||||
private static final Logger logger = LoggerFactory.getLogger(LicenseHook.class);
|
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)
|
/* (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)
|
* @see org.april.hebdobot.bot.hooks.Hook#attemptProcess(org.april.hebdobot.bot.Hebdobot, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
|
||||||
*/
|
*/
|
||||||
@ -44,8 +67,8 @@ public class LicenseHook extends Hook
|
|||||||
{
|
{
|
||||||
logger.info("!licence caught.");
|
logger.info("!licence caught.");
|
||||||
|
|
||||||
bot.sendMessage(sender
|
bot.sendMessage(
|
||||||
+ ", Hebdobot est un logiciel libre de l'April sous licence GNU AGPL (sources : https://forge.april.org/adminsys/hebdobot).");
|
"Hebdobot est un logiciel libre de l'April sous licence GNU AGPLv3+, sources : https://forge.april.org/adminsys/hebdobot");
|
||||||
|
|
||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
|
@ -19,16 +19,36 @@
|
|||||||
package org.april.hebdobot.bot.hooks;
|
package org.april.hebdobot.bot.hooks;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.april.hebdobot.HebdobotException;
|
||||||
import org.april.hebdobot.bot.Hebdobot;
|
import org.april.hebdobot.bot.Hebdobot;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import fr.devinsy.strings.StringList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class TimekeeperHook.
|
* The Class ListenAlexandrieHook.
|
||||||
|
*
|
||||||
|
* This hook is listening Alexandrie messages and do not answer.
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
public class TimekeeperHook extends Hook
|
public class ListenAlexandrieHook extends Hook
|
||||||
{
|
{
|
||||||
private static final Logger logger = LoggerFactory.getLogger(TimekeeperHook.class);
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (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)
|
* @see org.april.hebdobot.bot.hooks.Hook#attemptProcess(org.april.hebdobot.bot.Hebdobot, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
|
||||||
@ -39,11 +59,8 @@ public class TimekeeperHook extends Hook
|
|||||||
{
|
{
|
||||||
boolean result;
|
boolean result;
|
||||||
|
|
||||||
if (StringUtils.equalsAnyIgnoreCase(message, "!timekeeper", "!chrono"))
|
if (StringUtils.equalsIgnoreCase(sender, "alexandrie"))
|
||||||
{
|
{
|
||||||
logger.info("!chrono caught.");
|
|
||||||
bot.sendMessage(bot.getTimekeeper().format());
|
|
||||||
|
|
||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (C) 2018-2019 Christian Pierre MOMON <cmomon@april.org>
|
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||||
*
|
*
|
||||||
* This file is part of (April) Hebdobot.
|
* This file is part of (April) Hebdobot.
|
||||||
*
|
*
|
||||||
@ -22,12 +22,15 @@ import java.util.Collection;
|
|||||||
|
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.april.hebdobot.HebdobotException;
|
||||||
import org.april.hebdobot.bot.Hebdobot;
|
import org.april.hebdobot.bot.Hebdobot;
|
||||||
import org.april.hebdobot.bot.review.Topic;
|
import org.april.hebdobot.bot.review.Topic;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import fr.devinsy.strings.StringList;
|
||||||
import fr.devinsy.strings.StringSet;
|
import fr.devinsy.strings.StringSet;
|
||||||
|
import fr.devinsy.strings.StringsUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class MissingHook.
|
* The Class MissingHook.
|
||||||
@ -36,6 +39,27 @@ public class MissingHook extends Hook
|
|||||||
{
|
{
|
||||||
private static final Logger logger = LoggerFactory.getLogger(MissingHook.class);
|
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)
|
/* (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)
|
* @see org.april.hebdobot.bot.hooks.Hook#attemptProcess(org.april.hebdobot.bot.Hebdobot, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
|
||||||
*/
|
*/
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (C) 2018 Christian Pierre MOMON <cmomon@april.org>
|
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||||
*
|
*
|
||||||
* This file is part of (April) Hebdobot.
|
* This file is part of (April) Hebdobot.
|
||||||
*
|
*
|
||||||
@ -20,6 +20,8 @@ package org.april.hebdobot.bot.hooks;
|
|||||||
|
|
||||||
import java.io.File;
|
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.Hebdobot;
|
||||||
import org.april.hebdobot.bot.stats.ReviewDatas;
|
import org.april.hebdobot.bot.stats.ReviewDatas;
|
||||||
import org.april.hebdobot.bot.stats.ReviewDatasFile;
|
import org.april.hebdobot.bot.stats.ReviewDatasFile;
|
||||||
@ -27,6 +29,9 @@ import org.april.hebdobot.bot.stats.ReviewStatsReporter;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import fr.devinsy.strings.StringList;
|
||||||
|
import fr.devinsy.strings.StringsUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class RecordHook.
|
* The Class RecordHook.
|
||||||
*/
|
*/
|
||||||
@ -34,6 +39,27 @@ public class RecordHook extends Hook
|
|||||||
{
|
{
|
||||||
private static final Logger logger = LoggerFactory.getLogger(RecordHook.class);
|
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)
|
/* (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)
|
* @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)
|
||||||
*/
|
*/
|
||||||
@ -43,7 +69,7 @@ public class RecordHook extends Hook
|
|||||||
{
|
{
|
||||||
boolean result;
|
boolean result;
|
||||||
|
|
||||||
if (message.equals("!record"))
|
if (StringUtils.equalsIgnoreCase(message, "!record"))
|
||||||
{
|
{
|
||||||
logger.info("!record caught.");
|
logger.info("!record caught.");
|
||||||
|
|
||||||
@ -55,7 +81,7 @@ public class RecordHook extends Hook
|
|||||||
{
|
{
|
||||||
ReviewDatas datas = ReviewDatasFile.load(reviewDataFile);
|
ReviewDatas datas = ReviewDatasFile.load(reviewDataFile);
|
||||||
datas.clean();
|
datas.clean();
|
||||||
bot.sendMessage("% " + ReviewStatsReporter.reportUserCountRecord(datas));
|
bot.sendMessage(ReviewStatsReporter.reportUserCountRecord(datas));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (C) 2018 Christian Pierre MOMON <cmomon@april.org>
|
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||||
*
|
*
|
||||||
* This file is part of (April) Hebdobot.
|
* This file is part of (April) Hebdobot.
|
||||||
*
|
*
|
||||||
@ -21,12 +21,16 @@ package org.april.hebdobot.bot.hooks;
|
|||||||
import java.time.LocalTime;
|
import java.time.LocalTime;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.april.hebdobot.HebdobotException;
|
||||||
import org.april.hebdobot.bot.Hebdobot;
|
import org.april.hebdobot.bot.Hebdobot;
|
||||||
import org.april.hebdobot.bot.review.Review;
|
import org.april.hebdobot.bot.review.Review;
|
||||||
import org.quartz.SchedulerException;
|
import org.quartz.SchedulerException;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import fr.devinsy.strings.StringList;
|
||||||
|
import fr.devinsy.strings.StringsUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class StartReviewHook.
|
* The Class StartReviewHook.
|
||||||
*/
|
*/
|
||||||
@ -34,6 +38,27 @@ public class StartReviewHook extends Hook
|
|||||||
{
|
{
|
||||||
private static final Logger logger = LoggerFactory.getLogger(StartReviewHook.class);
|
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)
|
/* (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)
|
* @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)
|
||||||
*/
|
*/
|
||||||
@ -74,6 +99,7 @@ public class StartReviewHook extends Hook
|
|||||||
bot.setReview(new Review(sender, bot.getAliases()));
|
bot.setReview(new Review(sender, bot.getAliases()));
|
||||||
bot.sendMessage(sender, "Bonjour " + sender + ", vous êtes le conducteur de réunion.");
|
bot.sendMessage(sender, "Bonjour " + sender + ", vous êtes le conducteur de réunion.");
|
||||||
bot.sendMessage(sender, "Pour terminer la réunion, tapez \"!fin\"");
|
bot.sendMessage(sender, "Pour terminer la réunion, tapez \"!fin\"");
|
||||||
|
bot.checkReviewAnniversary();
|
||||||
bot.sendMessage("% Début de la réunion hebdomadaire");
|
bot.sendMessage("% Début de la réunion hebdomadaire");
|
||||||
bot.sendMessage(
|
bot.sendMessage(
|
||||||
"% rappel : toute ligne commençant par % sera considérée comme un commentaire et non prise en compte dans la synthèse");
|
"% 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 Christian Pierre MOMON <cmomon@april.org>
|
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||||
*
|
*
|
||||||
* This file is part of (April) Hebdobot.
|
* This file is part of (April) Hebdobot.
|
||||||
*
|
*
|
||||||
@ -20,6 +20,8 @@ package org.april.hebdobot.bot.hooks;
|
|||||||
|
|
||||||
import java.io.File;
|
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.Hebdobot;
|
||||||
import org.april.hebdobot.bot.stats.ReviewDatas;
|
import org.april.hebdobot.bot.stats.ReviewDatas;
|
||||||
import org.april.hebdobot.bot.stats.ReviewDatasFile;
|
import org.april.hebdobot.bot.stats.ReviewDatasFile;
|
||||||
@ -27,6 +29,9 @@ import org.april.hebdobot.bot.stats.ReviewStatsReporter;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import fr.devinsy.strings.StringList;
|
||||||
|
import fr.devinsy.strings.StringsUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class StatsHook.
|
* The Class StatsHook.
|
||||||
*/
|
*/
|
||||||
@ -34,6 +39,27 @@ public class StatsHook extends Hook
|
|||||||
{
|
{
|
||||||
private static final Logger logger = LoggerFactory.getLogger(StatsHook.class);
|
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)
|
/* (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)
|
* @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)
|
||||||
*/
|
*/
|
||||||
@ -43,7 +69,7 @@ public class StatsHook extends Hook
|
|||||||
{
|
{
|
||||||
boolean result;
|
boolean result;
|
||||||
|
|
||||||
if (message.equals("!stats"))
|
if (StringUtils.equalsIgnoreCase(message, "!stats"))
|
||||||
{
|
{
|
||||||
logger.info("!stats caught.");
|
logger.info("!stats caught.");
|
||||||
|
|
||||||
@ -56,6 +82,9 @@ public class StatsHook extends Hook
|
|||||||
{
|
{
|
||||||
ReviewDatas datas = ReviewDatasFile.load(reviewDataFile);
|
ReviewDatas datas = ReviewDatasFile.load(reviewDataFile);
|
||||||
datas.clean();
|
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.reportUserCountBoard(datas));
|
||||||
bot.sendMessage("% " + ReviewStatsReporter.reportDurationBoard(datas));
|
bot.sendMessage("% " + ReviewStatsReporter.reportDurationBoard(datas));
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (C) 2018 Christian Pierre MOMON <cmomon@april.org>
|
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||||
*
|
*
|
||||||
* This file is part of (April) Hebdobot.
|
* This file is part of (April) Hebdobot.
|
||||||
*
|
*
|
||||||
@ -19,10 +19,14 @@
|
|||||||
package org.april.hebdobot.bot.hooks;
|
package org.april.hebdobot.bot.hooks;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.april.hebdobot.HebdobotException;
|
||||||
import org.april.hebdobot.bot.Hebdobot;
|
import org.april.hebdobot.bot.Hebdobot;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import fr.devinsy.strings.StringList;
|
||||||
|
import fr.devinsy.strings.StringsUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class StatusHook.
|
* The Class StatusHook.
|
||||||
*/
|
*/
|
||||||
@ -30,6 +34,27 @@ public class StatusHook extends Hook
|
|||||||
{
|
{
|
||||||
private static final Logger logger = LoggerFactory.getLogger(StatusHook.class);
|
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)
|
/* (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)
|
* @see org.april.hebdobot.bot.hooks.Hook#attemptProcess(org.april.hebdobot.bot.Hebdobot, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
|
||||||
*/
|
*/
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (C) 2018-2019 Christian Pierre MOMON <cmomon@april.org>
|
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||||
*
|
*
|
||||||
* This file is part of (April) Hebdobot.
|
* This file is part of (April) Hebdobot.
|
||||||
*
|
*
|
||||||
@ -19,10 +19,14 @@
|
|||||||
package org.april.hebdobot.bot.hooks;
|
package org.april.hebdobot.bot.hooks;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.april.hebdobot.HebdobotException;
|
||||||
import org.april.hebdobot.bot.Hebdobot;
|
import org.april.hebdobot.bot.Hebdobot;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import fr.devinsy.strings.StringList;
|
||||||
|
import fr.devinsy.strings.StringsUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class StopReviewHook.
|
* The Class StopReviewHook.
|
||||||
*/
|
*/
|
||||||
@ -30,6 +34,27 @@ public class StopReviewHook extends Hook
|
|||||||
{
|
{
|
||||||
private static final Logger logger = LoggerFactory.getLogger(StopReviewHook.class);
|
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)
|
/* (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)
|
* @see org.april.hebdobot.bot.hooks.Hook#attemptProcess(org.april.hebdobot.bot.Hebdobot, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
|
||||||
*/
|
*/
|
||||||
@ -55,7 +80,7 @@ public class StopReviewHook extends Hook
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
bot.sendMessage("Abandon de la revue en cours.");
|
bot.sendMessage("Abandon de la revue en cours.");
|
||||||
bot.setReview(null);
|
bot.stopReview();
|
||||||
}
|
}
|
||||||
|
|
||||||
result = true;
|
result = true;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (C) 2018 Christian Pierre MOMON <cmomon@april.org>
|
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||||
*
|
*
|
||||||
* This file is part of (April) Hebdobot.
|
* This file is part of (April) Hebdobot.
|
||||||
*
|
*
|
||||||
@ -19,10 +19,12 @@
|
|||||||
package org.april.hebdobot.bot.hooks;
|
package org.april.hebdobot.bot.hooks;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.april.hebdobot.HebdobotException;
|
||||||
import org.april.hebdobot.bot.Hebdobot;
|
import org.april.hebdobot.bot.Hebdobot;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import fr.devinsy.strings.StringList;
|
||||||
import fr.devinsy.strings.StringsUtils;
|
import fr.devinsy.strings.StringsUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -32,6 +34,27 @@ public class ThanksHook extends Hook
|
|||||||
{
|
{
|
||||||
private static final Logger logger = LoggerFactory.getLogger(ThanksHook.class);
|
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)
|
/* (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)
|
* @see org.april.hebdobot.bot.hooks.Hook#attemptProcess(org.april.hebdobot.bot.Hebdobot, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
|
||||||
*/
|
*/
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (C) 2018 Christian Pierre MOMON <cmomon@april.org>
|
* Copyright (C) 2018-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||||
*
|
*
|
||||||
* This file is part of (April) Hebdobot.
|
* This file is part of (April) Hebdobot.
|
||||||
*
|
*
|
||||||
@ -18,11 +18,16 @@
|
|||||||
*/
|
*/
|
||||||
package org.april.hebdobot.bot.hooks;
|
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.Hebdobot;
|
||||||
import org.april.hebdobot.util.BuildInformation;
|
import org.april.hebdobot.util.BuildInformation;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import fr.devinsy.strings.StringList;
|
||||||
|
import fr.devinsy.strings.StringsUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class VersionHook.
|
* The Class VersionHook.
|
||||||
*/
|
*/
|
||||||
@ -30,6 +35,27 @@ public class VersionHook extends Hook
|
|||||||
{
|
{
|
||||||
private static final Logger logger = LoggerFactory.getLogger(VersionHook.class);
|
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)
|
/* (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)
|
* @see org.april.hebdobot.bot.hooks.Hook#attemptProcess(org.april.hebdobot.bot.Hebdobot, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
|
||||||
*/
|
*/
|
||||||
@ -39,7 +65,7 @@ public class VersionHook extends Hook
|
|||||||
{
|
{
|
||||||
boolean result;
|
boolean result;
|
||||||
|
|
||||||
if (message.equals("!version"))
|
if (StringUtils.equalsIgnoreCase(message, "!version"))
|
||||||
{
|
{
|
||||||
logger.info("!version caught.");
|
logger.info("!version caught.");
|
||||||
bot.sendMessage(new BuildInformation().toString());
|
bot.sendMessage(new BuildInformation().toString());
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (C) 2017-2019 Christian Pierre MOMON <cmomon@april.org>
|
* Copyright (C) 2017-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||||
* Copyright (C) 2011-2013 Nicolas Vinot <aeris@imirhil.fr>
|
* Copyright (C) 2011-2013 Nicolas Vinot <aeris@imirhil.fr>
|
||||||
*
|
*
|
||||||
* This file is part of (April) Hebdobot.
|
* This file is part of (April) Hebdobot.
|
||||||
@ -56,13 +56,25 @@ public class CollectiveTopic extends Topic
|
|||||||
* @see org.april.hebdobot.bot.review.Topic#cancelPrevious(java.lang.String)
|
* @see org.april.hebdobot.bot.review.Topic#cancelPrevious(java.lang.String)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void cancelPreviousMessage(final String author)
|
public String cancelPreviousMessage(final String author)
|
||||||
{
|
{
|
||||||
Message previousMessage = this.messages.getByAuthor(author).getLast();
|
String result;
|
||||||
if (previousMessage != null)
|
|
||||||
|
Messages authorMessages = this.messages.getByAuthor(author);
|
||||||
|
|
||||||
|
if (authorMessages.isEmpty())
|
||||||
{
|
{
|
||||||
this.messages.remove(previousMessage);
|
result = null;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Message previousMessage = authorMessages.getLast();
|
||||||
|
this.messages.remove(previousMessage);
|
||||||
|
result = previousMessage.getContent();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -90,4 +102,23 @@ public class CollectiveTopic extends Topic
|
|||||||
//
|
//
|
||||||
return result;
|
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-2019 Christian Pierre MOMON <cmomon@april.org>
|
* Copyright (C) 2017-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||||
* Copyright (C) 2011-2013 Nicolas Vinot <aeris@imirhil.fr>
|
* Copyright (C) 2011-2013 Nicolas Vinot <aeris@imirhil.fr>
|
||||||
*
|
*
|
||||||
* This file is part of (April) Hebdobot.
|
* This file is part of (April) Hebdobot.
|
||||||
@ -19,9 +19,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.april.hebdobot.bot.review;
|
package org.april.hebdobot.bot.review;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import fr.devinsy.strings.StringSet;
|
import fr.devinsy.strings.StringSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -29,7 +26,7 @@ import fr.devinsy.strings.StringSet;
|
|||||||
*/
|
*/
|
||||||
public class IndividualTopic extends Topic
|
public class IndividualTopic extends Topic
|
||||||
{
|
{
|
||||||
private final Map<String, Messages> messages;
|
private final MessageMap messages;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new individual topic.
|
* Instantiates a new individual topic.
|
||||||
@ -41,7 +38,7 @@ public class IndividualTopic extends Topic
|
|||||||
{
|
{
|
||||||
super(title);
|
super(title);
|
||||||
|
|
||||||
this.messages = new HashMap<>();
|
this.messages = new MessageMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
@ -62,13 +59,23 @@ public class IndividualTopic extends Topic
|
|||||||
* @see org.april.hebdobot.bot.review.Topic#cancelPrevious(java.lang.String)
|
* @see org.april.hebdobot.bot.review.Topic#cancelPrevious(java.lang.String)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void cancelPreviousMessage(final String participant)
|
public String cancelPreviousMessage(final String participant)
|
||||||
{
|
{
|
||||||
|
String result;
|
||||||
|
|
||||||
Messages authorMessages = this.messages.get(participant);
|
Messages authorMessages = this.messages.get(participant);
|
||||||
if (authorMessages != null)
|
if ((authorMessages == null) || (authorMessages.isEmpty()))
|
||||||
{
|
{
|
||||||
authorMessages.removeLast();
|
result = null;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Message removed = authorMessages.removeLast();
|
||||||
|
result = removed.getContent();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -102,6 +109,33 @@ public class IndividualTopic extends Topic
|
|||||||
return result;
|
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.
|
* Checks for participant.
|
||||||
*
|
*
|
||||||
|
37
src/org/april/hebdobot/bot/review/MessageMap.java
Normal file
37
src/org/april/hebdobot/bot/review/MessageMap.java
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
/**
|
||||||
|
* 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, '=');
|
addLine(buffer, '=');
|
||||||
addEmpty(buffer);
|
addEmpty(buffer);
|
||||||
addCenter(buffer, "Participants", '-');
|
addCenter(buffer, "Personnes participantes", '-');
|
||||||
for (final String participant : review.getParticipants())
|
for (final String participant : review.getParticipants())
|
||||||
{
|
{
|
||||||
addChunk(buffer, "* " + review.getAliases().getRealName(participant));
|
addChunk(buffer, "* " + review.getAliases().getRealName(participant));
|
||||||
@ -343,12 +343,12 @@ public class ReviewReporter
|
|||||||
addEmpty(buffer);
|
addEmpty(buffer);
|
||||||
addCenter(buffer, "Statistiques");
|
addCenter(buffer, "Statistiques");
|
||||||
addEmpty(buffer);
|
addEmpty(buffer);
|
||||||
addChunk(buffer, ReviewStatsReporter.reportReviewCount(datas));
|
addChunk(buffer, ReviewStatsReporter.reportCurrentReviewCount(datas));
|
||||||
addChunk(buffer, "Horaire de début de la revue : " + review.getFormattedStartTime());
|
addChunk(buffer, "Horaire de début de la revue : " + review.getFormattedStartTime());
|
||||||
addChunk(buffer, "Horaire de fin de la revue : " + review.getFormattedEndTime());
|
addChunk(buffer, "Horaire de fin de la revue : " + review.getFormattedEndTime());
|
||||||
addChunk(buffer, "Durée de la revue : " + review.getDurationInMinutes() + " minutes");
|
addChunk(buffer, "Durée de la revue : " + review.getDurationInMinutes() + " minutes");
|
||||||
addChunk(buffer, "Nombre de personnes participantes : " + review.getParticipants().size());
|
addChunk(buffer, "Nombre de personnes participantes : " + review.getParticipants().size());
|
||||||
addChunk(buffer, ReviewStatsReporter.reportNewUserCountRecord(datas));
|
addChunk(buffer, ReviewStatsReporter.reportCheckUserCountRecord(datas));
|
||||||
addChunk(buffer, ReviewStatsReporter.reportUserCount(datas, review.getParticipants().size()));
|
addChunk(buffer, ReviewStatsReporter.reportUserCount(datas, review.getParticipants().size()));
|
||||||
addChunk(buffer, ReviewStatsReporter.reportDuration(datas, review.getDurationInMinutes()));
|
addChunk(buffer, ReviewStatsReporter.reportDuration(datas, review.getDurationInMinutes()));
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (C) 2017-2019 Christian Pierre MOMON <cmomon@april.org>
|
* Copyright (C) 2017-2021 Christian Pierre MOMON <cmomon@april.org>
|
||||||
* Copyright (C) 2011-2013 Nicolas Vinot <aeris@imirhil.fr>
|
* Copyright (C) 2011-2013 Nicolas Vinot <aeris@imirhil.fr>
|
||||||
*
|
*
|
||||||
* This file is part of (April) Hebdobot.
|
* This file is part of (April) Hebdobot.
|
||||||
@ -53,7 +53,7 @@ public abstract class Topic
|
|||||||
* @param participant
|
* @param participant
|
||||||
* the participant
|
* the participant
|
||||||
*/
|
*/
|
||||||
public abstract void cancelPreviousMessage(final String participant);
|
public abstract String cancelPreviousMessage(final String participant);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the participants.
|
* Gets the participants.
|
||||||
@ -71,4 +71,13 @@ public abstract class Topic
|
|||||||
{
|
{
|
||||||
return this.title;
|
return this.title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks for message from.
|
||||||
|
*
|
||||||
|
* @param author
|
||||||
|
* the author
|
||||||
|
* @return true, if successful
|
||||||
|
*/
|
||||||
|
public abstract boolean hasMessage(String author);
|
||||||
}
|
}
|
||||||
|
@ -106,6 +106,70 @@ public class ReviewDatas extends ArrayList<ReviewData>
|
|||||||
return result;
|
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.
|
* Gets the by year.
|
||||||
*
|
*
|
||||||
@ -183,6 +247,35 @@ public class ReviewDatas extends ArrayList<ReviewData>
|
|||||||
return result;
|
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.
|
* Gets the max user count.
|
||||||
*
|
*
|
||||||
@ -212,6 +305,35 @@ public class ReviewDatas extends ArrayList<ReviewData>
|
|||||||
return result;
|
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.
|
* Gets the min user count.
|
||||||
*
|
*
|
||||||
@ -298,32 +420,60 @@ public class ReviewDatas extends ArrayList<ReviewData>
|
|||||||
/**
|
/**
|
||||||
* Reverse.
|
* Reverse.
|
||||||
*/
|
*/
|
||||||
public void reverse()
|
public ReviewDatas reverse()
|
||||||
{
|
{
|
||||||
|
ReviewDatas result;
|
||||||
|
|
||||||
Collections.reverse(this);
|
Collections.reverse(this);
|
||||||
|
|
||||||
|
result = this;
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sort by date.
|
* Sort by date.
|
||||||
*/
|
*/
|
||||||
public void sortByDate()
|
public ReviewDatas sortByDate()
|
||||||
{
|
{
|
||||||
|
ReviewDatas result;
|
||||||
|
|
||||||
Collections.sort(this, new ReviewDataComparator(Sorting.DATE));
|
Collections.sort(this, new ReviewDataComparator(Sorting.DATE));
|
||||||
|
|
||||||
|
result = this;
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sort by duration.
|
* Sort by duration.
|
||||||
*/
|
*/
|
||||||
public void sortByDuration()
|
public ReviewDatas sortByDuration()
|
||||||
{
|
{
|
||||||
|
ReviewDatas result;
|
||||||
|
|
||||||
Collections.sort(this, new ReviewDataComparator(Sorting.DURATION));
|
Collections.sort(this, new ReviewDataComparator(Sorting.DURATION));
|
||||||
|
|
||||||
|
result = this;
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sort by user count.
|
* Sort by user count.
|
||||||
*/
|
*/
|
||||||
public void sortByUserCount()
|
public ReviewDatas sortByUserCount()
|
||||||
{
|
{
|
||||||
|
ReviewDatas result;
|
||||||
|
|
||||||
Collections.sort(this, new ReviewDataComparator(Sorting.USERCOUNT));
|
Collections.sort(this, new ReviewDataComparator(Sorting.USERCOUNT));
|
||||||
|
|
||||||
|
result = this;
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -108,6 +108,82 @@ public class ReviewStatsReporter
|
|||||||
return result;
|
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.
|
* Report duration.
|
||||||
*
|
*
|
||||||
@ -169,55 +245,6 @@ public class ReviewStatsReporter
|
|||||||
return result;
|
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.
|
* Report review count.
|
||||||
*
|
*
|
||||||
@ -235,11 +262,61 @@ public class ReviewStatsReporter
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
long currentYear = LocalDateTime.now().getYear();
|
ReviewData firstReview = datas.sortByDate().get(0);
|
||||||
long reviewYearCount = datas.countByYear(currentYear);
|
long reviewCount = datas.size();
|
||||||
|
String firstDate = firstReview.getDate().format(DateTimeFormatter.ofPattern("EEEE dd MMMM yyyy", Locale.FRENCH));
|
||||||
|
|
||||||
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()),
|
result = String.format("Il y a eu %d revues. La première date du %s.", reviewCount, firstDate);
|
||||||
reviewYearCount, numberSuffix(reviewYearCount), currentYear);
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
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());
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -220,7 +220,7 @@ public class PrivatebinClient extends PrivatebinSettings
|
|||||||
String deleteToken = parser.get("deletetoken").toString();
|
String deleteToken = parser.get("deletetoken").toString();
|
||||||
String finalURL = this.serverUrl + pasteURL + "#" + Base58.encode(randomPassword.getBytes());
|
String finalURL = this.serverUrl + pasteURL + "#" + Base58.encode(randomPassword.getBytes());
|
||||||
String deleteURL = this.serverUrl + pasteURL + "&deletetoken=" + deleteToken;
|
String deleteURL = this.serverUrl + pasteURL + "&deletetoken=" + deleteToken;
|
||||||
logger.info("Pastebin SUCESS");
|
logger.info("Pastebin SUCCESS");
|
||||||
logger.debug("Paste URL: {}", finalURL);
|
logger.debug("Paste URL: {}", finalURL);
|
||||||
logger.debug("Delete URL: {}", deleteURL);
|
logger.debug("Delete URL: {}", deleteURL);
|
||||||
result = finalURL;
|
result = finalURL;
|
||||||
|
@ -22,18 +22,18 @@ import java.time.Duration;
|
|||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class TimeKeeper.
|
* The Class Chrono.
|
||||||
*/
|
*/
|
||||||
public class Timekeeper
|
public class Chrono
|
||||||
{
|
{
|
||||||
private LocalDateTime start;
|
private LocalDateTime start;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new time keeper.
|
* Instantiates a new time keeper.
|
||||||
*/
|
*/
|
||||||
public Timekeeper()
|
public Chrono()
|
||||||
{
|
{
|
||||||
this.start = null;
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -61,6 +61,14 @@ public class Timekeeper
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reset.
|
||||||
|
*/
|
||||||
|
public void reset()
|
||||||
|
{
|
||||||
|
this.start = null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start.
|
* Start.
|
||||||
*/
|
*/
|
||||||
@ -68,4 +76,20 @@ public class Timekeeper
|
|||||||
{
|
{
|
||||||
this.start = LocalDateTime.now();
|
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.");
|
logger.debug("File loaded.");
|
||||||
ReviewData currentReview = new ReviewData(LocalDateTime.now(), 12, 17L);
|
ReviewData currentReview = new ReviewData(LocalDateTime.now(), 12, 17L);
|
||||||
datas.add(currentReview);
|
datas.add(currentReview);
|
||||||
String report = ReviewStatsReporter.reportNewUserCountRecord(datas);
|
String report = ReviewStatsReporter.reportCheckUserCountRecord(datas);
|
||||||
logger.debug("Report=" + report);
|
logger.debug("Report=" + report);
|
||||||
Assert.assertTrue(StringUtils.startsWith(report, "Le dernier record de"));
|
Assert.assertTrue(StringUtils.startsWith(report, "Le dernier record de"));
|
||||||
}
|
}
|
||||||
@ -92,7 +92,7 @@ public class ReviewStatsReporterTest
|
|||||||
logger.debug("File loaded.");
|
logger.debug("File loaded.");
|
||||||
ReviewData currentReview = new ReviewData(LocalDateTime.now(), 42000, 17L);
|
ReviewData currentReview = new ReviewData(LocalDateTime.now(), 42000, 17L);
|
||||||
datas.add(currentReview);
|
datas.add(currentReview);
|
||||||
String report = ReviewStatsReporter.reportNewUserCountRecord(datas);
|
String report = ReviewStatsReporter.reportCheckUserCountRecord(datas);
|
||||||
logger.debug("Report=" + report);
|
logger.debug("Report=" + report);
|
||||||
Assert.assertTrue(StringUtils.startsWith(report, "*\\o/* Nouveau record de participation"));
|
Assert.assertTrue(StringUtils.startsWith(report, "*\\o/* Nouveau record de participation"));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user