diff --git a/telegrambots-extensions/src/main/java/org/telegram/telegrambots/bots/commandbot/TelegramLongPollingCommandBot.java b/telegrambots-extensions/src/main/java/org/telegram/telegrambots/extensions/bots/commandbot/TelegramLongPollingCommandBot.java similarity index 93% rename from telegrambots-extensions/src/main/java/org/telegram/telegrambots/bots/commandbot/TelegramLongPollingCommandBot.java rename to telegrambots-extensions/src/main/java/org/telegram/telegrambots/extensions/bots/commandbot/TelegramLongPollingCommandBot.java index 7bf923f2..8bb39742 100644 --- a/telegrambots-extensions/src/main/java/org/telegram/telegrambots/bots/commandbot/TelegramLongPollingCommandBot.java +++ b/telegrambots-extensions/src/main/java/org/telegram/telegrambots/extensions/bots/commandbot/TelegramLongPollingCommandBot.java @@ -1,4 +1,4 @@ -package org.telegram.telegrambots.bots.commandbot; +package org.telegram.telegrambots.extensions.bots.commandbot; import org.telegram.telegrambots.meta.ApiContext; @@ -7,10 +7,9 @@ import org.telegram.telegrambots.meta.api.objects.Update; import org.telegram.telegrambots.meta.bots.AbsSender; import org.telegram.telegrambots.bots.DefaultBotOptions; import org.telegram.telegrambots.bots.TelegramLongPollingBot; -import org.telegram.telegrambots.bots.commandbot.commands.BotCommand; -import org.telegram.telegrambots.bots.commandbot.commands.CommandRegistry; -import org.telegram.telegrambots.bots.commandbot.commands.IBotCommand; -import org.telegram.telegrambots.bots.commandbot.commands.ICommandRegistry; +import org.telegram.telegrambots.extensions.bots.commandbot.commands.CommandRegistry; +import org.telegram.telegrambots.extensions.bots.commandbot.commands.IBotCommand; +import org.telegram.telegrambots.extensions.bots.commandbot.commands.ICommandRegistry; import java.util.Collection; import java.util.Map; diff --git a/telegrambots-extensions/src/main/java/org/telegram/telegrambots/bots/commandbot/commands/BotCommand.java b/telegrambots-extensions/src/main/java/org/telegram/telegrambots/extensions/bots/commandbot/commands/BotCommand.java similarity index 97% rename from telegrambots-extensions/src/main/java/org/telegram/telegrambots/bots/commandbot/commands/BotCommand.java rename to telegrambots-extensions/src/main/java/org/telegram/telegrambots/extensions/bots/commandbot/commands/BotCommand.java index 40994049..33d09c92 100644 --- a/telegrambots-extensions/src/main/java/org/telegram/telegrambots/bots/commandbot/commands/BotCommand.java +++ b/telegrambots-extensions/src/main/java/org/telegram/telegrambots/extensions/bots/commandbot/commands/BotCommand.java @@ -1,4 +1,4 @@ -package org.telegram.telegrambots.bots.commandbot.commands; +package org.telegram.telegrambots.extensions.bots.commandbot.commands; import org.telegram.telegrambots.meta.api.objects.Chat; import org.telegram.telegrambots.meta.api.objects.Message; diff --git a/telegrambots-extensions/src/main/java/org/telegram/telegrambots/bots/commandbot/commands/CommandRegistry.java b/telegrambots-extensions/src/main/java/org/telegram/telegrambots/extensions/bots/commandbot/commands/CommandRegistry.java similarity index 98% rename from telegrambots-extensions/src/main/java/org/telegram/telegrambots/bots/commandbot/commands/CommandRegistry.java rename to telegrambots-extensions/src/main/java/org/telegram/telegrambots/extensions/bots/commandbot/commands/CommandRegistry.java index e1967d00..fdd3771b 100644 --- a/telegrambots-extensions/src/main/java/org/telegram/telegrambots/bots/commandbot/commands/CommandRegistry.java +++ b/telegrambots-extensions/src/main/java/org/telegram/telegrambots/extensions/bots/commandbot/commands/CommandRegistry.java @@ -1,4 +1,4 @@ -package org.telegram.telegrambots.bots.commandbot.commands; +package org.telegram.telegrambots.extensions.bots.commandbot.commands; import org.telegram.telegrambots.meta.api.objects.Message; import org.telegram.telegrambots.meta.bots.AbsSender; diff --git a/telegrambots-extensions/src/main/java/org/telegram/telegrambots/bots/commandbot/commands/DefaultBotCommand.java b/telegrambots-extensions/src/main/java/org/telegram/telegrambots/extensions/bots/commandbot/commands/DefaultBotCommand.java similarity index 96% rename from telegrambots-extensions/src/main/java/org/telegram/telegrambots/bots/commandbot/commands/DefaultBotCommand.java rename to telegrambots-extensions/src/main/java/org/telegram/telegrambots/extensions/bots/commandbot/commands/DefaultBotCommand.java index 69150a07..58aed29b 100644 --- a/telegrambots-extensions/src/main/java/org/telegram/telegrambots/bots/commandbot/commands/DefaultBotCommand.java +++ b/telegrambots-extensions/src/main/java/org/telegram/telegrambots/extensions/bots/commandbot/commands/DefaultBotCommand.java @@ -1,4 +1,4 @@ -package org.telegram.telegrambots.bots.commandbot.commands; +package org.telegram.telegrambots.extensions.bots.commandbot.commands; import org.telegram.telegrambots.meta.api.objects.Chat; import org.telegram.telegrambots.meta.api.objects.Message; diff --git a/telegrambots-extensions/src/main/java/org/telegram/telegrambots/bots/commandbot/commands/IBotCommand.java b/telegrambots-extensions/src/main/java/org/telegram/telegrambots/extensions/bots/commandbot/commands/IBotCommand.java similarity index 83% rename from telegrambots-extensions/src/main/java/org/telegram/telegrambots/bots/commandbot/commands/IBotCommand.java rename to telegrambots-extensions/src/main/java/org/telegram/telegrambots/extensions/bots/commandbot/commands/IBotCommand.java index fe0d0c0b..13cf3a2a 100644 --- a/telegrambots-extensions/src/main/java/org/telegram/telegrambots/bots/commandbot/commands/IBotCommand.java +++ b/telegrambots-extensions/src/main/java/org/telegram/telegrambots/extensions/bots/commandbot/commands/IBotCommand.java @@ -1,12 +1,8 @@ -package org.telegram.telegrambots.bots.commandbot.commands; +package org.telegram.telegrambots.extensions.bots.commandbot.commands; import org.telegram.telegrambots.meta.api.objects.Message; import org.telegram.telegrambots.meta.bots.AbsSender; -import java.util.Collection; -import java.util.Map; -import java.util.function.BiConsumer; - /** * This Interface represents the a Command that can be executed * diff --git a/telegrambots-extensions/src/main/java/org/telegram/telegrambots/bots/commandbot/commands/ICommandRegistry.java b/telegrambots-extensions/src/main/java/org/telegram/telegrambots/extensions/bots/commandbot/commands/ICommandRegistry.java similarity index 96% rename from telegrambots-extensions/src/main/java/org/telegram/telegrambots/bots/commandbot/commands/ICommandRegistry.java rename to telegrambots-extensions/src/main/java/org/telegram/telegrambots/extensions/bots/commandbot/commands/ICommandRegistry.java index e5253259..4b3c7565 100644 --- a/telegrambots-extensions/src/main/java/org/telegram/telegrambots/bots/commandbot/commands/ICommandRegistry.java +++ b/telegrambots-extensions/src/main/java/org/telegram/telegrambots/extensions/bots/commandbot/commands/ICommandRegistry.java @@ -1,4 +1,4 @@ -package org.telegram.telegrambots.bots.commandbot.commands; +package org.telegram.telegrambots.extensions.bots.commandbot.commands; import org.telegram.telegrambots.meta.api.objects.Message; import org.telegram.telegrambots.meta.bots.AbsSender; diff --git a/telegrambots-extensions/src/main/java/org/telegram/telegrambots/bots/commandbot/commands/helpCommand/HelpCommand.java b/telegrambots-extensions/src/main/java/org/telegram/telegrambots/extensions/bots/commandbot/commands/helpCommand/HelpCommand.java similarity index 93% rename from telegrambots-extensions/src/main/java/org/telegram/telegrambots/bots/commandbot/commands/helpCommand/HelpCommand.java rename to telegrambots-extensions/src/main/java/org/telegram/telegrambots/extensions/bots/commandbot/commands/helpCommand/HelpCommand.java index beafa244..65344615 100644 --- a/telegrambots-extensions/src/main/java/org/telegram/telegrambots/bots/commandbot/commands/helpCommand/HelpCommand.java +++ b/telegrambots-extensions/src/main/java/org/telegram/telegrambots/extensions/bots/commandbot/commands/helpCommand/HelpCommand.java @@ -1,116 +1,116 @@ -package org.telegram.telegrambots.bots.commandbot.commands.helpCommand; - -import org.telegram.telegrambots.meta.api.methods.send.SendMessage; -import org.telegram.telegrambots.meta.api.objects.Chat; -import org.telegram.telegrambots.meta.api.objects.User; -import org.telegram.telegrambots.meta.bots.AbsSender; -import org.telegram.telegrambots.bots.commandbot.commands.IBotCommand; -import org.telegram.telegrambots.bots.commandbot.commands.ICommandRegistry; -import org.telegram.telegrambots.meta.exceptions.TelegramApiException; - -import java.util.Collection; - -/** - * A special bot command used for printing help messages similiar to the Linux man command. - * The commands printed by this command should implement the {@link IManCommand} interface to provide an extended description. - * @author Lukas Prediger(Chase) - * @version 1.0.0 - * - */ -public class HelpCommand extends ManCommand { - - private static final String COMMAND_IDENTIFIER = "help"; - private static final String COMMAND_DESCRIPTION = "shows all commands. Use /help [command] for more info"; - private static final String EXTENDED_DESCRIPTION = "This command displays all commands the bot has to offer.\n /help [command] can display deeper information"; - - /** - * Returns the command and description of all supplied commands as a formatted String - * @param botCommands the Commands that should be included in the String - * @return a formatted String containing command and description for all supplied commands - */ - public static String getHelpText(IBotCommand...botCommands) { - StringBuilder reply = new StringBuilder(); - for (IBotCommand com : botCommands) { - reply.append(com.toString()).append(System.lineSeparator()).append(System.lineSeparator()); - } - return reply.toString(); - } - - /** - * Returns the command and description of all supplied commands as a formatted String - * @param botCommands a collection of commands that should be included in the String - * @return a formatted String containing command and description for all supplied commands - */ - public static String getHelpText(Collection botCommands) { - return getHelpText(botCommands.toArray(new IBotCommand[botCommands.size()])); - } - - /** - * Returns the command and description of all supplied commands as a formatted String - * @param registry a commandRegistry which commands are formatted into the String - * @return a formatted String containing command and description for all supplied commands - */ - public static String getHelpText(ICommandRegistry registry) { - return getHelpText(registry.getRegisteredCommands()); - } - - /** - * Reads the extended Description from a BotCommand. If the Command is not of Type {@link IManCommand}, it calls toString(); - * @param command a command the extended Descriptions is read from - * @return the extended Description or the toString() if IManCommand is not implemented - */ - public static String getManText(IBotCommand command) { - return IManCommand.class.isInstance(command) ? getManText((IManCommand) command) : command.toString(); - } - - /** - * Reads the extended Description from a BotCommand; - * @param command a command the extended Descriptions is read from - * @return the extended Description - */ - public static String getManText(IManCommand command) { - return command.toMan(); - } - - /** - * Create a Help command with the standard Arguments. - */ - public HelpCommand() { - super(COMMAND_IDENTIFIER, COMMAND_DESCRIPTION, EXTENDED_DESCRIPTION); - } - - /** - * Creates a Help Command with custom identifier, description and extended Description - * @param commandIdentifier the unique identifier of this command (e.g. the command string to enter into chat) - * @param description the description of this command - * @param extendedDescription The extended Description for the Command, should provide detailed information about arguments and possible options - */ - public HelpCommand(String commandIdentifier, String description, String extendedDescription) { - super(commandIdentifier, description, extendedDescription); - } - - @Override - public void execute(AbsSender absSender, User user, Chat chat, String[] arguments) { - if (ICommandRegistry.class.isInstance(absSender)) { - ICommandRegistry registry = (ICommandRegistry) absSender; - - if (arguments.length > 0) { - IBotCommand command = registry.getRegisteredCommand(arguments[0]); - String reply = getManText(command); - try { - absSender.execute(new SendMessage(chat.getId(), reply).setParseMode("HTML")); - } catch (TelegramApiException e) { - e.printStackTrace(); - } - } else { - String reply = getHelpText(registry); - try { - absSender.execute(new SendMessage(chat.getId(), reply).setParseMode("HTML")); - } catch (TelegramApiException e) { - e.printStackTrace(); - } - } - } - } - -} +package org.telegram.telegrambots.extensions.bots.commandbot.commands.helpCommand; + +import org.telegram.telegrambots.meta.api.methods.send.SendMessage; +import org.telegram.telegrambots.meta.api.objects.Chat; +import org.telegram.telegrambots.meta.api.objects.User; +import org.telegram.telegrambots.meta.bots.AbsSender; +import org.telegram.telegrambots.extensions.bots.commandbot.commands.IBotCommand; +import org.telegram.telegrambots.extensions.bots.commandbot.commands.ICommandRegistry; +import org.telegram.telegrambots.meta.exceptions.TelegramApiException; + +import java.util.Collection; + +/** + * A special bot command used for printing help messages similiar to the Linux man command. + * The commands printed by this command should implement the {@link IManCommand} interface to provide an extended description. + * @author Lukas Prediger(Chase) + * @version 1.0.0 + * + */ +public class HelpCommand extends ManCommand { + + private static final String COMMAND_IDENTIFIER = "help"; + private static final String COMMAND_DESCRIPTION = "shows all commands. Use /help [command] for more info"; + private static final String EXTENDED_DESCRIPTION = "This command displays all commands the bot has to offer.\n /help [command] can display deeper information"; + + /** + * Returns the command and description of all supplied commands as a formatted String + * @param botCommands the Commands that should be included in the String + * @return a formatted String containing command and description for all supplied commands + */ + public static String getHelpText(IBotCommand...botCommands) { + StringBuilder reply = new StringBuilder(); + for (IBotCommand com : botCommands) { + reply.append(com.toString()).append(System.lineSeparator()).append(System.lineSeparator()); + } + return reply.toString(); + } + + /** + * Returns the command and description of all supplied commands as a formatted String + * @param botCommands a collection of commands that should be included in the String + * @return a formatted String containing command and description for all supplied commands + */ + public static String getHelpText(Collection botCommands) { + return getHelpText(botCommands.toArray(new IBotCommand[botCommands.size()])); + } + + /** + * Returns the command and description of all supplied commands as a formatted String + * @param registry a commandRegistry which commands are formatted into the String + * @return a formatted String containing command and description for all supplied commands + */ + public static String getHelpText(ICommandRegistry registry) { + return getHelpText(registry.getRegisteredCommands()); + } + + /** + * Reads the extended Description from a BotCommand. If the Command is not of Type {@link IManCommand}, it calls toString(); + * @param command a command the extended Descriptions is read from + * @return the extended Description or the toString() if IManCommand is not implemented + */ + public static String getManText(IBotCommand command) { + return IManCommand.class.isInstance(command) ? getManText((IManCommand) command) : command.toString(); + } + + /** + * Reads the extended Description from a BotCommand; + * @param command a command the extended Descriptions is read from + * @return the extended Description + */ + public static String getManText(IManCommand command) { + return command.toMan(); + } + + /** + * Create a Help command with the standard Arguments. + */ + public HelpCommand() { + super(COMMAND_IDENTIFIER, COMMAND_DESCRIPTION, EXTENDED_DESCRIPTION); + } + + /** + * Creates a Help Command with custom identifier, description and extended Description + * @param commandIdentifier the unique identifier of this command (e.g. the command string to enter into chat) + * @param description the description of this command + * @param extendedDescription The extended Description for the Command, should provide detailed information about arguments and possible options + */ + public HelpCommand(String commandIdentifier, String description, String extendedDescription) { + super(commandIdentifier, description, extendedDescription); + } + + @Override + public void execute(AbsSender absSender, User user, Chat chat, String[] arguments) { + if (ICommandRegistry.class.isInstance(absSender)) { + ICommandRegistry registry = (ICommandRegistry) absSender; + + if (arguments.length > 0) { + IBotCommand command = registry.getRegisteredCommand(arguments[0]); + String reply = getManText(command); + try { + absSender.execute(new SendMessage(chat.getId(), reply).setParseMode("HTML")); + } catch (TelegramApiException e) { + e.printStackTrace(); + } + } else { + String reply = getHelpText(registry); + try { + absSender.execute(new SendMessage(chat.getId(), reply).setParseMode("HTML")); + } catch (TelegramApiException e) { + e.printStackTrace(); + } + } + } + } + +} diff --git a/telegrambots-extensions/src/main/java/org/telegram/telegrambots/bots/commandbot/commands/helpCommand/IManCommand.java b/telegrambots-extensions/src/main/java/org/telegram/telegrambots/extensions/bots/commandbot/commands/helpCommand/IManCommand.java similarity index 86% rename from telegrambots-extensions/src/main/java/org/telegram/telegrambots/bots/commandbot/commands/helpCommand/IManCommand.java rename to telegrambots-extensions/src/main/java/org/telegram/telegrambots/extensions/bots/commandbot/commands/helpCommand/IManCommand.java index 67e15d63..5d1e6a57 100644 --- a/telegrambots-extensions/src/main/java/org/telegram/telegrambots/bots/commandbot/commands/helpCommand/IManCommand.java +++ b/telegrambots-extensions/src/main/java/org/telegram/telegrambots/extensions/bots/commandbot/commands/helpCommand/IManCommand.java @@ -1,21 +1,21 @@ -package org.telegram.telegrambots.bots.commandbot.commands.helpCommand; - -/** - * Represents a Command that, aside the normal command description provides an extended Description similar to the output of the Linux man command - * @author Lukas Prediger(Chase) - * @version 1.0.0 - */ -public interface IManCommand { - /** - * Returns the extended Description of this command - * @return the extendedDescription - */ - String getExtendedDescription(); - - /** - * Returns a String Representations of the Command and it's extended Description. - * @return a String representing the Command and it's extended Description - */ - String toMan(); - +package org.telegram.telegrambots.extensions.bots.commandbot.commands.helpCommand; + +/** + * Represents a Command that, aside the normal command description provides an extended Description similar to the output of the Linux man command + * @author Lukas Prediger(Chase) + * @version 1.0.0 + */ +public interface IManCommand { + /** + * Returns the extended Description of this command + * @return the extendedDescription + */ + String getExtendedDescription(); + + /** + * Returns a String Representations of the Command and it's extended Description. + * @return a String representing the Command and it's extended Description + */ + String toMan(); + } \ No newline at end of file diff --git a/telegrambots-extensions/src/main/java/org/telegram/telegrambots/bots/commandbot/commands/helpCommand/ManCommand.java b/telegrambots-extensions/src/main/java/org/telegram/telegrambots/extensions/bots/commandbot/commands/helpCommand/ManCommand.java similarity index 75% rename from telegrambots-extensions/src/main/java/org/telegram/telegrambots/bots/commandbot/commands/helpCommand/ManCommand.java rename to telegrambots-extensions/src/main/java/org/telegram/telegrambots/extensions/bots/commandbot/commands/helpCommand/ManCommand.java index 1f645b7a..fff709ca 100644 --- a/telegrambots-extensions/src/main/java/org/telegram/telegrambots/bots/commandbot/commands/helpCommand/ManCommand.java +++ b/telegrambots-extensions/src/main/java/org/telegram/telegrambots/extensions/bots/commandbot/commands/helpCommand/ManCommand.java @@ -1,41 +1,41 @@ -package org.telegram.telegrambots.bots.commandbot.commands.helpCommand; - -import org.telegram.telegrambots.bots.commandbot.commands.BotCommand; - -public abstract class ManCommand extends BotCommand implements IManCommand { - - private final String extendedDescription; - - /** - * Create a new ManCommand providing a commandIdentifier, a short description and the extended description - * @param commandIdentifier the unique identifier of this command (e.g. the command string to enter into chat) - * @param description the description of this command - * @param extendedDescription The extended Description for the Command, should provide detailed information about arguments and possible options - */ - public ManCommand(String commandIdentifier, String description, String extendedDescription) { - super(commandIdentifier, description); - this.extendedDescription = extendedDescription; - } - - /* (non-Javadoc) - * @see org.telegram.telegrambots.bots.commandbot.commands.helpCommand.IManCommand#getExtendedDescription() - */ - @Override - public String getExtendedDescription() { - return extendedDescription; - } - - /* (non-Javadoc) - * @see org.telegram.telegrambots.bots.commandbot.commands.helpCommand.IManCommand#toMan() - */ - @Override - public String toMan() { - StringBuilder sb = new StringBuilder(toString()); - sb.append(System.lineSeparator()) - .append("-----------------") - .append(System.lineSeparator()); - if (getExtendedDescription() != null) sb.append(getExtendedDescription()); - return sb.toString(); - } - -} +package org.telegram.telegrambots.extensions.bots.commandbot.commands.helpCommand; + +import org.telegram.telegrambots.extensions.bots.commandbot.commands.BotCommand; + +public abstract class ManCommand extends BotCommand implements IManCommand { + + private final String extendedDescription; + + /** + * Create a new ManCommand providing a commandIdentifier, a short description and the extended description + * @param commandIdentifier the unique identifier of this command (e.g. the command string to enter into chat) + * @param description the description of this command + * @param extendedDescription The extended Description for the Command, should provide detailed information about arguments and possible options + */ + public ManCommand(String commandIdentifier, String description, String extendedDescription) { + super(commandIdentifier, description); + this.extendedDescription = extendedDescription; + } + + /* (non-Javadoc) + * @see org.telegram.telegrambots.extensions.bots.commandbot.commands.helpCommand.IManCommand#getExtendedDescription() + */ + @Override + public String getExtendedDescription() { + return extendedDescription; + } + + /* (non-Javadoc) + * @see org.telegram.telegrambots.extensions.bots.commandbot.commands.helpCommand.IManCommand#toMan() + */ + @Override + public String toMan() { + StringBuilder sb = new StringBuilder(toString()); + sb.append(System.lineSeparator()) + .append("-----------------") + .append(System.lineSeparator()); + if (getExtendedDescription() != null) sb.append(getExtendedDescription()); + return sb.toString(); + } + +} diff --git a/telegrambots-extensions/src/main/java/org/telegram/telegrambots/bots/timedbot/TimedSendLongPollingBot.java b/telegrambots-extensions/src/main/java/org/telegram/telegrambots/extensions/bots/timedbot/TimedSendLongPollingBot.java similarity index 99% rename from telegrambots-extensions/src/main/java/org/telegram/telegrambots/bots/timedbot/TimedSendLongPollingBot.java rename to telegrambots-extensions/src/main/java/org/telegram/telegrambots/extensions/bots/timedbot/TimedSendLongPollingBot.java index 734c52a4..7de54f7e 100644 --- a/telegrambots-extensions/src/main/java/org/telegram/telegrambots/bots/timedbot/TimedSendLongPollingBot.java +++ b/telegrambots-extensions/src/main/java/org/telegram/telegrambots/extensions/bots/timedbot/TimedSendLongPollingBot.java @@ -1,4 +1,4 @@ -package org.telegram.telegrambots.bots.timedbot; +package org.telegram.telegrambots.extensions.bots.timedbot; import org.telegram.telegrambots.bots.TelegramLongPollingBot;