Set internal classes in their own dedicated file.
This commit is contained in:
parent
00f0c356af
commit
e22c563554
@ -42,23 +42,6 @@ import fr.imirhil.april.hebdobot.review.Topic;
|
||||
*/
|
||||
public class Bot extends PircBot
|
||||
{
|
||||
/**
|
||||
* The Class Handler.
|
||||
*/
|
||||
private abstract class Handler
|
||||
{
|
||||
/**
|
||||
* Handle.
|
||||
*
|
||||
* @param sender
|
||||
* the sender
|
||||
* @param message
|
||||
* the message
|
||||
* @return true, if successful
|
||||
*/
|
||||
public abstract boolean handle(String sender, String message);
|
||||
}
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(Bot.class);
|
||||
|
||||
private final String host;
|
||||
|
37
src/main/java/fr/imirhil/april/hebdobot/irc/Handler.java
Normal file
37
src/main/java/fr/imirhil/april/hebdobot/irc/Handler.java
Normal file
@ -0,0 +1,37 @@
|
||||
/**
|
||||
* Copyright (C) 2011-2013,2017 Nicolas Vinot <aeris@imirhil.fr>
|
||||
* Copyright (C) 2017 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 fr.imirhil.april.hebdobot.irc;
|
||||
|
||||
/**
|
||||
* The Class Handler.
|
||||
*/
|
||||
public abstract class Handler
|
||||
{
|
||||
/**
|
||||
* Handle.
|
||||
*
|
||||
* @param sender
|
||||
* the sender
|
||||
* @param message
|
||||
* the message
|
||||
* @return true, if successful
|
||||
*/
|
||||
public abstract boolean handle(String sender, String message);
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
/**
|
||||
* Copyright (C) 2011-2013 Nicolas Vinot <aeris@imirhil.fr>
|
||||
* Copyright (C) 2017 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 fr.imirhil.april.hebdobot.pastebin;
|
||||
|
||||
public class APIException extends Exception
|
||||
{
|
||||
private static final long serialVersionUID = 1852384776503676687L;
|
||||
|
||||
/**
|
||||
* Instantiates a new API exception.
|
||||
*
|
||||
* @param message
|
||||
* the message
|
||||
*/
|
||||
private APIException(final String message)
|
||||
{
|
||||
super(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Throw if error.
|
||||
*
|
||||
* @param content
|
||||
* the content
|
||||
* @throws APIException
|
||||
* the API exception
|
||||
*/
|
||||
public static void throwIfError(final String content) throws APIException
|
||||
{
|
||||
if (content.contains(PastebinClient.API_ERROR))
|
||||
{
|
||||
throw new APIException(content.replaceFirst(PastebinClient.API_ERROR, ""));
|
||||
}
|
||||
}
|
||||
}
|
@ -37,41 +37,6 @@ import org.apache.http.protocol.HTTP;
|
||||
*/
|
||||
public class PastebinClient
|
||||
{
|
||||
/**
|
||||
* The Class APIException.
|
||||
*/
|
||||
public static class APIException extends Exception
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Instantiates a new API exception.
|
||||
*
|
||||
* @param message
|
||||
* the message
|
||||
*/
|
||||
private APIException(final String message)
|
||||
{
|
||||
super(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Throw if error.
|
||||
*
|
||||
* @param content
|
||||
* the content
|
||||
* @throws APIException
|
||||
* the API exception
|
||||
*/
|
||||
private static void throwIfError(final String content) throws APIException
|
||||
{
|
||||
if (content.contains(API_ERROR))
|
||||
{
|
||||
throw new APIException(content.replaceFirst(API_ERROR, ""));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static final String API_LOGIN_URL = "http://pastebin.com/api/api_login.php";
|
||||
private static final String API_POST_URL = "http://pastebin.com/api/api_post.php";
|
||||
|
||||
@ -88,7 +53,7 @@ public class PastebinClient
|
||||
|
||||
private static final String API_PASTE_CODE = "api_paste_code";
|
||||
|
||||
private static final String API_ERROR = "Bad API request,";
|
||||
public static final String API_ERROR = "Bad API request,";
|
||||
|
||||
private final String apiKey;
|
||||
private String apiUserKey = null;
|
||||
|
Loading…
Reference in New Issue
Block a user