ObviBot Code
Status: Pre-Alpha
Brought to you by:
carteriffic
File | Date | Author | Commit |
---|---|---|---|
doc | 2009-04-25 |
![]() |
[a0143a] initial checkin |
src | 2009-04-25 |
![]() |
[a0143a] initial checkin |
.classpath | 2009-04-25 |
![]() |
[a0143a] initial checkin |
.project | 2009-04-25 |
![]() |
[a0143a] initial checkin |
README.txt | 2009-04-26 |
![]() |
[5d7147] adding readme doc |
ObviBot - a Java bot for MOO Overview Obvibot is an event driven bot framework for MOO that can be subclassed and extended in Java. It was adapted from the PircBot IRC bot (http://www.jibble.org/pircbot.php). Running ObviBot Requirements * An OS capable of running Java 1.5 (Windows, OS X, Linux, BSD, etc) * Java 1.5 (http://java.sun.com) * an account on a LambdaMOO system Download ObviBot To run your own bot, you can use the precompiled ObviBot jar file, available at http://sourceforge.net/projects/obvibot/ for download. Subclass Obvibot Here is a simple example. package org.obviosity.trigger; import java.io.IOException; import org.obviosity.obvibot.ObviBot; public class Trigger extends ObviBot { protected final void onSay(final String me, final String player, final String command, final String arguments) { } protected final void onDirectedSay(final String me, final String player, final String command, final String arguments) { } protected final void onEmote(final String me, final String player, final String command, final String arguments) { } protected final void onPage(final String me, final String player, final String command, final String arguments) { sendPage(player, "I hear ya!"); } protected void onConnect() { } protected void onDisconnect() { } public static void main(final String[] args) throws IOException { Trigger mb = new Trigger(); mb.setVerbose(true); mb.setName(args[0]); mb.connect(args[1], args[2], args[3]); } } If you save this as Trigger.java in the same dir with your obvibot jar, you can compile it like this: javac -classpath obvibot-0.1.0.jar;. *.java And once compiled it can be run like this: java -classpath pircbot.jar;. Trigger username password mooaddress mooport Of course you need to use real username etc, not dummy values. You can do any sort of computation you want inside of these overridden methods. The Player Object The parsing of communication from the MOO depends upon the use of the following custom :tell verb. You will need to program this on your bot object in the MOO before the ObviBot event hooks will work properly. You can paste the following snippet while logged into your bot account to accomplish this: @verb me:tell this none this @program me:tell if (!argstr) argstr = $su:from_list(args, " "); endif caller_list = callers(); len = length(caller_list); caller = tostr(caller_list[len][5]); verbname = tostr(caller_list[len][2]); tell = tostr(this) + " " + (caller + " ") + verbname + " " + argstr; notify(this, tell); . Developing ObviBot If you'd like to work with the source code for the ObviBot itself, perhaps helping to enhance it with new features or fix bugs, let me know. I use the Eclipse IDE (http://www.eclipse.org), and have checked in the project and classpath files you would need to import the project into your copy of Eclipse. I also use the Mercurial Eclipse Plugin (http://www.vectrace.com/mercurialeclipse/) which lets me conveniently push and pull code from the sourceforge repository. Try the Mercurial Wiki (http://www.selenic.com/mercurial/wiki/) for more on this. David Carter carteriffic@gmail.com