So I've been writing a java-based irc-bot, which is fairly simple. Makes a socket connection to a server, attaches buffered readers / writers to the socket, and then reads / writes using those buffers.
I've not run into issues except for when I was printing out a json object and got kicked off the network for excessive flood. I'm not sure of the message rate limit for the network, but I do pass all my messages through the same simple function.
I'm hoping to add some kind of x bytes / timeframe limit to it. Someone suggested that I look into NIO, but that seems to be over-engineering the issue a little bit.
Here's what my current write-to-irc channel method looks like:
public static void writeMsg(BufferedWriter writer, String Channel, String Message) {
try {
System.out.println("Bot Command: PRIVMSG " + Channel + Message); //diagnostic
writer.write("PRIVMSG " + Channel + Message);
writer.flush();
} catch(IOException ioe) {
ioe.printStackTrace();
}
}
Example of what might be passed into / out of that function:
Input:
writer (my BufferedWriter object), "#Testing1234: ", "!wiki China";
Output:
PRIVMSG #BeginnersProgramming :http://en.wikipedia.org/wiki/China