/** * Copyright (C) 2018-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; import fr.devinsy.strings.StringsUtils; /** * The Class StatusHook. */ public class StatusHook extends Hook { private static final Logger logger = LoggerFactory.getLogger(StatusHook.class); /* (non-Javadoc) * @see org.april.hebdobot.bot.hooks.Hook#attemptHelp(java.lang.String) */ @Override public StringList attemptHelp(final String token) throws HebdobotException { StringList result; if (StringsUtils.equalsAnyIgnoreCase(token, "status", "statut")) { result = new StringList("!status, !statut : état et paramétrage d'Hebdobot"); } else { result = null; } // return result; } /* (non-Javadoc) * @see org.april.hebdobot.bot.hooks.Hook#attemptProcess(org.april.hebdobot.bot.Hebdobot, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String) */ @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, "!status", "!statut")) { logger.info("!status caught."); bot.sendMessage(sender, sender + ", voici l'état d'Hebdobot :"); bot.sendMessage(sender, " revue en cours : " + (bot.getReview() != null)); if (bot.getReview() == null) { bot.sendMessage(sender, " animateur revue : none"); } else { bot.sendMessage(sender, " animateur revue : " + bot.getReview().getOwner()); } bot.sendMessage(sender, " Alias settings : " + (bot.getAliases().size())); bot.sendMessage(sender, " Identica settings : " + (bot.getIdenticaSettings().isValid())); bot.sendMessage(sender, " Privatebin settings : " + bot.getPrivatebinSettings().toString()); bot.sendMessage(sender, " Twitter settings : " + (bot.getTwitterSettings().isValid())); bot.sendMessage(sender, " Cron settings : " + (bot.getCronSettings().size())); bot.sendMessage(sender, " Review Wait Time : " + (bot.getReviewWaitTime())); result = true; } else { result = false; } // return result; } }