Class TelegramWebhookCommandBot

java.lang.Object
org.telegram.telegrambots.meta.bots.AbsSender
org.telegram.telegrambots.bots.DefaultAbsSender
org.telegram.telegrambots.bots.TelegramWebhookBot
org.telegram.telegrambots.extensions.bots.commandbot.TelegramWebhookCommandBot
All Implemented Interfaces:
CommandBot, ICommandRegistry, org.telegram.telegrambots.meta.generics.TelegramBot, org.telegram.telegrambots.meta.generics.WebhookBot

public abstract class TelegramWebhookCommandBot extends TelegramWebhookBot implements CommandBot, ICommandRegistry
This class adds command functionality to the TelegramWebhookBot
Author:
Andrey Korsakov (loolzaaa)
  • Constructor Details

    • TelegramWebhookCommandBot

      @Deprecated public TelegramWebhookCommandBot()
      Deprecated.
      Overwriting the getBotToken() method is deprecated. Use the constructor instead
      Creates a TelegramWebhookCommandBot using default options Use ICommandRegistry's methods on this bot to register commands
    • TelegramWebhookCommandBot

      @Deprecated public TelegramWebhookCommandBot(DefaultBotOptions options)
      Deprecated.
      Overwriting the getBotToken() method is deprecated. Use the constructor instead
      Creates a TelegramWebhookCommandBot with custom options and allowing commands with usernames Use ICommandRegistry's methods on this bot to register commands
      Parameters:
      options - Bot options
    • TelegramWebhookCommandBot

      @Deprecated public TelegramWebhookCommandBot(DefaultBotOptions options, boolean allowCommandsWithUsername)
      Deprecated.
      Overwriting the getBotToken() method is deprecated. Use the constructor instead
      Creates a TelegramWebhookCommandBot Use ICommandRegistry's methods on this bot to register commands
      Parameters:
      options - Bot options
      allowCommandsWithUsername - true to allow commands with parameters (default), false otherwise
    • TelegramWebhookCommandBot

      public TelegramWebhookCommandBot(String botToken)
      Creates a TelegramWebhookCommandBot using default options Use ICommandRegistry's methods on this bot to register commands
      Parameters:
      botToken - the telegram api token
    • TelegramWebhookCommandBot

      public TelegramWebhookCommandBot(DefaultBotOptions options, String botToken)
      Creates a TelegramWebhookCommandBot with custom options and allowing commands with usernames Use ICommandRegistry's methods on this bot to register commands
      Parameters:
      options - Bot options
      botToken - the telegram api token
    • TelegramWebhookCommandBot

      public TelegramWebhookCommandBot(DefaultBotOptions options, boolean allowCommandsWithUsername, String botToken)
      Creates a TelegramWebhookCommandBot Use ICommandRegistry's methods on this bot to register commands
      Parameters:
      options - Bot options
      allowCommandsWithUsername - true to allow commands with parameters (default), false otherwise
      botToken - the telegram api token
  • Method Details

    • onWebhookUpdateReceived

      public org.telegram.telegrambots.meta.api.methods.BotApiMethod<?> onWebhookUpdateReceived(org.telegram.telegrambots.meta.api.objects.Update update)
      Specified by:
      onWebhookUpdateReceived in interface org.telegram.telegrambots.meta.generics.WebhookBot
    • register

      public final boolean register(IBotCommand botCommand)
      Description copied from interface: ICommandRegistry
      register a command
      Specified by:
      register in interface ICommandRegistry
      Parameters:
      botCommand - the command to register
      Returns:
      whether the command could be registered, was not already registered
    • registerAll

      public final Map<IBotCommand,Boolean> registerAll(IBotCommand... botCommands)
      Description copied from interface: ICommandRegistry
      register multiple commands
      Specified by:
      registerAll in interface ICommandRegistry
      Parameters:
      botCommands - commands to register
      Returns:
      map with results of the command register per command
    • deregister

      public final boolean deregister(IBotCommand botCommand)
      Description copied from interface: ICommandRegistry
      deregister a command
      Specified by:
      deregister in interface ICommandRegistry
      Parameters:
      botCommand - the command to deregister
      Returns:
      whether the command could be deregistered, was registered
    • deregisterAll

      public final Map<IBotCommand,Boolean> deregisterAll(IBotCommand... botCommands)
      Description copied from interface: ICommandRegistry
      deregister multiple commands
      Specified by:
      deregisterAll in interface ICommandRegistry
      Parameters:
      botCommands - commands to deregister
      Returns:
      map with results of the command deregistered per command
    • getRegisteredCommands

      public final Collection<IBotCommand> getRegisteredCommands()
      Description copied from interface: ICommandRegistry
      get a collection of all registered commands
      Specified by:
      getRegisteredCommands in interface ICommandRegistry
      Returns:
      a collection of registered commands
    • registerDefaultAction

      public void registerDefaultAction(BiConsumer<org.telegram.telegrambots.meta.bots.AbsSender,org.telegram.telegrambots.meta.api.objects.Message> defaultConsumer)
      Description copied from interface: ICommandRegistry
      Register a default action when there is no command register that match the message sent
      Specified by:
      registerDefaultAction in interface ICommandRegistry
      Parameters:
      defaultConsumer - Consumer to evaluate the message
    • getRegisteredCommand

      public final IBotCommand getRegisteredCommand(String commandIdentifier)
      Description copied from interface: ICommandRegistry
      get registered command
      Specified by:
      getRegisteredCommand in interface ICommandRegistry
      Returns:
      registered command if exists or null if not