public final class CommandRegistry extends Object implements ICommandRegistry
| Constructor and Description |
|---|
CommandRegistry(boolean allowCommandsWithUsername,
String botUsername)
Creates a Command registry
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
deregister(IBotCommand botCommand)
deregister a command
|
Map<IBotCommand,Boolean> |
deregisterAll(IBotCommand... botCommands)
deregister multiple commands
|
boolean |
executeCommand(AbsSender absSender,
org.telegram.telegrambots.api.objects.Message message)
Executes a command action if the command is registered.
|
IBotCommand |
getRegisteredCommand(String commandIdentifier)
get registered command
|
Collection<IBotCommand> |
getRegisteredCommands()
get a collection of all registered commands
|
boolean |
register(IBotCommand botCommand)
register a command
|
Map<IBotCommand,Boolean> |
registerAll(IBotCommand... botCommands)
register multiple commands
|
void |
registerDefaultAction(BiConsumer<AbsSender,org.telegram.telegrambots.api.objects.Message> defaultConsumer)
Register a default action when there is no command register that match the message sent
|
public CommandRegistry(boolean allowCommandsWithUsername,
String botUsername)
allowCommandsWithUsername - True to allow commands with username, false otherwisebotUsername - Bot usernamepublic void registerDefaultAction(BiConsumer<AbsSender,org.telegram.telegrambots.api.objects.Message> defaultConsumer)
ICommandRegistryregisterDefaultAction in interface ICommandRegistrydefaultConsumer - Consumer to evaluate the messagepublic final boolean register(IBotCommand botCommand)
ICommandRegistryregister in interface ICommandRegistrybotCommand - the command to registerpublic final Map<IBotCommand,Boolean> registerAll(IBotCommand... botCommands)
ICommandRegistryregisterAll in interface ICommandRegistrybotCommands - commands to registerpublic final boolean deregister(IBotCommand botCommand)
ICommandRegistryderegister in interface ICommandRegistrybotCommand - the command to deregisterpublic final Map<IBotCommand,Boolean> deregisterAll(IBotCommand... botCommands)
ICommandRegistryderegisterAll in interface ICommandRegistrybotCommands - commands to deregisterpublic final Collection<IBotCommand> getRegisteredCommands()
ICommandRegistrygetRegisteredCommands in interface ICommandRegistrypublic final IBotCommand getRegisteredCommand(String commandIdentifier)
ICommandRegistrygetRegisteredCommand in interface ICommandRegistrypublic final boolean executeCommand(AbsSender absSender, org.telegram.telegrambots.api.objects.Message message)
absSender - absSendermessage - input messageCopyright © 2018. All rights reserved.