#wolfbot
#wolfbot
A quick introduction to creating IRC bots in java using pircbot.
PircBot
Our first bot!
import org.jibble.pircbot.*;��public class MyBot extends PircBot {� public MyBot() {� setName("WolfBot");
setVerbose(true);
bot.connect("irc.freenode.net");
bot.joinChannel("#wolftest");� }� public static void main(String[] args) throws Exception {� MyBot bot = new MyBot();� }
}
Demo
Echo echo echo echo bot
@Override
public void onMessage(String channel,
String sender, String login,
String hostname, String message) {�
sendMessage(channel,
sender + " said: " + message);
}
Demo
Adding Commands
@Override
public void onMessage(String channel,
String sender, String login,
String hostname, String message) {
if (message.startsWith("!") {
command(channel,sender,
login,hostname,message)
}
}
public void command (String channel,
String sender, String login,
String hostname, String message) {
String[] args;
message = message.substring(1);
args = message.split(" ");
...
...
switch (args[0]) {
case "help": //Java 7 bitches
sendMessage(channel, "Commands: help");
break;
default:
sendMessage(channel,
"Unknown command... Idiot.");
break;
}
Demo
So why #WolfBot?
What is Werewolf?
What is Werewolf?
Features
Un-Features
Shall we play!?
More Werewolf Tonight!
Code on github.
Links/Notes