code:
function sendMessageWhenRequired(myMessage, Email)
{
if (myMessage.length > 0)
{
//Check if my status requires sending a message
var myStatus = Messenger.MyStatus;
var sendStatus = myMessage[3].split(";");
for (var i=0; i<sendStatus.length; i++)
{
var eSendStatus = getStatusEnum(sendStatus[ i]);
if (eSendStatus == myStatus)
{
//Don't send when status of the contact is offline or appears offline or status is unknown
var contactStatus = Messenger.MyContacts.GetContact(Email).Status;
if (contactStatus != 1 && contactStatus != 2 && contactStatus != 0)
{
//Send a message
var chWnd = Messenger.OpenChat(Email);
if (chWnd != null) chWnd.SendMessage(myMessage[2]);
break;
}
}
}
}
}
function OnEvent_ContactSignin(Email)
{
//Get a message for signin event for this email if it exists
var myMessage = GetMessage(Email, "SignIn");
sendMessageWhenRequired(myMessage, Email);
}
A little explanation maybe:
code:
var myMessage = GetMessage(Email, "Signin");
GetMessage is a function in another js file wich looks in an xml file for a node with the attributes 'email' and 'signin'. If it is found an array of length 4 is returned. This array contains: the email of the contact, on which action a message is to be send, the message to send and all statusses in which a message should be automatically sent. The last value in the array is build as following: Online;Away;Busy, hence the
split you see in
sendMessageWhenRequired.
The function
sendMessageWhenRequired is also called for all the other message that are sent and they only get delivered once.
As I also said before, the
OnEvent_ContactSignin - event is executed twice ...
Try it... Make yourself a dummy account, or ask a friend to signout and in again so that you can send a message...
There just has to be a reason why that event is executed twice...