What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » [Help] Messenger.MyContacts.GetContact

[Help] Messenger.MyContacts.GetContact
Author: Message:
davidpolitis
Full Member
***


Posts: 371
Reputation: 16
Joined: Aug 2006
RE: RE: RE: [Help] Messenger.MyContacts.GetContact
quote:
Originally posted by Leroux
Javascript code:
var DM = "rpg1@hotmail.com";
 
function OnEvent_ChatWndSendMessage(ChatWnd,Message)
{
  if ((Message =="/Test") && (Messenger.MyEmailAddress == DM))
  {
        var Message = "Testing";
        MsgPlus.DisplayToast("Alert", Message);
  }
}

Apologies for the bad code.  I'm a little rusty, but you get the gist and hopefully it'll help you out a bit.
quote:
Return Value
A string containing the message to be sent instead of Message. If you do not want to modify the message, simply return Message without changing it. No size restriction applies to the new message except for the maximum size allowed by Messenger. If the event handler returns an empty string, the message is ignored and not sent to the server.
Problems:
1. You're setting the variable "Message", which is already set by OnEvent_ChatWndSendMessage
2. You aren't returning anything at the end of the event
3. Script commands should not start with an uppercase character (although they will still work)
4. Using OnGetScriptCommands(), along with our script command check, would be more suitable

Btw, I changed the one if to use two ifs so that "/test" isn't returned, causing a loop and script error, if the current user's email address is not the value of "DM". Also, "MyEmailAddress" is not a valid property of the Messenger object and was therefore changed to "MyEmail".

Javascript code:
var DM = "email@live.com"; // Change to the 'enabled' email address
 
function OnGetScriptCommands()
{
    var SC = "<ScriptCommands>";
    SC += "<Command>";
    SC += "<Name>test</Name>";
    SC += "<Description>Test</Description>";
    SC += "</Command>";
    SC += "</ScriptCommands>";
    return SC;
}
 
function OnEvent_ChatWndSendMessage(ChatWnd, Message)
{
    if (Message === "/test")
    {
        if (Messenger.MyEmail == DM)
        {
            var Msg = "Testing";
            MsgPlus.DisplayToast("Alert", Msg);
        }
        return "";
    }
    return Message;
}

P.S. hopefully what I said makes sense. Sorry if it doesn't.

This post was edited on 04-17-2009 at 08:18 AM by davidpolitis.
04-17-2009 12:24 AM
Profile PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
[Help] Messenger.MyContacts.GetContact - by Red Blood on 04-15-2009 at 08:45 PM
RE: [Help] Messenger.MyContacts.GetContact - by ryxdp on 04-15-2009 at 10:14 PM
RE: [Help] Messenger.MyContacts.GetContact - by Red Blood on 04-16-2009 at 01:06 AM
RE: [Help] Messenger.MyContacts.GetContact - by davidpolitis on 04-16-2009 at 02:27 PM
RE: [Help] Messenger.MyContacts.GetContact - by Red Blood on 04-16-2009 at 06:20 PM
RE: RE: [Help] Messenger.MyContacts.GetContact - by ArkaneArkade on 04-16-2009 at 08:48 PM
RE: RE: RE: [Help] Messenger.MyContacts.GetContact - by davidpolitis on 04-17-2009 at 12:24 AM


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