I made a script to do this for myself a while ago, this should start you off:
code:
//////////////////////////////////////////////////////////////////////////////////////
////// //////
////// AwaySMS //////
////// //////
//////////////////////////////////////////////////////////////////////////////////////
var myPhone = "01234567890";
var sUser = "usernmae";
var sPass = "password";
var whitelist = Array();
whitelist[0] = "email@hotmail.co.uk";
whitelist[1] = "emailone@hotmail.com";
whitelist[2] = "emailtwo@hotmail.com";
whitelist[3] = "email3@hotmail.com";
whitelist[4] = "emailfour@hotmail.com";
whitelist[5] = "email5@hotmail.com";
whitelist[6] = "emailsix@hotmail.com";
whitelist[7] = "emailseven@hotmail.com";
whitelist[8] = "emaileight@hotmail.co.uk";
function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind)
{
if ((Origin.indexOf('(')==0)&&(Origin.indexOf(':')!=-1)&&(Origin.indexOf(')')!=-1)){
var sOrigin = Origin.substr(Origin.indexOf(')')+2);
}else{
var sOrigin = Origin;
}
if((sOrigin != Messenger.MyName) && (MessageKind == MSGKIND_SAYS)){
if(Messenger.MyStatus == STATUS_AWAY || Messenger.MyStatus == STATUS_IDLE)
{
for(var e = new Enumerator(ChatWnd.Contacts);!e.atEnd();e.moveNext()){
var Contact = e.item();
if (Contact.Email != Messenger.MyEmail){var sEmail = Contact.Email;}
}
for (i = 0; i < whitelist.length; i ++) {
if(whitelist[i] == sEmail)
{
SendMsg(sEmail, Origin, Message);
}
}
}
}
}
function SendMsg(Email, Name, Message)
{
var sSender = Email.substr(0,Email.indexOf('@'));
if ((Name.indexOf('(')==0)&&(Name.indexOf(':')!=-1)&&(Name.indexOf(')')!=-1)){
var sName = Name.substr(Name.indexOf(')')+2,20);
}else{
var sName = Name.substr(0,20);
}
var sMsg = sName + ' (' +sSender + '): ' + Message;
Debug.Trace(sMsg);
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
var sURL = "http://www.50sms.com/multi.php?login="+sUser+"&password="+sPass+"&phones="+myPhone+"&message="+sMsg+"&originator=AwaySMS";
xmlhttp.open("GET",sURL, true);
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState==4) {
var sRet = xmlhttp.responseText;
if (sRet.indexOf('<result>OK</result>')!=-1){
MsgPlus.DisplayToast("AwaySMS", "SMS Sent");
}else{
MsgPlus.DisplayToast("AwaySMS", "Error Sending SMS");
}
}
};
xmlhttp.send();
}
You may want to change it, as this is what it does currentley:
- Works with 50sms.com - Can easily be changed
- Only sends messages when my status is idle
- Only sends me a message when whitelisted emails contact me
- Shows the display name and start of email address