PircBot is a Java Framework which provides an API to write different kinds of interactive IRC bots. If you have finished your bot, you have only to compile and run your little Java program on your irc server console. But keep an eye on your user rights and don’t start your bot as root to avoid possible complete server hacks due to your bot software.
Example:
Example:
import org.jibble.pircbot.PircBot;
public class OwnBot extends PircBot {
public OwnBot() {
//set bot name
this.setName("BotName");
}
public static void main(String[] args) throws Exception {
// now start the bot up
OwnBot bot = new OwnBot();
// enable debugging output
bot.setVerbose(true);
// connect to your own irc server
bot.connect("irc.domain.de", 6668);
bot.identify("botpassword");
// join the #bottest1 channel
bot.joinChannel("#bottest1");
// left the #bottest2 channel
bot.partChannel("#bottest2");
}
public void onMessage(String channel, String sender, String login,
String hostname, String message) {
if (message.equalsIgnoreCase("!time")) {
String time = new java.util.Date().toString();
sendMessage(channel, sender + ": The time is now " + time);
}
…
}
}
see http://www.jibble.org/pircbot.php
