Permalink
Browse files

Limit IRC console commands to those defined in the config.yml, build …

…Preview 8
  • Loading branch information...
1 parent 3d2df1e commit a0a3384721170d3fefb09734f0fe47c957d61f84 @Animosity committed Mar 5, 2011
Showing with 26 additions and 21 deletions.
  1. BIN beta/preview/CraftIRC.jar
  2. +25 −20 com/ensifera/animosity/craftirc/Minebot.java
  3. +1 −1 plugin.yml
View
Binary file not shown.
@@ -316,8 +316,9 @@ public void onMessage(String channel, String sender, String login, String hostna
if (this.plugin.isDebug()) {
CraftIRC.log.info(String.format(CraftIRC.NAME + " Authorized User %s executed command %s", sender, message));
}
+ return;
}
- return;
+
} else if (message.startsWith(cmdPrefix + "botsay ") && splitMessage.length > 1) {
if (this.channels.contains(splitMessage[1])) {
command = Util.combineSplit(2, splitMessage, " ");
@@ -334,26 +335,25 @@ public void onMessage(String channel, String sender, String login, String hostna
this.sendRawLine(command);
this.sendNotice(sender, "Raw IRC string sent");
return;
- } else {
- // IRCEvent - AUTHED_COMMAND
- if (this.plugin.isDebug()) {
- CraftIRC.log.info(String.format(CraftIRC.NAME + " Minebot IRCEVENT.AUTHED_COMMAND"));
- }
- RelayedMessage msg = this.plugin.newMsg(EndPoint.IRC, EndPoint.BOTH);
- msg.formatting = "";
- msg.sender = sender;
- msg.srcBot = botId;
- msg.srcChannel = channel;
- msg.message = message.replaceFirst(cmdPrefix, "");
- msg.updateTag();
- // PLUGIN INTEROP
- msg.setTarget(EndPoint.PLUGIN);
- Event ie = new IRCEvent(Mode.AUTHED_COMMAND, msg);
- this.plugin.getServer().getPluginManager().callEvent(ie);
- if (((IRCEvent)ie).isHandled()) return;
+ }
+ // IRCEvent - AUTHED_COMMAND
+ if (this.plugin.isDebug()) {
+ CraftIRC.log.info(String.format(CraftIRC.NAME + " Minebot IRCEVENT.AUTHED_COMMAND"));
}
-
+ RelayedMessage msg = this.plugin.newMsg(EndPoint.IRC, EndPoint.BOTH);
+ msg.formatting = "";
+ msg.sender = sender;
+ msg.srcBot = botId;
+ msg.srcChannel = channel;
+ msg.message = message.replaceFirst(cmdPrefix, "");
+ msg.updateTag();
+ // PLUGIN INTEROP
+ msg.setTarget(EndPoint.PLUGIN);
+ Event ie = new IRCEvent(Mode.AUTHED_COMMAND, msg);
+ this.plugin.getServer().getPluginManager().callEvent(ie);
+ if (((IRCEvent)ie).isHandled()) return;
+
} // End admin commands
// Begin public commands
@@ -510,7 +510,12 @@ private boolean routeCommand(String fullCommand, RelayedMessage ircConCmd) {
//if (!this.plugin.defaultConsoleCommands.contains(rootCommand))
// return false;
- if (this.plugin.cConsoleCommands().contains(rootCommand)) {
+ if (!this.plugin.cConsoleCommands().contains(rootCommand)){
+ if (this.plugin.isDebug()) { CraftIRC.log.info(String.format(CraftIRC.NAME + " Console command: %s not found in config.yml",rootCommand)); }
+ return false;
+ }
+
+ if (this.plugin.defaultConsoleCommands.contains(rootCommand)) {
if (this.plugin.isDebug()) {
CraftIRC.log.info(String.format(CraftIRC.NAME + " Minebot routeCommand(default) fullCommand=" + fullCommand
+ " -- rootCommand=" + rootCommand));
View
@@ -1,6 +1,6 @@
name: CraftIRC
main: com.ensifera.animosity.craftirc.CraftIRC
-version: 2.0 Preview 7
+version: 2.0 Preview 8
commands:
irc:
description: Sends a message to all IRC channels

0 comments on commit a0a3384

Please sign in to comment.