Passed
Push — master ( 482350...d5f627 )
by Roannel Fernández
03:16
created

com.github.netkorp.telegram.framework.commands.basic.WhoAmICommand   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
dl 0
loc 24
rs 10
c 1
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A execute(Update,String[]) 0 4 1
A description() 0 3 1
1
package com.github.netkorp.telegram.framework.commands.basic;
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.condition.ExcludeCondition;
6
import org.springframework.context.annotation.Conditional;
7
import org.telegram.telegrambots.meta.api.objects.Update;
8
9
/**
10
 * Shows the chat identification for user who invoked the command.
11
 */
12
@TelegramCommand(name = "whoami", group = "Basic", secure = false)
13
@Conditional(ExcludeCondition.class)
14
public final class WhoAmICommand extends AbstractSimpleCommand {
15
16
    /**
17
     * Processes the data sent by the users.
18
     *
19
     * @param update the received message.
20
     * @param args   the parameters passed to the command execution.
21
     */
22
    @Override
23
    public void execute(Update update, String[] args) {
24
        Long idChat = update.getMessage().getChatId();
25
        bot.sendMessage(idChat.toString(), idChat);
26
    }
27
28
    /**
29
     * Returns the command's description, used to be displayed in help message.
30
     *
31
     * @return the command's description.
32
     */
33
    @Override
34
    public String description() {
35
        return "Shows the ID of the current chat.";
36
    }
37
}
38