Why not take the whole text and split it on linebreaks, using the Lua string-library? A very basic pattern should be sufficient to achieve this.
Simply iterate over the whole text, grab a single line and build the chat-message (/2 or whatever) around it, send it, grab the next line.
edit: Those multiline-spam-messages in public channels are fubar!