What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Replacing Words from an Array

Replacing Words from an Array
Author: Message:
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: Replacing Words from an Array
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):P) 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;
}

This post was edited on 12-31-2008 at 03:41 PM by matty.
12-31-2008 03:21 PM
Profile E-Mail PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
Replacing Words from an Array - by KooKas on 12-31-2008 at 07:18 AM
RE: Replacing Words from an Array - by Matti on 12-31-2008 at 09:29 AM
RE: Replacing Words from an Array - by KooKas on 12-31-2008 at 12:09 PM
RE: Replacing Words from an Array - by matty on 12-31-2008 at 03:21 PM
RE: Replacing Words from an Array - by KooKas on 12-31-2008 at 11:06 PM


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On