I have a bot which analyses chat command and provides a small database. When I tell the bot it should write the content of the database to the irc, it gets kicked because of excess flooding. How can I prevent this? (I'm using freenode.net)
PS: Here is my code:
for (User u : users.values()) {
ps.println("PRIVMSG " + CHANNEL + " :" + u.toString());
}
ps is a PrintStream which writes to Socket.getOutputStream(). CHANNEL is the name of my channel. users.size() is ~ 60.
Obviously a client can't change a servers thresholds for detecting flooding and disconnecting clients which do so. The whole idea of flood protection would be pointless, otherwise.
So, you must limit your output to such a level, that it will not trigger flooding kick. Add a (configurable) sleep between ps.println
calls, and set the sleep duration so that you don't get kicked.
Work-around would be to use a pastebin-like service, and just send URL and summary/title text to IRC in one line. Using these services is a standard procedure for any IRC paste longer than 3 lines these days anyway. Various "pastebin" services have REST APIs (example), so this should be rather easy way to go.