What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Need a bit of help with email addresses.

Need a bit of help with email addresses.
Author: Message:
lol2112
New Member
*


Posts: 2
Joined: Apr 2008
O.P. Need a bit of help with email addresses.
Hi, I'm new to this and I just wanted to ask how you make a script which only lets a command work for a person you've specified. E.g. if a friend you have specified types /hello then the command does something but if another contact does the same command but you have not activated the command for his email address, then it won't do anything. Thanks for any help.

This post was edited on 04-15-2008 at 08:25 PM by lol2112.
04-15-2008 08:24 PM
Profile E-Mail PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: Need a bit of help with email addresses.
Because the email address of the sent message isn't provided you have to do a few checks on the message.

code:
var aEmailAddresses = new Array('johndoe@hotmail.com', 'billgates@microsoft.com');
var oChatWndMessageSent = {};

function OnEvent_ChatWndSendMessage(oChatWnd, sMessage) { oChatWndMessageSent[oChatWnd.Handle] = sMessage; }

function OnEvent_ChatWndReceiveMessage(oChatWnd, sOrigin, sMessage, nMessageType) {
    if ( oChatWndMessageSent[oChatWnd.Handle] !== sMessage && sOrigin !== Messenger.MyName ) {
        for ( var oContact = new Enumerator(oChatWnd.Contacts); !oContact.atEnd(); oContact.moveNext() ) {
            for ( var i in aEmailAddresses ) {
                if ( oContact.item().Email === aEmailAddresses[i] && oContact.item().Name === sOrigin) {
                    // do stuff here
                }
            }
        }
    }
}

function OnEvent_ChatWndDestroyed(oChatWnd) { delete oChatWndMessageSent[oChatWnd.Handle]; }

What this does is when you send a message it stores it in an object then because when you send a message the OnEvent_ChatWndSendMessage is called followed by the OnEvent_ChatWndReceiveMessage. So what we do is compare the sOrigin (which is the name) to your name and we check if the message that was "received" is the different from the message stored in the object. The OnEvent_ChatWndReceiveMessage occures when specific things are added to the chat history it isn't specifically when an instant message is received.

This post was edited on 04-16-2008 at 10:53 AM by matty.
04-16-2008 01:18 AM
Profile E-Mail PM Find Quote Report
lol2112
New Member
*


Posts: 2
Joined: Apr 2008
O.P. RE: Need a bit of help with email addresses.
Thankyou very much for a helpful answer and a detailed explanation.
04-16-2008 04:38 PM
Profile E-Mail 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