Example usage for org.apache.commons.lang StringUtils removeStartIgnoreCase

List of usage examples for org.apache.commons.lang StringUtils removeStartIgnoreCase

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils removeStartIgnoreCase.

Prototype

public static String removeStartIgnoreCase(String str, String remove) 

Source Link

Document

Case insensitive removal of a substring if it is at the begining of a source string, otherwise returns the source string.

Usage

From source file:org.quackbot.hooks.core.CoreQuackbotListener.java

@Override
public void onMessage(MessageEvent event) throws Exception {
    String message = event.getMessage();

    //Look for a prefix
    for (String curPrefix : getBot(event).getPrefixes())
        //Strip away start of message and end when the message doesn't match anymore (meaning something changed)
        if (!(message = StringUtils.removeStartIgnoreCase(message, curPrefix)).equals(message))
            break;

    //Make sure there was a prefix that got removed. No prefix = no command
    if (message.equals(event.getMessage())) {
        log.trace("Ignoring message, no prefix");
        return;//  w  ww.  j ava2  s .  co m
    }

    execute(event, event.getChannel(), event.getUser(), message);
}