import jerklib.ConnectionManager;
import jerklib.ProfileImpl;
import jerklib.Session;
import jerklib.events.IRCEvent;
import jerklib.events.JoinCompleteEvent;
/**
* Created: Apr 6, 2008 10:23:06 PM
*
* @author Robert O'Connor
*/
public class FCMBot {
ConnectionManager manager = new ConnectionManager(new ProfileImpl("fcmbot","fcmbot","fcmbot2","fcmbot3"));
Session s = manager.requestConnection("irc.freenode.org");
public FCMBot() {
s.addIRCEventListener(#(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 FCM!!!");
}
});
}
public static void main(String[] args) {
new FCMBot();
}
}
It is much like the BGGA bot; in fact i changed nothing and followed the same design:
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();
}
}
No comments:
Post a Comment