diff --git a/src/org/april/hebdobot/bot/Hebdobot.java b/src/org/april/hebdobot/bot/Hebdobot.java index bbb3b96..8488ddd 100644 --- a/src/org/april/hebdobot/bot/Hebdobot.java +++ b/src/org/april/hebdobot/bot/Hebdobot.java @@ -43,6 +43,7 @@ import org.april.hebdobot.bot.hooks.Hooker; import org.april.hebdobot.bot.hooks.IndividualSubjectHook; import org.april.hebdobot.bot.hooks.InputReviewHook; import org.april.hebdobot.bot.hooks.LicenseHook; +import org.april.hebdobot.bot.hooks.ListenAlexandrieHook; import org.april.hebdobot.bot.hooks.MissingHook; import org.april.hebdobot.bot.hooks.RecordHook; import org.april.hebdobot.bot.hooks.StartReviewHook; @@ -143,6 +144,7 @@ public class Hebdobot extends PircBot // this.hooker = new Hooker(); + this.hooker.add(new ListenAlexandrieHook()); this.hooker.add(new CancelPreviousInputHook()); this.hooker.add(new ChronoHook()); this.hooker.add(new CollectiveSubjectHook()); diff --git a/src/org/april/hebdobot/bot/hooks/ListenAlexandrieHook.java b/src/org/april/hebdobot/bot/hooks/ListenAlexandrieHook.java new file mode 100644 index 0000000..3e6a0df --- /dev/null +++ b/src/org/april/hebdobot/bot/hooks/ListenAlexandrieHook.java @@ -0,0 +1,74 @@ +/** + * Copyright (C) 2021 Christian Pierre MOMON + * + * 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 + */ +package org.april.hebdobot.bot.hooks; + +import org.apache.commons.lang3.StringUtils; +import org.april.hebdobot.HebdobotException; +import org.april.hebdobot.bot.Hebdobot; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import fr.devinsy.strings.StringList; + +/** + * The Class ListenAlexandrieHook. + * + * This hook is listening Alexandrie messages and do not answer. + * + */ +public class ListenAlexandrieHook extends Hook +{ + private static final Logger logger = LoggerFactory.getLogger(ListenAlexandrieHook.class); + + /* (non-Javadoc) + * @see org.april.hebdobot.bot.hooks.Hook#attemptHelp(java.lang.String) + */ + @Override + public StringList attemptHelp(final String token) throws HebdobotException + { + StringList result; + + result = null; + + // + return result; + } + + /* (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.equalsIgnoreCase(sender, "alexandrie")) + { + result = true; + } + else + { + result = false; + } + + // + return result; + } +}