Fixed message catching. Added !vaten command. Modify !stop command.
This commit is contained in:
parent
533e2d1486
commit
7025e74490
@ -132,7 +132,7 @@ public class Hebdobot extends PircBot
|
|||||||
sendMessage(message);
|
sendMessage(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.twitterSettings != null)
|
if (this.twitterSettings.isValid())
|
||||||
{
|
{
|
||||||
String message = String.format("Revue hebdomadaire !april dans %dmin sur irc://irc.freenode.org/april ou http://apr1.org/8l", minutes);
|
String message = String.format("Revue hebdomadaire !april dans %dmin sur irc://irc.freenode.org/april ou http://apr1.org/8l", minutes);
|
||||||
|
|
||||||
@ -169,6 +169,31 @@ public class Hebdobot extends PircBot
|
|||||||
sendMessage(sender, "— !courant : affiche le sujet en cours");
|
sendMessage(sender, "— !courant : affiche le sujet en cours");
|
||||||
sendMessage(sender, "— !manquants : affiche les participants qui n'ont pas répondu sur le dernier sujet");
|
sendMessage(sender, "— !manquants : affiche les participants qui n'ont pas répondu sur le dernier sujet");
|
||||||
sendMessage(sender, "— % message : un commentaire");
|
sendMessage(sender, "— % message : un commentaire");
|
||||||
|
sendMessage(sender, "— !stop : abandonner la revue en cours");
|
||||||
|
sendMessage(sender, "— !vaten : faire partir le bot");
|
||||||
|
}
|
||||||
|
else if (StringUtils.equalsIgnoreCase(text, "!vaten"))
|
||||||
|
{
|
||||||
|
logger.info("!die caught.");
|
||||||
|
|
||||||
|
// Die.
|
||||||
|
if (this.review == null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
sendMessage(sender + ", ok bye.");
|
||||||
|
Thread.sleep(1000);
|
||||||
|
System.exit(0);
|
||||||
|
}
|
||||||
|
catch (InterruptedException exception)
|
||||||
|
{
|
||||||
|
logger.warn("Pause abord: " + exception.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sendMessage("% Une revue est en cours, arrêt impossible");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (StringUtils.equalsIgnoreCase(text, "!stop"))
|
else if (StringUtils.equalsIgnoreCase(text, "!stop"))
|
||||||
{
|
{
|
||||||
@ -177,12 +202,11 @@ public class Hebdobot extends PircBot
|
|||||||
// Die.
|
// Die.
|
||||||
if (this.review == null)
|
if (this.review == null)
|
||||||
{
|
{
|
||||||
// TODO
|
sendMessage("Aucune revue en cours, arrêt impossible");
|
||||||
// Context.close();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sendMessage("% Une revue est en cours, arrêt impossible");
|
this.review = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((StringUtils.equalsIgnoreCase(text, "!debut")) || (StringUtils.equalsIgnoreCase(text, "!début")))
|
else if ((StringUtils.equalsIgnoreCase(text, "!debut")) || (StringUtils.equalsIgnoreCase(text, "!début")))
|
||||||
@ -201,7 +225,7 @@ public class Hebdobot extends PircBot
|
|||||||
logger.info("!fin caught.");
|
logger.info("!fin caught.");
|
||||||
|
|
||||||
// Stop.
|
// Stop.
|
||||||
if (this.review != null)
|
if (this.review == null)
|
||||||
{
|
{
|
||||||
sendMessage(sender + ", pas de revue en cours.");
|
sendMessage(sender + ", pas de revue en cours.");
|
||||||
}
|
}
|
||||||
@ -216,6 +240,7 @@ public class Hebdobot extends PircBot
|
|||||||
String textReview = this.review.toString();
|
String textReview = this.review.toString();
|
||||||
if (this.pastebinSettings.isValid())
|
if (this.pastebinSettings.isValid())
|
||||||
{
|
{
|
||||||
|
logger.info("Pastebin the review.");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
PastebinClient pastebinClient = new PastebinClient(this.pastebinSettings.getApiKey());
|
PastebinClient pastebinClient = new PastebinClient(this.pastebinSettings.getApiKey());
|
||||||
@ -232,10 +257,11 @@ public class Hebdobot extends PircBot
|
|||||||
|
|
||||||
if (this.reviewFileSuffix != null)
|
if (this.reviewFileSuffix != null)
|
||||||
{
|
{
|
||||||
|
logger.info("Write review file.");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
File file = new File(date + "_" + this.reviewFileSuffix);
|
File file = new File(date + "_" + this.reviewFileSuffix);
|
||||||
FileUtils.writeStringToFile(file, text);
|
FileUtils.writeStringToFile(file, textReview);
|
||||||
sendMessage("% Compte-rendu de la revue : " + file.getName());
|
sendMessage("% Compte-rendu de la revue : " + file.getName());
|
||||||
}
|
}
|
||||||
catch (final Exception exception)
|
catch (final Exception exception)
|
||||||
@ -286,19 +312,19 @@ public class Hebdobot extends PircBot
|
|||||||
logger.info("\\s*#[^#].* caught.");
|
logger.info("\\s*#[^#].* caught.");
|
||||||
|
|
||||||
// Individual topic.
|
// Individual topic.
|
||||||
if (this.review == null)
|
if (this.review != null)
|
||||||
{
|
{
|
||||||
if (this.review.isOwner(sender))
|
if (this.review.isOwner(sender))
|
||||||
{
|
|
||||||
sendMessage(sender + ", vous n'êtes pas le conducteur de la réunion");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
IndividualTopic topic = new IndividualTopic(text.replaceFirst("#", "").trim());
|
IndividualTopic topic = new IndividualTopic(text.replaceFirst("#", "").trim());
|
||||||
this.review.begin(topic);
|
this.review.begin(topic);
|
||||||
sendMessage("Sujet individuel : " + topic.getTitle());
|
sendMessage("Sujet individuel : " + topic.getTitle());
|
||||||
sendMessage("% quand vous avez fini vous le dites par % fini");
|
sendMessage("% quand vous avez fini vous le dites par % fini");
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sendMessage(sender + ", vous n'êtes pas le conducteur de la réunion");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (StringUtils.equalsIgnoreCase(text, "!manquants"))
|
else if (StringUtils.equalsIgnoreCase(text, "!manquants"))
|
||||||
@ -374,6 +400,13 @@ public class Hebdobot extends PircBot
|
|||||||
this.review.add(new Message(sender, text));
|
this.review.add(new Message(sender, text));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (text.startsWith("!"))
|
||||||
|
{
|
||||||
|
logger.info("!??? caught.");
|
||||||
|
|
||||||
|
// Command unknown.
|
||||||
|
sendMessage(sender + ", command unknown: " + text);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logger.info("Else caught.");
|
logger.info("Else caught.");
|
||||||
|
@ -18,6 +18,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.april.hebdobot.twitter;
|
package org.april.hebdobot.twitter;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class TwitterSettings.
|
* The Class TwitterSettings.
|
||||||
*/
|
*/
|
||||||
@ -62,6 +64,28 @@ public class TwitterSettings
|
|||||||
return this.consumerSecret;
|
return this.consumerSecret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if is valid.
|
||||||
|
*
|
||||||
|
* @return true, if is valid
|
||||||
|
*/
|
||||||
|
public boolean isValid()
|
||||||
|
{
|
||||||
|
boolean result;
|
||||||
|
|
||||||
|
if ((StringUtils.isBlank(this.consumerKey)) || (StringUtils.isBlank(this.consumerSecret)))
|
||||||
|
{
|
||||||
|
result = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
public void setAccessToken(final String accessToken)
|
public void setAccessToken(final String accessToken)
|
||||||
{
|
{
|
||||||
this.accessToken = accessToken;
|
this.accessToken = accessToken;
|
||||||
|
Loading…
Reference in New Issue
Block a user