Class HelpCommand

  • All Implemented Interfaces:
    IManCommand, IBotCommand

    public class HelpCommand
    extends ManCommand
    A special bot command used for printing help messages similiar to the Linux man command. The commands printed by this command should implement the IManCommand interface to provide an extended description.
    Version:
    1.0.0
    Author:
    Lukas Prediger(Chase)
    • Constructor Detail

      • HelpCommand

        public HelpCommand()
        Create a Help command with the standard Arguments.
      • HelpCommand

        public HelpCommand​(String commandIdentifier,
                           String description,
                           String extendedDescription)
        Creates a Help Command with custom identifier, description and extended Description
        Parameters:
        commandIdentifier - the unique identifier of this command (e.g. the command string to enter into chat)
        description - the description of this command
        extendedDescription - The extended Description for the Command, should provide detailed information about arguments and possible options
    • Method Detail

      • getHelpText

        public static String getHelpText​(IBotCommand... botCommands)
        Returns the command and description of all supplied commands as a formatted String
        Parameters:
        botCommands - the Commands that should be included in the String
        Returns:
        a formatted String containing command and description for all supplied commands
      • getHelpText

        public static String getHelpText​(Collection<IBotCommand> botCommands)
        Returns the command and description of all supplied commands as a formatted String
        Parameters:
        botCommands - a collection of commands that should be included in the String
        Returns:
        a formatted String containing command and description for all supplied commands
      • getHelpText

        public static String getHelpText​(ICommandRegistry registry)
        Returns the command and description of all supplied commands as a formatted String
        Parameters:
        registry - a commandRegistry which commands are formatted into the String
        Returns:
        a formatted String containing command and description for all supplied commands
      • getManText

        public static String getManText​(IBotCommand command)
        Reads the extended Description from a BotCommand. If the Command is not of Type IManCommand, it calls toString();
        Parameters:
        command - a command the extended Descriptions is read from
        Returns:
        the extended Description or the toString() if IManCommand is not implemented
      • getManText

        public static String getManText​(IManCommand command)
        Reads the extended Description from a BotCommand;
        Parameters:
        command - a command the extended Descriptions is read from
        Returns:
        the extended Description
      • execute

        public void execute​(org.telegram.telegrambots.meta.bots.AbsSender absSender,
                            org.telegram.telegrambots.meta.api.objects.User user,
                            org.telegram.telegrambots.meta.api.objects.Chat chat,
                            String[] arguments)
        Description copied from class: BotCommand
        Execute the command
        Specified by:
        execute in class BotCommand
        Parameters:
        absSender - absSender to send messages over
        user - the user who sent the command
        chat - the chat, to be able to send replies
        arguments - passed arguments