import jerklib.ConnectionManager;
import jerklib.ProfileImpl;
import jerklib.Session;
import jerklib.events.listeners.IRCEventListener;
import jerklib.events.IRCEvent;
import jerklib.events.JoinCompleteEvent;
/**
* Created: Apr 6, 2008 10:55:08 PM
*
* @author Robert O'Connor
*/
public class CICEBot {
ConnectionManager manager = new ConnectionManager(new ProfileImpl("cicebot", "cicebot", "cicebot2", "cicebot3"));
Session s = manager.requestConnection("irc.freenode.org");
public CICEBot() {
s.addIRCEventListener(IRCEventListener(IRCEvent e) {
if(e.getType() == IRCEvent.Type.CONNECT_COMPLETE) {
e.getSession().join("#jerklib");
} else if(e.getType() == IRCEvent.Type.JOIN_COMPLETE) {
JoinCompleteEvent jce = (JoinCompleteEvent)e;
jce.getChannel().say("Hello from CICE!!!");
}
});
}
public static void main(String[] args) {
new CICEBot();
}
}
The regular java version looks like this:
import jerklib.ConnectionManager;
import jerklib.ProfileImpl;
import jerklib.Session;
import jerklib.events.IRCEvent;
import jerklib.events.JoinCompleteEvent;
import jerklib.events.listeners.IRCEventListener;
/**
* Created: Apr 6, 2008 10:05:09 PM
*
* @author Robert O'Connor
*/
public class JavaBot {
ConnectionManager manager = new ConnectionManager(new ProfileImpl("javabot", "javabot", "javabot2", "javabot3"));
Session s = manager.requestConnection("irc.freenode.org");
public JavaBot() {
s.addIRCEventListener(new IRCEventListener() {
public void receiveEvent(IRCEvent e) {
if (e.getType() == IRCEvent.Type.CONNECT_COMPLETE) {
e.getSession().join("#jerklib");
} else if (e.getType() == IRCEvent.Type.JOIN_COMPLETE) {
JoinCompleteEvent jce = (JoinCompleteEvent) e;
jce.getSession().sayChannel(jce.getChannel(), "Hi from Java!!!");
}
}
});
}
public static void main(String[] args) {
new JavaBot();
}
}
4 comments:
Since you have been "closuring" a lot lately, I found this: I Don't Believe In Closures"... Its what I've been thinking for a long time...
@Saptarshi: right... The first thought that came to mind was... what the hell; the guy seems to be off a bit..or maybe i'm just not getting his point; but either way...what the hell.
No, closures are not just assignments from one variable to another. That guy is way off.
Ricky, I know :)
Post a Comment