I had a go at it, but my mind isn't working very well today so the following is most likely highly inefficient.
code:
function OnEvent_ChatWndSendMessage(pChatWnd, sMessage){
return punctuate(sMessage);
}
function punctuate(s)
{
var sentences = s.split(" ");
for (var i = 0; i < sentences.length; i++)
{
if (i == sentences.length - 1 && isin(sentences[i].charAt(sentences[i].length - 1), "abcdefghijklmnopqrstuvwxyz0123456789"))
sentences[i] = sentences[i] + ".";
if (i == 0)
sentences[i] = sentences[i].charAt(0).toUpperCase() + sentences[i].substr(1);
else
if (isin(sentences[i-1].charAt(sentences[i-1].length - 1), ".?!"))
sentences[i] = sentences[i].charAt(0).toUpperCase() + sentences[i].substr(1);
}
return sentences.join(" ");
}
function isin(needle, haystack)
{
for (var i = 0; i < haystack.length; i++)
if (haystack.charAt( i ) == needle)
return true;
return false;
}
If it's easier to read/copy/paste I pastebinned it:
http://pastebin.ca/75734