What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » changing words in sent text?

changing words in sent text?
Author: Message:
moon_lit_shadow
New Member
*


Posts: 6
Joined: Dec 2007
O.P. changing words in sent text?
I'm working on a very small script to try to replace words in a sentence (for testing purposes) and I'm unsure exactly how to do this. I was wondering if perhaps someone could tell me what i'm doing wrong?
I'm native to C++, so Javascript is not too difficult to understand, it's just the MsgPlus! syntax which I am uncertain of.

my code so far:
code:
function OnEvent_ChatWndSendMessage(ChatWnd, Message)
{
    var split_message = Message.split(' ');
    for(var i=0; i>=split_message.length; i=i+1)
    {
        split_message[i] = "word ";
    }
}


Anyone able to help?

EDIT:
Oh yeah, my question is just how to return the array of the message that is going to be sent to be the new output message. Sort of like the word replace feature. (I'm changing all the words at the moment with the for loop/array, but in the end i intend to use a switch/case branch. It's just to test things for now to get the hang of it)

This post was edited on 05-11-2010 at 07:53 PM by moon_lit_shadow.
05-11-2010 07:51 PM
Profile E-Mail PM Find Quote Report
Chrissy
Senior Member
****

Avatar

Posts: 850
Reputation: 5
29 / Male / Flag
Joined: Nov 2009
RE: changing words in sent text?
Changing a message being sent:

You can return a message from the ChatWndSendMessage function and it will change the message before it is sent. If you don't return a message, the intercepted message will be sent.

The following code will replace all instances of hi with test.
code:
function OnEvent_ChatWndSendMessage(ChatWnd, sMessage)
{
   return sMessage.replace("hi", "test");
}

(ChrisBoulton)
05-11-2010 10:29 PM
Profile E-Mail PM Web Find Quote Report
Spunky
Former Super Mod
*****

Avatar

Posts: 3658
Reputation: 61
35 / Male / Flag
Joined: Aug 2006
RE: changing words in sent text?
quote:
Originally posted by Chrissy
The following code will replace all instances of hi with test.

No, It'll replace one instance. For all instances you would have to use a RegExp with the g modifier

Javascript code:
function OnEvent_ChatWndSendMessage(ChatWnd, Message){
   return Message.replace(/hi/gi, "test");
}


g = global
i = case insensitive
Anything between the slashes (/) are the RexExp to look for. Special characters can also be used here to denote certain things.

This post was edited on 05-12-2010 at 05:23 AM by Spunky.
<Eljay> "Problems encountered: shit blew up" :zippy:
05-12-2010 05:21 AM
Profile PM Find Quote Report
« Next Oldest Return to Top Next Newest »


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