-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
170 additions
and
447 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package ml.duncte123.skybot; | ||
|
||
import net.dv8tion.jda.core.events.Event; | ||
import net.dv8tion.jda.core.hooks.IEventManager; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
/** | ||
* A single event listener container | ||
*/ | ||
public class EventManager | ||
implements IEventManager { | ||
|
||
private static final Logger logger = LoggerFactory.getLogger(EventManager.class); | ||
|
||
private BotListener botListener = new BotListener(); | ||
|
||
@Override | ||
public void register(Object listener) { | ||
throw new IllegalArgumentException(); | ||
} | ||
|
||
@Override | ||
public void unregister(Object listener) { | ||
throw new IllegalArgumentException(); | ||
} | ||
|
||
@Override | ||
public void handle(Event event) { | ||
try { | ||
botListener.onEvent(event); | ||
} catch (Throwable thr) { | ||
logger.warn("Error while handling event " + event + "; " + thr.getLocalizedMessage(), thr); | ||
} | ||
} | ||
|
||
@Override | ||
public List<Object> getRegisteredListeners() { | ||
return Arrays.asList(botListener); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
src/main/java/ml/duncte123/skybot/objects/delegate/ScriptDelegate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
* Skybot, a multipurpose discord bot | ||
* Copyright (C) 2017 Duncan "duncte123" Sterken & Ramid "ramidzkh" Khan & Sanduhr32 | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published | ||
* by the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package ml.duncte123.skybot.objects.delegate; | ||
|
||
import Java.lang.VRCubeException; | ||
import groovy.lang.Script; | ||
import org.codehaus.groovy.control.CompilationFailedException; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
|
||
public class ScriptDelegate extends Script { | ||
|
||
public ScriptDelegate(Script s) { | ||
super(s.getBinding()); | ||
} | ||
|
||
@Override | ||
public Object run() { | ||
return "I'm a bot, I can't run."; | ||
} | ||
|
||
@Override | ||
public void println() { | ||
throw new VRCubeException("Hey, i like to keep my console clean"); | ||
} | ||
|
||
@Override | ||
public void print(Object value) { | ||
throw new VRCubeException("Hey, i like to keep my console clean"); | ||
} | ||
|
||
@Override | ||
public void println(Object value) { | ||
throw new VRCubeException("Hey, i like to keep my console clean"); | ||
} | ||
|
||
@Override | ||
public void printf(String format, Object value) { | ||
throw new VRCubeException("Hey, i like to keep my console clean"); | ||
} | ||
|
||
@Override | ||
public void printf(String format, Object[] values) { | ||
throw new VRCubeException("Hey, i like to keep my console clean"); | ||
} | ||
|
||
@Override | ||
public Object evaluate(String expression) throws CompilationFailedException { | ||
throw new VRCubeException("Erm, no?"); | ||
} | ||
|
||
@Override | ||
public Object evaluate(File file) throws CompilationFailedException, IOException { | ||
throw new VRCubeException("Erm, no?"); | ||
} | ||
|
||
@Override | ||
public void run(File file, String[] arguments) throws CompilationFailedException, IOException { | ||
throw new VRCubeException("Erm, no?"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.