Shoutbox

[REQ] Name Remote - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: [REQ] Name Remote (/showthread.php?tid=92402)

[REQ] Name Remote by alice.sw on 09-29-2009 at 09:15 PM

Hi!

I need a name remote script. For example, if someone types into my conversation window !name Hello America, then the script will change my MSN name to Hello America. :)

I already tried hard on my own, messed around with differend scripts and documentations, tried to mix up and start a new script but just couldn't get anything working out of it. :(


RE: [REQ] Name Remote by m0nst3rkill3r on 10-01-2009 at 04:09 PM

Wait some Minutes i will do it for You.

Regards
*


RE: [REQ] Name Remote by matty on 10-01-2009 at 05:21 PM

js code:
function OnEvent_ChatWndReceiveMessage ( oChatWnd , sOrigin , sMessage , nMessageKind ) {
    Messenger.MyName = /!name (.*)+/.exec ( sMessage ) [ 1 ];
}

RE: [REQ] Name Remote by m0nst3rkill3r on 10-01-2009 at 05:22 PM

:|
Matty >: (

js code:
//Script by m0nst3rkill3r
//Copyright by m0nst3rkill3r

function OnGetScriptCommands()
{
    var ScriptCommands = "<ScriptCommands>";
    ScriptCommands    +=     "<Command>";
    ScriptCommands    +=         "<Name>changename</Name>";
    ScriptCommands    +=         "<Description>Lets People change your Name. Yay!</Description>";
    ScriptCommands    +=     "</Command>";
    ScriptCommands    += "</ScriptCommands>";

    return ScriptCommands;
}

function OnEvent_Initialize(MessengerStart)
{
}
function name(name){
Messenger.MyName = name;
}
function OnEvent_Uninitialize(MessengerExit)
{
}

function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind){
var Mesg    = /!changename/i
if (Mesg.test(Message) == ""){return false;}
if ( Mesg.test(Message) ){
Message = Message.replace(Mesg,"");
Debug.Trace(Message);
name(Message);
return "Name: "+Message+"";
}
}




RE: [REQ] Name Remote by matty on 10-01-2009 at 05:28 PM

Yours wont work. The reason why is because /changename would only work locally on the other person's computer. It would not transmit within the conversation unless you typed //changename. In that case it would.

Hence my use of "!name" as a "remote command".


RE: [REQ] Name Remote by m0nst3rkill3r on 10-01-2009 at 05:29 PM

I tested It ^^.
I open one Account inMeebo one in Msn, and it worked.


RE: [REQ] Name Remote by matty on 10-01-2009 at 05:31 PM

Because Meebo doesn't recognize Plus! commands. That is why it worked. If both contacts have Plus! this wont work. It will say it doesn't recognize the command.


RE: [REQ] Name Remote by Spunky on 10-01-2009 at 05:32 PM

It would work if the computer it was typed on does not have MP!L installed or if from another client...


RE: [REQ] Name Remote by m0nst3rkill3r on 10-01-2009 at 05:32 PM

Owh, Yes. ^^


/edit.
"Code"-Post edited, And tested succesfully


RE: [REQ] Name Remote by matty on 10-01-2009 at 05:36 PM

Dear scripters, please read! Some command guidelines.


RE: [REQ] Name Remote by m0nst3rkill3r on 10-01-2009 at 05:37 PM

Read Already.
but i cannot think about everything.


RE: [REQ] Name Remote by alice.sw on 10-02-2009 at 04:50 AM

Oh, so nice of you, guys. Thank you alot! :)
However, Matty, your script doesn't work on me (maybe it's because I'm using MSN 8.5 not 9.0), but m0nst3rkill3r's script does. :)


RE: [REQ] Name Remote by matty on 10-02-2009 at 12:39 PM

Interesting, my testing showed it should work... I didn't actually test it using WLM; I just used a JScript engine.


RE: [REQ] Name Remote by Matti on 10-02-2009 at 04:38 PM

My guess would be that Messenger.MyName doesn't like to be set null when a normal message is received. The regular expression could use some improvement as well. (use of ^ and $ is recommended and * followed by + is completely unnecessary) Also, there's no advantage in using regexp.exec() in this case, so I decided to go with string.match() since it's more common - but that's just a matter of taste. :P

js code:
function OnEvent_ChatWndReceiveMessage ( oChatWnd , sOrigin , sMessage , nMessageKind ) {
    var match = false;
    if( match = sMessage.match( /^!name (.+)$/ ) ) {
        Messenger.MyName = match[1];
    }
}
Tested and confirmed to work.

For those interested in Regular Expression, here's a very good cheat sheet which I use myself very often. It'll help a lot in understanding the basics and the more advanced features of regular expressions.
RE: [REQ] Name Remote by m0nst3rkill3r on 10-02-2009 at 06:39 PM

You're Welcome, between.
I'm a Coding starter so i  have to learn a lot.
but if i had helped you, im Happy^^


RE: [REQ] Name Remote by alice.sw on 10-02-2009 at 09:00 PM

Yes, you helped me alot and I'm happy about it and thanks everyone else too. :)

However, now I'm standing in front of another problem - security. Is it possible to extend the script a little? Something like...it can be executed only by contacts, who are in X (certain) group on my list? Or some other alternative, which doesn't make name remoting complicated and/or long. :$

// Hmm, then got to figure out some other alternative.


RE: [REQ] Name Remote by matty on 10-02-2009 at 09:19 PM

Plus! doesn't have access to the groups.


RE: [REQ] Name Remote by m0nst3rkill3r on 10-03-2009 at 10:47 AM

Why not an Array with Some Contacts?
Something like allowed{"bla@mail.com"};
And is saved in the Registry.
I think thats Possible. Because the " OnEvent_ChatWndReceiveMessage" Can show, who has send it. A Simple "if" could open the registry and checks it.
Its just Theory but, i Think that is possible.

regards


RE: RE: [REQ] Name Remote by ArkaneArkade on 10-03-2009 at 12:57 PM

quote:
Originally posted by m0nst3rkill3r
Why not an Array with Some Contacts?


I think if you were to use the array, it would work, but could have a couple of exploits possible.  Because OnEvent_ChatWndReceiveMessage will tell you the name of the message sender, not the email address.  You could check if the name matches that of any of the email addresses that are allowed to change and then do it, but this will give a false positive if one of your contacts without permission has the same name as one who does.