What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Yahoo contacts

Yahoo contacts
Author: Message:
questsin
New Member
*


Posts: 14
Joined: Jan 2007
O.P. Yahoo contacts

I've been testing with the compatibility of Messenger Plus scripts and Yahoo. Looks like when in a chat everything seems fine regarding events and the message however

chatwindow contacts does not get updated and contact.email is null

is this a bug?

or is it cause my messenger contact list is too big.
01-15-2007 06:16 PM
Profile E-Mail PM Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15517
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: Yahoo contacts
Can you show the exact and entire test-script of yours, since it might be possible you did something wrong in the script regarding yahoo-contacts...

This post was edited on 01-15-2007 at 09:09 PM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
01-15-2007 09:08 PM
Profile PM Find Quote Report
questsin
New Member
*


Posts: 14
Joined: Jan 2007
O.P. RE: Yahoo contacts
the code is as follows. My observations is MSN contacts work, yahoo contacts don't. I use the GUID to identify then 4 now.

function OnEvent_ChatWndReceiveMessage(ChatWnd,Origin,Message,MessageKind) {

     // get contact
     var Contact = null;
     var e = new Enumerator(ChatWnd.Contacts);
     for(; !e.atEnd(); e.moveNext())
     {
          if(e.item().Name == Origin) {
               Contact = e.item();
          }
     }

     if (Origin != Messenger.MyName ) {
         
          if (Contact != null) {
               Debug.Trace(Contact.Email);
          } else {
               Debug.Trace('unknown');
               Debug.Trace( new ActiveXObject("Scriptlet.TypeLib").GUID.substr(1,36));
          }
    }
}
01-17-2007 12:30 AM
Profile E-Mail PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: Yahoo contacts
For yahoo contacts you need to prefix Yahoo: or Yahoo: I forget which one.

CookieRevised's reply to * Stat Center * [UPDATE: v1.1.2]

This post was edited on 01-17-2007 at 01:37 AM by matty.
01-17-2007 01:32 AM
Profile E-Mail PM Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15517
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: RE: Yahoo contacts
questsin,

Although your code is basically what most people use to identify the contact object in the ChatWndReceiveMessage event (thus by comparing the Origin with the Name property of a contact object), there are actually some pitfalls you need to understand:

The Origin parameter is the name of the contact in the conversation window. This is all what Messenger gives Plus! to identify the contact. However, this chat name can be different than the name of the contact in the contactlist.

Contacts can have a so called 'chat-only' name. Or you could have set an alternative email or Windows Live Messenger nickname in the contact's properties and this too can interfair with the Origin parameter.

Point is: the Origin parameter is not a fail-proof check to see who the contact is, though in most cases it should work. Unfortunatly, there is currently no better, fail-proof, method to do it though.

-----

So, the above raises the first question:

Has the contact you're testing this with a 'chat-only' name? If so, it is normal you don't find a contact object with that code... But that doesn't mean yahoo contacts aren't 'updated' (I don't quite understand what you mean by updated though).

Also, have you set an alternative email or nickname or something else for this contact in its contact properties in Windows Live Messenger itself?

-----

As for working with Yahoo contacts:
(and this is something many scripts forget to be compatible with)

When you have events like OnEvent_ContactStatusChange where an Email parameter is passed to the function, the Email parameter will always be prefixed with "yahoo:" for yahoo contacts which can be used to identify the contact as a yahoo contact.

So, this is already something you must take in account when you are going to iterate thru the Contacts enumeration object and compare the passed Email parameter with the Email property of the Contact object.

Because the Email property of the Contact object is never prefixed with "yahoo:" for yahoo contacts. This is why there is a Network property, so you can see if the Contact object is from a yahoo contact or not...

All this because of the fact that the email of a yahoo contact can be the same email of a contact using MSN Messenger/Windows Live Messenger. In other words, it is possible to have 2 different contacts in your contactlist (and both online) but with the exact same email address. Only one will be using the MSN network, the other will be using the Yahoo network.

Note that the GetContact method behaves in this way:
When you pass an email to it without the "yahoo:" prefix, it will first search thru the emails from the MSN network, if the email is found, that specific Contact object will be returned. If no email is found, it will then look in the contacts using the Yahoo network.

When you pass an email to it with the "yahoo:" prefix, it will only search in the contacts using the Yahoo network.

So this makes for example that if you pass an email without the "yahoo:" prefix, you also much check on the Network property of the returned Contact object. If it is 1 (=MSN network), it might still be possible that there is a second contact with the exact same email, but on the Yahoo network. So you must call GetContact again and this time with "yahoo:" prefixed to the email to check on this.


And as a sidenote and example of all this, and how many scripts don't do it properly:

In many scripts there is always some code to check if the return email isn't our own email or to get all the contacts, so the function will only do something to contacts and not on our own account (eg: to store settings or something). However what you see in most scripts is:
code:
// Do something with all the contacts, except for our own account
// (in case you have added yourself to your own contactlist)
for(var e = new Enumerator(Messenger.MyContacts); !e.atEnd(); e.moveNext()) {
        var Contact = e.item();
        if (Contact.Email !== Messenger.MyEmail) {
                // Do something here with the contact
        }
}
But this is wrong and will actually ignore contacts who have the same email as you, but who are on the Yahoo network. The proper code is:
code:
// Do something with all the contacts, except for our own account
// (in case you have added yourself to your own contactlist)
for(var e = new Enumerator(Messenger.MyContacts); !e.atEnd(); e.moveNext()) {
        var Contact = e.item();
        if (Contact.Email !== Messenger.MyEmail || Contact.Network === 2) {
                // Do something here with the contact...
                // ...and if we need to store something uniquely for this contact we also need
                // to store the network linked to this contact and thus not only the email!
        }
}
Or say that you need to grab the Contact object, again taking yahoo contacts in account:
code:
function OnEvent_ContactNameChange(Email, NewName) {
        var Contact = Messenger.MyContacts.GetContact(Email);
        // the returned Contact object will always be unique since events like
        // this will always pass a prefixed email if needed.
}
But(!!!):
code:
var Email = "user@yahoo.com"; // .NET Passport (aka Windows Live ID)
var Contact = Messenger.MyContacts.GetContact(Email);
// the returned Contact object is NOT unique!
// It might be possible there is another contact with that same email,
// but using the Yahoo network.

var Email = "yahoo:user@yahoo.com";
var Contact = Messenger.MyContacts.GetContact(Email);
// the returned Contact object will always be unique since only contacts on
// the Yahoo network will be searched.

-----

Last: What do you mean by "for now I use the GUID to identify them"? I mean, what you do in that script regarding GUIDs is just creating a random but unique GUID each time. This GUID has got nothing todo with the contact, not even with the script. So I don't quite understand how that is going to be used to identify the contact...

-----

The code you showed works perfectly here though (except for the GUID which is kind of useless). And yahoo contacts are nicely found and returned.

This post was edited on 01-17-2007 at 04:23 AM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
01-17-2007 03:43 AM
Profile PM Find Quote Report
questsin
New Member
*


Posts: 14
Joined: Jan 2007
O.P. RE: Yahoo contacts

thanks for the tip. It explains alot. I'm new to Messenger Plus Live, but like it.

I've been operating a MSN chat bot for a few years and constantly porting my code from platform 2 platform.

You could say I've seen them all.

I use the GUID for interaction with my database server as a last resort. Just to tag the contact for that chat session only.

regards
01-20-2007 02:32 AM
Profile E-Mail PM Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15517
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: Yahoo contacts
quote:
Originally posted by questsin
I use the GUID for interaction with my database server as a last resort. Just to tag the contact for that chat session only
I see, but make sure you do not create a new GUID for that contact, even in the same chat session/chat window or anywhere else. Since it will create a different GUID each time you run it (as it depends on nothing).

If you want a contact specific ID for a chat session, you better use the msnID (or userID, whatever you wanna call it) combined with the handle of the chat window. just imho...

;)

This post was edited on 01-20-2007 at 02:37 AM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
01-20-2007 02:34 AM
Profile 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