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
public abstract class CommandHandler extends java.lang.Object implements TelegramHandler<SendMessage>
Abstract class to make easy to respond static content for a Telegram Bot command.- Since:
- 1.0.0
- Author:
- Sergio del Amo
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
CommandHandler(TelegramSlashCommandParser slashCommandParser, TextResourceLoader textResourceLoader, SpaceParser<Update,Chat> spaceParser)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
canHandle(TelegramBotConfiguration bot, @NotNull Update input)
Returns true if the handler can dispatch the current request.abstract java.lang.String
getCommand()
int
getOrder()
java.util.Optional<SendMessage>
handle(TelegramBotConfiguration bot, @NotNull Update input)
Handles the request.
-
-
-
Constructor Detail
-
CommandHandler
protected CommandHandler(TelegramSlashCommandParser slashCommandParser, TextResourceLoader textResourceLoader, SpaceParser<Update,Chat> spaceParser)
-
-
Method Detail
-
getCommand
@NonNull public abstract java.lang.String getCommand()
- Returns:
- A slash command. E.g. /help
-
canHandle
public boolean canHandle(@Nullable TelegramBotConfiguration bot, @NonNull @NotNull @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 java.util.Optional<SendMessage> handle(@Nullable TelegramBotConfiguration bot, @NonNull @NotNull @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
-
-