public void SendPrivMessage(string target, string message, bool splitOnWord) { //Format the message and get its length string formattedMessage = Rfc1459MessageBuilder.CreatePrivMessage(target, message); int lastMessageLength = formattedMessage.Length; // Loop splitting the message into separate messages until the last message // is an allowable size while (lastMessageLength > this.maxMessageLength) { int lastMsgIndex = formattedMessage.LastIndexOf("PRIVMSG"); // Find the point at which we need to split the message // TODO: Work out why .LastIndexOf() cant find the last space int splitIndex = // splitOnWord ? formattedMessage.LastIndexOf(" ", maxMessageLength, lastMsgIndex, StringComparison.InvariantCultureIgnoreCase) : maxMessageLength; // Split the message string nextMessage = formattedMessage.Substring(splitIndex); formattedMessage = formattedMessage.Substring(0, splitIndex); // Format the next message nextMessage = Rfc1459MessageBuilder.CreatePrivMessage(target, nextMessage); // Append it to the message to be sent formattedMessage += Environment.NewLine + nextMessage; lastMessageLength = nextMessage.Length; } base.SendMessage(formattedMessage); }