Class CommandHandler
java.lang.Object
io.micronaut.chatbots.telegram.core.CommandHandler
- All Implemented Interfaces:
Handler<TelegramBotConfiguration,
,Update, SendMessage> TelegramHandler<SendMessage>
,io.micronaut.core.order.Ordered
Abstract class to make easy to respond static content for a Telegram Bot command.
- Since:
- 1.0.0
- Author:
- Sergio del Amo
-
Field Summary
Fields inherited from interface io.micronaut.core.order.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
CommandHandler
(TelegramSlashCommandParser slashCommandParser, TextResourceLoader textResourceLoader, SpaceParser<Update, Chat> spaceParser) -
Method Summary
Modifier and TypeMethodDescriptionboolean
canHandle
(@Nullable TelegramBotConfiguration bot, @NonNull @NotNull Update input) Returns true if the handler can dispatch the current request.abstract @NonNull String
int
getOrder()
@NonNull Optional<SendMessage>
handle
(@Nullable TelegramBotConfiguration bot, @NonNull @NotNull Update input) Handles the request.
-
Constructor Details
-
CommandHandler
protected CommandHandler(TelegramSlashCommandParser slashCommandParser, TextResourceLoader textResourceLoader, SpaceParser<Update, Chat> spaceParser)
-
-
Method Details
-
getCommand
- Returns:
- A slash command. E.g. /help
-
canHandle
public boolean canHandle(@Nullable @Nullable TelegramBotConfiguration bot, @NonNull @NotNull @NonNull @NotNull Update input) Description copied from interface:Handler
Returns true if the handler can dispatch the current request.- Specified by:
canHandle
in interfaceHandler<TelegramBotConfiguration,
Update, SendMessage> - Parameters:
bot
- bot being asked to handle this commandinput
- input to the request handler- Returns:
- true if the handler is capable of handling the current request
-
handle
@NonNull public @NonNull Optional<SendMessage> handle(@Nullable @Nullable TelegramBotConfiguration bot, @NonNull @NotNull @NonNull @NotNull Update input) Description copied from interface:Handler
Handles the request.- Specified by:
handle
in interfaceHandler<TelegramBotConfiguration,
Update, SendMessage> - Parameters:
bot
- bot being asked to handle this commandinput
- input to the request handler- Returns:
- output from the handler. Empty if you want to respond asynchronously.
-
getOrder
public int getOrder()- Specified by:
getOrder
in interfaceio.micronaut.core.order.Ordered
-