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 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 Details

  • Method Details

    • getCommand

      @NonNull public abstract @NonNull String 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 interface Handler<TelegramBotConfiguration,Update,SendMessage>
      Parameters:
      bot - bot being asked to handle this command
      input - 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 interface Handler<TelegramBotConfiguration,Update,SendMessage>
      Parameters:
      bot - bot being asked to handle this command
      input - 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 interface io.micronaut.core.order.Ordered