rendered paste bodypackage irc.bot.plugins;
import irc.bot.plugins.system.BotPluginAdapter;
/**
* User: root
* Date: Apr 2, 2007
* Time: 8:45:41 AM
* Aftermath
*/
public class AlterCaps extends BotPluginAdapter {
private boolean enabled;
public String getName() {
return "AlterCaps";
}
public void onMessage(String channel, String nickname, String hostname, String message, double rights) {
if(rights >= 0 && (enabled || rights < 500)) {
if(message.startsWith("!altercaps")) {
sendMessage(channel, alterCaps(message.substring(11).trim()));
}
}
if(rights > 500) {
if(message.equals("!acapson")) {
enabled = true;
} else if(message.equals("!acapsoff")) {
enabled = false;
}
}
}
public String alterCaps(String message) {
byte[] bytes = message.getBytes();
String out = "";
for(int i = 0, j = 0; i < bytes.length && j < bytes.length; i++, j++) {
if(isWhiteSpace(bytes[j])) out += (char)bytes[j++];
out += (i % 2 == 0) ? Character.toUpperCase(new Character((char)bytes[j])) : Character.toLowerCase((char)bytes[j]);
}
return out;
}
private boolean isWhiteSpace(byte chr) {
Character c = (char)chr;
return c.equals(' ') || c.equals('\n') || c.equals('\t') || c.equals('\r');
}
}