Description:*
I'm writing an irc bot, using
PircBot
The bot can only send String messages of maximum 512 bytes, including an added "\r\n".
Strings longer than this will be truncated before sending.
I want to check if the String is longer than 512b, and cut it up in separate Strings,
using a recursive method:
Pseudo:*
method splitMessage( String message ){
if message including \r\n is larger than 512 bytes{
message1 = first part of the message, including \r\n no longer than 512 bytes;
message2 = rest of the message;
send message1;
splitMessage( message2 );
}
else{
send message;
}
}
My problem:* I don't know how to check the byte length of a String, and how to cut it up in 512b chunks.
Would this be possible in any way? Or do I need a diffent approach?
Thanks in advance,
Tayotoshi