aboutsummaryrefslogtreecommitdiff
path: root/juick-commands/src/main/java/com/juick/command/Login.java
blob: 3092a5f51d7956d95a1e5c5a5849812a49139cc5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package com.juick.command;

import com.juick.User;
import com.juick.service.UserService;
import lombok.Getter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.regex.Pattern;

/**
 * @author ma1uta
 */
@Component
@Getter
public class Login implements Command {

    private static final Pattern PATTERN = Pattern.compile("^login$", Pattern.CASE_INSENSITIVE);

    private final UserService userService;

    @Autowired
    public Login(UserService userService) {
        this.userService = userService;
    }

    @Override
    public Pattern pattern() {
        return PATTERN;
    }

    @Override
    public String help() {
        return "LOGIN - log in to Juick website";
    }

    @Override
    public String execute(User sender, MessageListener protocolListener, String command) {
        return "http://juick.com/login?hash=" + getUserService().getHashByUID(sender.getUid());
    }
}