Created the SendErrorHandler. Useful to send custom error messages to the user whenever the message could not be found

This commit is contained in:
mathias 2021-10-02 17:27:11 +02:00
parent aca8c36dfd
commit d94480bb4e
No known key found for this signature in database
GPG Key ID: 8950DF62139C852A

View File

@ -0,0 +1,25 @@
package de.gnmyt.autoresponder.handler;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class SendErrorHandler extends NotFoundHandler {
private final ArrayList<String> messages = new ArrayList<>();
/**
* Constructor of the {@link SendErrorHandler}.
*
* It sends error message sto the author if the message could not be found
* @param errorMessages The error messages you want to send
*/
public SendErrorHandler(String... errorMessages) {
messages.addAll(Arrays.asList(errorMessages));
}
@Override
public List<String> handleRequest(String sender, String message) {
return messages;
}
}