Passed
Push — master ( 1e545e...f6131a )
by Roannel Fernández
02:58
created

description()   A

Complexity

Conditions 1

Size

Total Lines 3
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
1
package com.github.netkorp.overridebasiccommand.commands;
2
3
import com.github.netkorp.telegram.framework.annotations.FreeCommand;
4
import com.github.netkorp.telegram.framework.commands.abstracts.AbstractCommand;
5
import com.github.netkorp.telegram.framework.commands.interfaces.HelpCommand;
6
import org.springframework.stereotype.Component;
7
import org.telegram.telegrambots.meta.api.objects.Update;
8
9
import java.util.StringJoiner;
10
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
    }
48
}
49