| Total Complexity | 3 |
| Total Lines | 36 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | package com.github.netkorp.overridebasiccommand.commands; |
||
| 11 | @Component |
||
| 12 | @FreeCommand |
||
| 13 | public class OwnHelpCommand extends AbstractCommand implements HelpCommand { |
||
| 14 | |||
| 15 | /** |
||
| 16 | * Returns the commands that will be executed on the chat. |
||
| 17 | * |
||
| 18 | * @return Command to be executed. |
||
| 19 | */ |
||
| 20 | @Override |
||
| 21 | public String getName() { |
||
| 22 | return "assistance"; |
||
| 23 | } |
||
| 24 | |||
| 25 | /** |
||
| 26 | * Processes the data of the commands. |
||
| 27 | * |
||
| 28 | * @param update The received message. |
||
| 29 | */ |
||
| 30 | @Override |
||
| 31 | public void execute(Update update) { |
||
| 32 | StringJoiner stringJoiner = new StringJoiner(System.lineSeparator()); |
||
| 33 | stringJoiner.add("Commands:"); |
||
| 34 | commandManager.getAvailableFreeCommands() |
||
| 35 | .forEach(command -> stringJoiner.add(String.format("%s - <b>%s</b>", command.command(), command.description()))); |
||
| 36 | bot.sendMessage(stringJoiner.toString(), update.getMessage().getChatId(), true); |
||
| 37 | } |
||
| 38 | |||
| 39 | /** |
||
| 40 | * Returns the description of the commands. |
||
| 41 | * |
||
| 42 | * @return The description. |
||
| 43 | */ |
||
| 44 | @Override |
||
| 45 | public String description() { |
||
| 46 | return "Displays an assistance message"; |
||
| 47 | } |
||
| 49 |