-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQuote.java
More file actions
53 lines (46 loc) · 1.29 KB
/
Quote.java
File metadata and controls
53 lines (46 loc) · 1.29 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
import java.util.ArrayList;
import java.util.HashMap;
public class Quote implements Module {
private boolean admin;
private Message m;
private HashMap<String, ArrayList<String>> quotes;
public Quote(){
quotes = new HashMap<String, ArrayList<String>>();
}
@Override
public String[] outputs() {
String[] outputs = new String[1];
String target = "PRIVMSG " + m.getParam();
if(!m.getParam().startsWith("#")) target = "NOTICE " + m.getSender();
if(m.isBotCommand()){
if(m.getBotCommand().equals("quote")){
if(m.hasBotParams()){
String user = m.getBotParams().get(0);
if(quotes.get(user) != null){
int random = (int)Math.floor(Math.random() * quotes.get(user).size());
outputs[0] = target + " :<" + user + "> " + quotes.get(user).get(random);
return outputs;
}
}
}
}
else if(m.getCommand().equals("PRIVMSG")){
if(quotes.get(m.getSender()) == null){
ArrayList<String> temp = new ArrayList<String>();
temp.add(m.getTrailing());
quotes.put(m.getSender(), temp);
}
else{
ArrayList<String> temp = quotes.get(m.getSender());
temp.add(m.getTrailing());
quotes.put(m.getSender(), temp);
}
}
return null;
}
@Override
public void parse(Message message, boolean isadmin) {
m = message;
admin = isadmin;
}
}