0 Members and 2 Guests are viewing this topic.
import org.jibble.pircbot.*;public class BryceBot extends PircBot { public BryceBot() { this.setName("BryceBot"); } 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); } public void onMessage(String channel, String sender, String login, String hostname, String message) { if (message.equalsIgnoreCase("$op")) { if (sender.equalsIgnoreCase("KittyGirl")) { void op(channel, sender); sendMessage(channel, sender + ", you have been opped."); } } public void onMessage(String channel, String sender, String login, String hostname, String message) { if (message.equalsIgnoreCase("$op")) { if (sender.equalsIgnoreCase("UbuntuGuy")) { void op(channel, sender); sendMessage(channel, sender + ", you have been opped."); } } public void onMessage(String channel, String sender, String login, String hostname, String message) { if (message.equalsIgnoreCase("$op")) { if (sender.equalsIgnoreCase("Ti-PrgmR")) { void op(channel, sender); sendMessage(channel, sender + ", you have been opped."); } } }}
mport org.jibble.pircbot.*;public class BryceBotMain { public static void main(String[] args) throws Exception { BryceBot bot = new BryceBot(); bot.setVerbose(true); bot.connect("irc.SHOUTcast.net"); bot.joinChannel("#tiandubuntu"); } }
aaron@aaron-N150P-N210P-N220P:~/BryceBot/pircbot-1.5.0$ javac -classpath pircbot.jar:. *.javaBryceBot.java:16: illegal start of expression public void onMessage(String channel, String sender, ^BryceBot.java:16: illegal start of expression public void onMessage(String channel, String sender, ^BryceBot.java:16: ';' expected public void onMessage(String channel, String sender, ^BryceBot.java:16: ';' expected public void onMessage(String channel, String sender, ^BryceBot.java:16: not a statement public void onMessage(String channel, String sender, ^BryceBot.java:16: ';' expected public void onMessage(String channel, String sender, ^BryceBot.java:17: ';' expected String login, String hostname, String message) { ^BryceBot.java:17: not a statement String login, String hostname, String message) { ^BryceBot.java:17: ';' expected String login, String hostname, String message) { ^BryceBot.java:17: ';' expected String login, String hostname, String message) { ^BryceBot.java:20: illegal start of expression void op(channel, sender); ^BryceBot.java:20: ';' expected void op(channel, sender); ^BryceBot.java:20: not a statement void op(channel, sender); ^BryceBot.java:20: ';' expected void op(channel, sender); ^BryceBot.java:20: not a statement void op(channel, sender); ^BryceBot.java:20: ';' expected void op(channel, sender); ^BryceBot.java:25: illegal start of expression public void onMessage(String channel, String sender, ^BryceBot.java:25: illegal start of expression public void onMessage(String channel, String sender, ^BryceBot.java:25: ';' expected public void onMessage(String channel, String sender, ^BryceBot.java:25: ';' expected public void onMessage(String channel, String sender, ^BryceBot.java:25: not a statement public void onMessage(String channel, String sender, ^BryceBot.java:25: ';' expected public void onMessage(String channel, String sender, ^BryceBot.java:26: ';' expected String login, String hostname, String message) { ^BryceBot.java:26: not a statement String login, String hostname, String message) { ^BryceBot.java:26: ';' expected String login, String hostname, String message) { ^BryceBot.java:26: ';' expected String login, String hostname, String message) { ^BryceBot.java:29: illegal start of expression void op(channel, sender); ^BryceBot.java:29: ';' expected void op(channel, sender); ^BryceBot.java:29: not a statement void op(channel, sender); ^BryceBot.java:29: ';' expected void op(channel, sender); ^BryceBot.java:29: not a statement void op(channel, sender); ^BryceBot.java:29: ';' expected void op(channel, sender); ^BryceBot.java:34: illegal start of expression public void onMessage(String channel, String sender, ^BryceBot.java:34: illegal start of expression public void onMessage(String channel, String sender, ^BryceBot.java:34: ';' expected public void onMessage(String channel, String sender, ^BryceBot.java:34: ';' expected public void onMessage(String channel, String sender, ^BryceBot.java:34: not a statement public void onMessage(String channel, String sender, ^BryceBot.java:34: ';' expected public void onMessage(String channel, String sender, ^BryceBot.java:35: ';' expected String login, String hostname, String message) { ^BryceBot.java:35: not a statement String login, String hostname, String message) { ^BryceBot.java:35: ';' expected String login, String hostname, String message) { ^BryceBot.java:35: ';' expected String login, String hostname, String message) { ^BryceBot.java:38: illegal start of expression void op(channel, sender); ^BryceBot.java:38: ';' expected void op(channel, sender); ^BryceBot.java:38: not a statement void op(channel, sender); ^BryceBot.java:38: ';' expected void op(channel, sender); ^BryceBot.java:38: not a statement void op(channel, sender); ^BryceBot.java:38: ';' expected void op(channel, sender); ^BryceBot.java:43: reached end of file while parsing} ^BryceBot.java:44: reached end of file while parsing^50 errorsaaron@aaron-N150P-N210P-N220P:~/BryceBot/pircbot-1.5.0$
It seems as though you didn't close most of your methods with a curly brace you closed all internal if statements inside, but not the actual methods. Your errors are purely syntax errors from what I can tell. Try adding curly braces.
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); } } public void onMessage(String channel, String sender,
aaron@aaron-N150P-N210P-N220P:~/BryceBot/pircbot-1.5.0$ javac -classpath pircbot.jar:. *.javaBryceBot.java:13: illegal start of expression public final void setTopic(channel, ^BryceBot.java:13: illegal start of type public final void setTopic(channel, ^BryceBot.java:13: ';' expected public final void setTopic(channel, ^BryceBot.java:13: ')' expected public final void setTopic(channel, ^BryceBot.java:13: not a statement public final void setTopic(channel, ^BryceBot.java:14: not a statement "Ti-PrgmR, KittyGirl, and UbuntuGuy's Channel. Type $rules for channel rules."); ^BryceBot.java:14: ';' expected "Ti-PrgmR, KittyGirl, and UbuntuGuy's Channel. Type $rules for channel rules."); ^BryceBot.java:28: illegal start of expression void op(channel, sender); ^BryceBot.java:28: ';' expected void op(channel, sender); ^BryceBot.java:28: not a statement void op(channel, sender); ^BryceBot.java:28: ';' expected void op(channel, sender); ^BryceBot.java:28: not a statement void op(channel, sender); ^BryceBot.java:28: ';' expected void op(channel, sender); ^BryceBot.java:37: illegal start of expression void op(channel, sender); ^BryceBot.java:37: ';' expected void op(channel, sender); ^BryceBot.java:37: not a statement void op(channel, sender); ^BryceBot.java:37: ';' expected void op(channel, sender); ^BryceBot.java:37: not a statement void op(channel, sender); ^BryceBot.java:37: ';' expected void op(channel, sender); ^BryceBot.java:46: illegal start of expression void op(channel, sender); ^BryceBot.java:46: ';' expected void op(channel, sender); ^BryceBot.java:46: not a statement void op(channel, sender); ^BryceBot.java:46: ';' expected void op(channel, sender); ^BryceBot.java:46: not a statement void op(channel, sender); ^BryceBot.java:46: ';' expected void op(channel, sender); ^25 errorsaaron@aaron-N150P-N210P-N220P:~/BryceBot/pircbot-1.5.0$
import org.jibble.pircbot.*;public class BryceBot extends PircBot { public BryceBot() { this.setName("BryceBot"); } protected void onJoin(String channel, String sender, String login, String hostname) { if(sender.equalsIgnoreCase("BryceBot")) { public final void setTopic(channel, "Ti-PrgmR, KittyGirl, and UbuntuGuy's Channel. Type $rules for channel rules."); } } 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); } } public void onMessage(String channel, String sender, String login, String hostname, String message) { if (message.equalsIgnoreCase("$op")) { if (sender.equalsIgnoreCase("KittyGirl")) { void op(channel, sender); sendMessage(channel, sender + ", you have been opped."); } } } public void onMessage(String channel, String sender, String login, String hostname, String message) { if (message.equalsIgnoreCase("$op")) { if (sender.equalsIgnoreCase("UbuntuGuy")) { void op(channel, sender); sendMessage(channel, sender + ", you have been opped."); } } } public void onMessage(String channel, String sender, String login, String hostname, String message) { if (message.equalsIgnoreCase("$op")) { if (sender.equalsIgnoreCase("Ti-PrgmR")) { void op(channel, sender); sendMessage(channel, sender + ", you have been opped."); } } }public void onMessage(String channel, String sender, String login, String hostname, String message) { if (message.equalsIgnoreCase("$rules")) { sendMessage(channel, "Rules for #tiandubuntu - 1. Please don't troll other users. (Trolling is just basically being mean.) 2. Please no flaming. (Flaming is targeting someone and trying to make them upset.) 3. No useless spam. (Spam is advertising, or useless flooding.) 4. No full swear words. (If you censor it, like f*** or something or do FUUUUUUUUU it's OK. Commands you can use: If you are an owner of this channel, type '$op' to get opped. Type $time for the current time. '$rules' shows the rules and commands available."); } }}
import org.jibble.pircbot.*;public class BryceBot extends PircBot { public BryceBot() { this.setName("BryceBot"); } protected void onJoin(String channel, String sender, String login, String hostname) { if(sender.equalsIgnoreCase("BryceBot")) { setTopic(channel, "Ti-PrgmR, KittyGirl, and UbuntuGuy's Channel. Type $rules for channel rules."); } } 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); } } public void onMessage(String channel, String sender, String login, String hostname, String message) { if (message.equalsIgnoreCase("$op")) { if (sender.equalsIgnoreCase("KittyGirl")) { op(channel, sender); sendMessage(channel, sender + ", you have been opped."); } } } public void onMessage(String channel, String sender, String login, String hostname, String message) { if (message.equalsIgnoreCase("$op")) { if (sender.equalsIgnoreCase("UbuntuGuy")) { op(channel, sender); sendMessage(channel, sender + ", you have been opped."); } } } public void onMessage(String channel, String sender, String login, String hostname, String message) { if (message.equalsIgnoreCase("$op")) { if (sender.equalsIgnoreCase("Ti-PrgmR")) { op(channel, sender); sendMessage(channel, sender + ", you have been opped."); } } }public void onMessage(String channel, String sender, String login, String hostname, String message) { if (message.equalsIgnoreCase("$rules")) { sendMessage(channel, "Rules for #tiandubuntu - 1. Please don't troll other users. (Trolling is just basically being mean.) 2. Please no flaming. (Flaming is targeting someone and trying to make them upset.) 3. No useless spam. (Spam is advertising, or useless flooding.) 4. No full swear words. (If you censor it, like f*** or something or do FUUUUUUUUU it's OK. Commands you can use: If you are an owner of this channel, type '$op' to get opped. Type $time for the current time. '$rules' shows the rules and commands available."); } }}
aaron@aaron-N150P-N210P-N220P:~/BryceBot/pircbot-1.5.0$ javac -classpath pircbot.jar:. *.javaBryceBot.java:25: onMessage(java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String) is already defined in BryceBot public void onMessage(String channel, String sender, ^BryceBot.java:34: onMessage(java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String) is already defined in BryceBot public void onMessage(String channel, String sender, ^BryceBot.java:43: onMessage(java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String) is already defined in BryceBot public void onMessage(String channel, String sender, ^BryceBot.java:52: onMessage(java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String) is already defined in BryceBotpublic void onMessage(String channel, String sender, ^4 errorsaaron@aaron-N150P-N210P-N220P:~/BryceBot/pircbot-1.5.0$
import org.jibble.pircbot.*;public class BryceBot extends PircBot { public BryceBot() { this.setName("BryceBot"); } 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); if (message.equalsIgnoreCase("$op")) { if (sender.equalsIgnoreCase("KittyGirl")) { op(channel, sender); sendMessage(channel, sender + ", you have been opped."); } if (sender.equalsIgnoreCase("UbuntuGuy")) { op(channel, sender); sendMessage(channel, sender + ", you have been opped."); } if (sender.equalsIgnoreCase("Ti-PrgmR")) { op(channel, sender); sendMessage(channel, sender + ", you have been opped."); } } } }}
I want to enter another if (message.equalsIgnoreCase( outside of the checks for what user sent the message. Where can I put this?
import org.jibble.pircbot.*;public class BryceBot extends PircBot { public BryceBot() { this.setName("BryceBot"); } 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); } if (message.equalsIgnoreCase("$op")) { if (sender.equalsIgnoreCase("KittyGirl")) { op(channel, sender); sendMessage(channel, sender + ", you have been opped."); } if (sender.equalsIgnoreCase("UbuntuGuy")) { op(channel, sender); sendMessage(channel, sender + ", you have been opped."); } if (sender.equalsIgnoreCase("Ti-PrgmR")) { op(channel, sender); sendMessage(channel, sender + ", you have been opped."); } } } }
Ew, chained if statements. Case checking is better. . And in many cases, faster.