Skip to content
This repository has been archived by the owner on Jul 27, 2019. It is now read-only.

Commit

Permalink
Ignore blank invalid-irc-command messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
cnaude committed Jun 21, 2014
1 parent ed24e2c commit 537aa9e
Showing 1 changed file with 28 additions and 24 deletions.
52 changes: 28 additions & 24 deletions src/main/java/com/cnaude/purpleirc/Utilities/IRCMessageHandler.java
Expand Up @@ -88,7 +88,7 @@ public void processMessage(PurpleBot ircBot, User user, Channel channel, String

boolean modeOkay = false;
boolean permOkay = checkPerm(perm, user.getNick());

if (modes.equals("*")) {
modeOkay = true;
}
Expand All @@ -109,7 +109,7 @@ public void processMessage(PurpleBot ircBot, User user, Channel channel, String
}
if (modes.contains("s") && !modeOkay) {
modeOkay = user.getChannelsSuperOpIn().contains(channel);
}
}

if (modeOkay && permOkay) {
switch (gameCommand) {
Expand Down Expand Up @@ -147,16 +147,20 @@ public void processMessage(PurpleBot ircBot, User user, Channel channel, String
default:
if (commandArgs == null) {
commandArgs = "";
} if (gameCommand.contains("%ARGS%")) {
gameCommand = gameCommand.replace("%ARGS%", commandArgs);
} if (gameCommand.contains("%NAME%")) {
gameCommand = gameCommand.replace("%NAME%", user.getNick());
} plugin.logDebug("GM: \"" + gameCommand.trim() + "\"");
try {
plugin.commandQueue.add(new IRCCommand(new IRCCommandSender(ircBot, target, plugin, ctcpResponse), gameCommand.trim()));
} catch (Exception ex) {
plugin.logError(ex.getMessage());
} break;
}
if (gameCommand.contains("%ARGS%")) {
gameCommand = gameCommand.replace("%ARGS%", commandArgs);
}
if (gameCommand.contains("%NAME%")) {
gameCommand = gameCommand.replace("%NAME%", user.getNick());
}
plugin.logDebug("GM: \"" + gameCommand.trim() + "\"");
try {
plugin.commandQueue.add(new IRCCommand(new IRCCommandSender(ircBot, target, plugin, ctcpResponse), gameCommand.trim()));
} catch (Exception ex) {
plugin.logError(ex.getMessage());
}
break;
}
} else {
plugin.logDebug("User '" + user.getNick() + "' mode not okay.");
Expand All @@ -170,16 +174,16 @@ public void processMessage(PurpleBot ircBot, User user, Channel channel, String
target = user.getNick();
}
plugin.logDebug("Invalid command: " + command);
if (ircBot.invalidCommandCTCP.get(myChannel)) {
ircBot.blockingCTCPMessage(target, plugin.getMsgTemplate(
ircBot.botNick, TemplateName.INVALID_IRC_COMMAND)
.replace("%NICK%", user.getNick())
.replace("%CMDPREFIX%", ircBot.commandPrefix));
} else {
ircBot.asyncIRCMessage(target, plugin.getMsgTemplate(
ircBot.botNick, TemplateName.INVALID_IRC_COMMAND)
.replace("%NICK%", user.getNick())
.replace("%CMDPREFIX%", ircBot.commandPrefix));
String invalidIrcCommand = plugin.getMsgTemplate(
ircBot.botNick, TemplateName.INVALID_IRC_COMMAND)
.replace("%NICK%", user.getNick())
.replace("%CMDPREFIX%", ircBot.commandPrefix);
if (!invalidIrcCommand.isEmpty()) {
if (ircBot.invalidCommandCTCP.get(myChannel)) {
ircBot.blockingCTCPMessage(target, invalidIrcCommand);
} else {
ircBot.asyncIRCMessage(target, invalidIrcCommand);
}
}
}
} else {
Expand Down Expand Up @@ -223,8 +227,8 @@ private boolean checkPerm(String perm, String playerName) {
if (perm.isEmpty()) {
return true;
}
Player player = plugin.getServer().getPlayer(playerName);
Player player = plugin.getServer().getPlayer(playerName);

if (player != null) {
plugin.logDebug("[checkPerm] Player " + playerName + " permission node " + perm + "=" + player.hasPermission(perm));
return player.hasPermission(perm);
Expand Down

0 comments on commit 537aa9e

Please sign in to comment.