Shoutbox

Can msg script see e-mail? - 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: Can msg script see e-mail? (/showthread.php?tid=82817)

Can msg script see e-mail? by apex on 03-30-2008 at 03:33 PM

Hi,
I'm trying to improve PSM Chat 1.0, wich allows others to create your PSM by typing !psm <message> (or any other command)(wth authors permission).

You can now also "ban" people from creating your PSM, by entering their name in the script, al following:

code:
if (test == "on")
    {
        var name = Origin.substring(0,25);
        if (name == "") {
            if(Message.substring(0,1) == "~") {
                damessage = Message.substring(1,500);
                ChatWnd.SendMessage("You are not allowed...");

Now I want to make it so, that you can enter the E-MAIL adres, in stead of a name, because people often change their names, and also use bb codes etc...

But i dont know how? Does any else know? I tried using: var Email = Getadres (email) but it didn't work.

Any1 knows this? thx


~Apex
RE: Can msg script see e-mail? by CookieRevised on 03-30-2008 at 05:43 PM

See the Scripting Documentation. It is a great, very easy and fast help for stuff like this.

In the script Editor go to the "Options" menu and click on "Script Documentation"..... Or download the help file directly from the above link.

quote:
Originally posted by apex
code:
ChatWnd.SendMessage("You are not allowed...");

Before you use SendMessage you should _always_ check if you actually can send a message. This is explained in the Scripting Documentation:
quote:
Originally posted by Scripting Documentation - ChatWnd:: SendMessage
The EditChangeAllowed property should be checked before this function is called.

quote:
Originally posted by apex
var Email = Getadres (email) but it didn't work.
See Scripting Documentation -> Contacts::GetContact.
Make sure you read the remarks section very carefully in regards to Yahoo networks.

---

But because of the Origin parameter in the OnEvent_ChatWndReceiveMessage you can't get the email of the contact who send the message like that.

To check the banned email against the email of the contact who send the '!PSM' command you need to iterate (enumerate) thru all the contact objects in the chat window.

If the Name property of a contact object is the same as the Origin parameter you know you have the correct contact (well, in general, because actually this isn't always so and you could get false positives) of which you can use the Email property to compare against the banned email.


;)
RE: Can msg script see e-mail? by apex on 03-30-2008 at 06:49 PM

Okay,first of all: Thx for ur answer, I'm not the best @ english, but i think that i get what u mean.

I don't have any yahoo contacts, so that isnt the problem.

But do you know how to do it then?


RE: Can msg script see e-mail? by CookieRevised on 03-30-2008 at 08:13 PM

code:
var BannedEmails = new Array('iamspammer@hotmail.com', 'iannoyyou@msn.com');

function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind) {
    if (MessageKind === 1 && Message.substring(0,4).toLowerCase() === '!psm') {
        var bProceed = true;
        for (var e = new Enumerator(ChatWnd.Contacts); !e.atEnd(); e.moveNext()) {
            var Contact = e.item();
            for (i in BannedEmails) {
                if (Contact.Email === BannedEmails[ i]) {
                    // message is send by a banned email
                    bProceed = false;
                    break;
                }
            }
            if (!bProceed) break;
        }
        if (bProceed) {
            // Do whatever you otherwise do when a contact send !PSM
            Message = Message.substr(5);
            Message = Message.replace(/^\s+|\s+$/g,"");
            Origin = Origin.substring(0,25);
            Origin = Origin.replace(/^\s+|\s+$/g,"");
            Messenger.MyPersonalMessage = Origin + " says: " + Message;
            MsgPlus.DisplayToast("PSM Chat","PSM changed to: " + Message);
            if (ChatWnd.EditChangeAllowed) ChatWnd.SendMessage("Automated Message - PSM changed to: " + Message);
        } else {
            if (ChatWnd.EditChangeAllowed) ChatWnd.SendMessage("Automated Message - " + Origin + ", you are not allowed to use my psm chat...");
        }
    }
}
This will also work in multi-contact chats. Thus chats with more than one person: If one of the people in the chat is banned, nobody in the chat would be able to use the remote !PSM command.

You can't do it otherwise since the Origin parameter is the chatname of a contact. And this chatname can be different than the screenname of the contact. For example: if you have set a nickname in WLM for this contact, or if the contact is using the plugin StuffPlug, etc...





RE: Can msg script see e-mail? by apex on 03-31-2008 at 08:32 AM

Hey, thx for ur answer agian, i tried it in my script now, lets see if it worked!