Class TelegramLongPollingCommandBot

  • All Implemented Interfaces:
    CommandBot, ICommandRegistry, org.telegram.telegrambots.meta.generics.LongPollingBot, org.telegram.telegrambots.meta.generics.TelegramBot

    public abstract class TelegramLongPollingCommandBot
    extends TelegramLongPollingBot
    implements CommandBot, ICommandRegistry
    This class adds command functionality to the TelegramLongPollingBot
    Author:
    Timo Schulz (Mit0x2)
    • Constructor Detail

      • TelegramLongPollingCommandBot

        public TelegramLongPollingCommandBot()
        Creates a TelegramLongPollingCommandBot using default options Use ICommandRegistry's methods on this bot to register commands
      • TelegramLongPollingCommandBot

        public TelegramLongPollingCommandBot​(DefaultBotOptions options)
        Creates a TelegramLongPollingCommandBot with custom options and allowing commands with usernames Use ICommandRegistry's methods on this bot to register commands
        Parameters:
        options - Bot options
      • TelegramLongPollingCommandBot

        public TelegramLongPollingCommandBot​(DefaultBotOptions options,
                                             boolean allowCommandsWithUsername)
        Creates a TelegramLongPollingCommandBot Use ICommandRegistry's methods on this bot to register commands
        Parameters:
        options - Bot options
        allowCommandsWithUsername - true to allow commands with parameters (default), false otherwise
    • Method Detail

      • onUpdateReceived

        public final void onUpdateReceived​(org.telegram.telegrambots.meta.api.objects.Update update)
        Specified by:
        onUpdateReceived in interface org.telegram.telegrambots.meta.generics.LongPollingBot
      • 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
      • 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
      • 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
      • getBotUsername

        public abstract String getBotUsername()
        Specified by:
        getBotUsername in interface org.telegram.telegrambots.meta.generics.TelegramBot
        Returns:
        Bot username