It really depends on how you want the script to work. Here are three scripts.
Let's say you want it to send a random word when you send a message saying "moo!" (and only "moo!").
code:
var RandomWordList = new Array("box", "ship", "letter");
function OnEvent_ChatWndSendMessage(ChatWnd, Message) {
if(Message == "moo!") {
return RandomWordList[Math.floor(Math.random() * RandomWordList.length)];
}
}
The random words can be added to RandomWordList separated by commas and surrounded by quotation marks. There is no limit for how many words you want in the list. This script will send a random word when you send a message containing "moo!" exactly (case-sensitive), replacing "moo!".
Now, let's say you want it to replace all the "moo!"s in your message with a random word.
code:
var RandomWordList = new Array("box", "ship", "letter");
function OnEvent_ChatWndSendMessage(ChatWnd, Message) {
return Message.replace(/moo!/g, RandomWordList[Math.floor(Math.random() * RandomWordList.length)]);
}
Again, we use the RandomWordList array. This time, you can type whatever you want with a "moo!" in it and it will replace it with a random word. This is also case-sensitive
Finally, here is a code identical to the above, except it replaces "moo!" with different random words each time (if there is more that one "moo!' in a message).
code:
var RandomWordList = new Array("box", "ship", "letter");
function OnEvent_ChatWndSendMessage(ChatWnd, Message) {
while(Message.match(/moo!/) != null) {
return Message.replace(/moo!/, RandomWordList[Math.floor(Math.random() * RandomWordList.length)]);
}
}
This also uses the RandomWordList array. This is identical to the above, except if you send a message "I like moo! moo!", instead of seeing (for example) "I like box box", you will see something like "I like letter box".
Hope these are close to what you need. I haven't tested them, so look out for bugs or infinite loops.
EDIT: JayJay's random is better.