com.github.netkorp.overridebasiccommand.commands.OwnHelpCommand   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 4
Bugs 0 Features 0
Metric Value
eloc 12
c 4
b 0
f 0
dl 0
loc 19
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A execute(Update,String[]) 0 10 1
1
package com.github.netkorp.overridebasiccommand.commands;
2
3
import com.github.netkorp.telegram.framework.annotations.TelegramCommand;
4
import com.github.netkorp.telegram.framework.commands.abstracts.AbstractSimpleCommand;
5
import com.github.netkorp.telegram.framework.commands.interfaces.HelpCommand;
6
import com.github.netkorp.telegram.framework.managers.CommandManager;
7
import org.springframework.context.i18n.LocaleContextHolder;
8
import org.telegram.telegrambots.meta.api.objects.Update;
9
10
import java.util.StringJoiner;
11
12
@TelegramCommand(name = "assistance", secure = false)
13
public class OwnHelpCommand extends AbstractSimpleCommand implements HelpCommand {
14
15
    /**
16
     * Processes the data sent by the users.
17
     *
18
     * @param update the received message.
19
     * @param args   the parameters passed to the command execution.
20
     */
21
    @Override
22
    public void execute(Update update, String[] args) {
23
        StringJoiner stringJoiner = new StringJoiner(System.lineSeparator());
24
        stringJoiner.add(String.format("%s:", messageSource.getMessage("commands.ownhelp.title", null,
25
                LocaleContextHolder.getLocale())));
26
        commandManager.getAvailableNonSecureCommands()
27
                .forEach(command -> stringJoiner.add(String.format("%s - <b>%s</b>", CommandManager.getCommandFullNames(command),
28
                        messageSource.getMessage(command.getClass().getAnnotation(TelegramCommand.class).description(),
29
                                null, LocaleContextHolder.getLocale()))));
30
        bot.sendMessage(stringJoiner.toString(), update.getMessage().getChatId(), true);
31
    }
32
}
33