use of org.pircbotx.hooks.events.PrivateMessageEvent in project LanteaBot by PC-Logix.
the class Permissions method getPermLevel.
public static int getPermLevel(User u, GenericMessageEvent event) {
String target = "";
String NSAccount = "";
if (event instanceof MessageEvent) {
NSAccount = Account.getAccount(u, (MessageEvent) event);
target = ((MessageEvent) event).getChannel().getName();
if (((MessageEvent) event).getChannel().getOps().contains(u)) {
return getPermLevel(Permissions.MOD);
}
} else if (event instanceof PrivateMessageEvent) {
return 0;
}
if (NSAccount == null) {
return 0;
}
try {
PreparedStatement getPerm = Database.getPreparedStatement("getUserPerms");
getPerm.setString(1, NSAccount);
getPerm.setString(2, target);
ResultSet results = getPerm.executeQuery();
if (results.next()) {
String rank = results.getString(1);
for (int i = 0; i < ranks.length; i++) {
if (ranks[i].equals(rank))
return i;
}
return 0;
} else {
return 0;
}
} catch (Exception e) {
e.printStackTrace();
return 0;
}
}
use of org.pircbotx.hooks.events.PrivateMessageEvent in project LanteaBot by PC-Logix.
the class Permissions method getRank.
public static String getRank(GenericMessageEvent event) {
User u = event.getUser();
String target = "";
String NSAccount = "";
if (event instanceof MessageEvent) {
NSAccount = Account.getAccount(u, (MessageEvent) event);
target = ((MessageEvent) event).getChannel().getName();
if (((MessageEvent) event).getChannel().getOps().contains(u)) {
return Permissions.MOD;
}
} else if (event instanceof PrivateMessageEvent) {
return "";
}
if (NSAccount == null) {
return "";
}
try {
PreparedStatement getPerm = Database.getPreparedStatement("getUserPerms");
getPerm.setString(1, NSAccount);
getPerm.setString(2, target);
ResultSet results = getPerm.executeQuery();
if (results.next()) {
return results.getString(1);
} else {
return "";
}
} catch (Exception e) {
e.printStackTrace();
return "";
}
}
Aggregations