Shoutbox

Need a bit of help with email addresses. - 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: Need a bit of help with email addresses. (/showthread.php?tid=83185)

Need a bit of help with email addresses. by lol2112 on 04-15-2008 at 08:24 PM

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.


RE: Need a bit of help with email addresses. by matty on 04-16-2008 at 01:18 AM

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.
RE: Need a bit of help with email addresses. by lol2112 on 04-16-2008 at 04:38 PM

Thankyou very much for a helpful answer and a detailed explanation.