quote:
Originally posted by Mattike
code:
if(MessengerStart && Messenger.MyStatus > 1)
As phalanxii pointed out, this is wrong and can never become
true since if
MessengerStart is
true,
Messenger.MyStatus will always be 0.
However...
quote:
Originally posted by phalanxii
but if I'm not mistaken, shouldn't it be:code:
function OnEvent_Initialize(MessengerStart) {
if(!MessengerStart && Messenger.MyStatus > 1) {
OnEvent_SigninReady(Messenger.MyEmail); //Call the event like a normal function
}
}
function OnEvent_SigninReady(Email) {
//Original code for OnEvent_Initialize goes here
}
That way, OnEvent_SigninReady executes when a) the script is enabled when Messenger is signed in and b) when you sign in to Messenger. Also, if you don't need any details from contacts, you can use OnEvent_Signin instead, as this will give the same result, but a lot earlier.
That's not correct either though. The stuff in
SigninReady will not be executed when Messenger is started the first time...
And if you check on
Messenger.MyStatus you do not need to check on
MessengerStart too.
Because if Messenger is started the first time, your status (and email) can not be
something as you still need to sign in.
If the script is restarted (and thus
MessengerStart is
false) the important thing is again your status. If that is 0 (not signed in),
Messenger.MyEmail will not be defined. If you are signed in,
Messenger.MyEmail will be defined.
So, the proper code you want is:
code:
function OnEvent_Initialize(MessengerStart) {
if(Messenger.MyStatus > 0) {
OnEvent_SigninReady(Messenger.MyEmail);
}
}
function OnEvent_SigninReady(Email) {
//Original code for OnEvent_Initialize goes here
}
1) you start messenger thus script is started for the first time:
OnEvent_Initialize is called
MessengerStart is
true
Messenger.MyStatus is 0
Messenger.MyEmail is undefined
2) you restart the script:
OnEvent_Initialize is called
MessengerStart is
false
Messenger.MyStatus is 0
Messenger.MyEmail is undefined
3) you sign in:
OnEvent_Signin(Ready) is called
Messenger.MyStatus is >0
Messenger.MyEmail is defined
4) you restart the script:
OnEvent_Initialize is called
MessengerStart is
false
Messenger.MyStatus is >0
Messenger.MyEmail is defined
5) you sign out and then you restart the script
see 2