public final boolean executeCommand ( AbsSender absSender , Message message ) { if ( message . hasText ( ) ) { String text = message . getText ( ) ; if ( text . startsWith ( BotCommand . COMMAND_INIT_CHARACTER ) ) { String commandMessage = text . substring ( 1 ) ; String [ ] commandSplit = commandMessage . split ( BotCommand . COMMAND_PARAMETER_SEPARATOR_REGEXP ) ; String command = removeUsernameFromCommandIfNeeded ( commandSplit [ 0 ] ) ; if ( commandRegistryMap . containsKey ( command ) ) { String [ ] parameters = Arrays . copyOfRange ( commandSplit , 1 , commandSplit . length ) ; commandRegistryMap . get ( command ) . processMessage ( absSender , message , parameters ) ; return true ; } else if ( defaultConsumer != null ) { defaultConsumer . accept ( absSender , message ) ; return true ; } } } return false ; }
Executes a command action if the command is registered .