forked from maradine/swagmower
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPermissionsHandler.java
49 lines (37 loc) · 1.24 KB
/
PermissionsHandler.java
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
import org.pircbotx.hooks.ListenerAdapter;
import org.pircbotx.hooks.events.MessageEvent;
import org.pircbotx.User;
import java.util.Scanner;
import java.util.Collections;
import java.util.LinkedList;
public class PermissionsHandler extends ListenerAdapter {
private Scanner scanner;
private PermissionsManager pm;
public PermissionsHandler() {
super();
this.pm = PermissionsManager.getInstance();
System.out.println("PermissionsHandler initialized.");
}
public void onMessage(MessageEvent event) {
String rawcommand = event.getMessage();
String command = rawcommand.toLowerCase();
if (command.equals("!lock")){
if (!pm.isAllowed(command,event.getUser(),event.getChannel())) {
event.respond("Sorry, you do not have permission to execute this command.");
return;
}
pm.lock();
event.respond("Bot is now locked. Only the owner at instantiation can run restricted commands.");
return;
}
if (command.equals("!unlock")){
if (!pm.isAllowed(command,event.getUser(),event.getChannel())) {
event.respond("Sorry, you do not have permission to execute this command.");
return;
}
pm.unlock();
event.respond("Bot is now unlocked. Any Op can run restricted commands.");
return;
}
}
}