I’m developing a chat bot for my Twitch stream, but I’m facing a strange issue. It seems that only the !song
command is responding, while all my other commands don’t seem to work. I’ve gone through my code multiple times but can’t identify the problem.
Here’s the code for my bot:
import org.jibble.pircbot.*;
import java.io.*;
import java.lang.System.*;
public class HyperBotZ extends PircBot {
public String getSong() throws Exception {
FileReader file = new FileReader ("H:/Stream_Soft/Snip/Snip.txt");
BufferedReader reader = new BufferedReader(file);
String song = "";
String line = reader.readLine();
while (line != null) {
song += line;
line = reader.readLine();
}
return song;
}
public HyperBotZ() {
this.setName("HyperBotZ");
}
public static String ip = "";
public static String dual = "";
public void onMessage(String channel, String sender,
String login, String hostname, String message) {
String owner = "hypergainz";
if (message.startsWith("!songrequest")) {
sendMessage(channel, "Sorry, I can't do that right now. HyperGainZ needs to learn me that. To see the current song, use !song :D");
}
if (message.startsWith("!ip ")) {
if(sender.equals(owner)) {
ip = message.split(" ")[1];
sendMessage(channel, "The IP is set to " + ip);
}
} else {
if (message.equalsIgnoreCase("!ip")) {
sendMessage(channel, "HyperGainZ is currently playing on: " + ip);
}
}
if (message.startsWith("!dual ")) {
if(sender.equals(owner)) {
dual = message.split(" ")[1];
}
} else {
if (message.equalsIgnoreCase("!dual")) {
sendMessage(channel, "http://multitwitch.tv/hypergainz/" + dual);
}
}
if (message.equalsIgnoreCase("!song")) {
String song = "";
try {
song = getSong();
} catch (Exception e) { e.printStackTrace(); }
sendMessage(channel, song);
}
}
}
Can anyone help me figure out what’s going wrong?