quote:
Originally posted by Matti
ChatWnd.EditText is the text currently being typed by the user. Because you're using the OnEvent_ChatWndSendMessage, this will be empty as the message is already about to be sent and therefore the input area has been cleared. To change the message to be sent, you need to return the modified message at the end of your function.
Everything you stated in your post is correct except for the statement I am quoting. During the
OnEvent_ChatWndSendMessage function the
pChatWnd.EditText property is still populated. It is cleared out once the function succeeds. Such things as the following is made possible because of this:
js code:
function OnEvent_ChatWndSendMessage(pChatWnd, sMessage) {
return pChatWnd.EditText.indexOf('(!VER)') === -1 ? sMessage : pChatWnd.EditText.replace('(!VER)', '(!VER)\nxxx');
}
The reason this is done like this is because Messenger Plus! will parse the text before passing it to the function therefore to get the native text in the Chat Window edit box it is done like that.
However the only problem with the above code is that the
pChatWnd.EditText property is passed incorrectly therefore any emoticons to be sent (for instance:
(!VER)) will show up as
(!VER). I don't know if Patchou is aware of this. I will mention it next time I see him online.
Cheers!
And also the code can be cut down:
js code:
function OnEvent_ChatWndSendMessage(pChatWnd, sMessage) {
var Greet1 = new Array('hi', 'hey', 'hello', 'helo');
var Greet2 = new Array('sfe', 'wagwan', 'yo', 'oi');
for (var x in Greet1) sMessage = sMessage.replace(Greet1[x], Greet2[x]);
return sMessage;
}