get registered command by commandIdentifier

This commit is contained in:
dartwata 2016-07-14 12:49:06 +08:00
parent d39f874ceb
commit a24c147a17
3 changed files with 16 additions and 0 deletions

View File

@ -71,6 +71,11 @@ public abstract class TelegramLongPollingCommandBot extends TelegramLongPollingB
commandRegistry.registerDefaultAction(defaultConsumer);
}
@Override
public final BotCommand getRegisteredCommand(String commandIdentifier) {
return commandRegistry.getRegisteredCommand(commandIdentifier);
}
/**
* Process all updates, that are not commands.
* @warning Commands that have valid syntax but are not registered on this bot,

View File

@ -65,6 +65,11 @@ public final class CommandRegistry implements ICommandRegistry {
return commandRegistryMap.values();
}
@Override
public final BotCommand getRegisteredCommand(String commandIdentifier) {
return commandRegistryMap.get(commandIdentifier);
}
/**
* Executes a command action if the command is registered.
*

View File

@ -62,4 +62,10 @@ public interface ICommandRegistry {
*/
Collection<BotCommand> getRegisteredCommands();
/**
* get registered command
*
* @return registered command if exists or null if not
*/
BotCommand getRegisteredCommand(String commandIdentifier);
}