'Send ``text`` as a PRIVMSG to ``recipient``.
In the context of a triggered callable, the ``recipient`` defaults to
the channel (or nickname, if a private message) from which the message
was received.
By default, this will attempt to send the entire ``text`` in one
message. If the text is too long for the server, it may be truncated.
If ``max_messages`` is given, the ``text`` will be split into at most
that many messages, each no more than 400 bytes. The split is made at
the last space character before the 400th byte, or at the 400th byte if
no such space exists. If the ``text`` is too long to fit into the
specified number of messages using the above splitting, the final
message will contain the entire remainder, which may be truncated by
the server.'

def say(self, text, recipient, max_messages=1):

    max_text_length = 400
    if isinstance(text, unicode):
        encoded_text = text.encode(u'utf-8')
    else:
        encoded_text = text
    excess = u''
    if ((max_messages > 1) and (len(encoded_text) > max_text_length)):
        last_space = encoded_text.rfind(u'    '.encode(u'utf-8'), 0, max_text_length)
        if (last_space == (-1)):
            excess = encoded_text[max_text_length:]
            encoded_text = encoded_text[:max_text_length]
        else:
            excess = encoded_text[(last_space + 1):]
            encoded_text = encoded_text[:last_space]
    text = encoded_text.decode(u'utf-8')
    try:
        self.sending.acquire()
        recipient_id = Identifier(recipient)
        if (recipient_id not in self.stack):
            self.stack[recipient_id] = []
        elif self.stack[recipient_id]:
            elapsed = (time.time() - self.stack[recipient_id][(-1)][0])
            if (elapsed < 3):
                penalty = (float(max(0, (len(text) - 40))) / 70)
                wait = (0.8 + penalty)
                if (elapsed < wait):
                    time.sleep((wait - elapsed))
            messages = [m[1] for m in self.stack[recipient_id][(-8):]]
            if ((messages.count(text) >= 5) and (elapsed < 120)):
                text = u'...'
                if (messages.count(u'...') >= 3):
                    return
        self.write((u'PRIVMSG', recipient), text)
        self.stack[recipient_id].append((time.time(), self.safe(text)))
        self.stack[recipient_id] = self.stack[recipient_id][(-10):]
    finally:
        self.sending.release()
    if excess:
        self.msg(recipient, excess, (max_messages - 1))
