And here is a nicer version of this all.
code:
function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind) {
var Pattern = new RegExp("^report", "i");
var OK = Pattern.exec(Message);
//If the message begins with "report"...
if (OK) {
var Contacts = ChatWnd.Contacts;
//Loop through the participants of the chatwindow
for (var e = new Enumerator(Contacts); !e.atEnd(); e.moveNext()) {
var Contact = e.item();
//If the origin matches the current contacts name...
if (Origin == Contact.Name) {
var Message = "From: " + Contact.Email + "\n\nMessage: " + Message;
//If the status of the home user is Offline...
if (Messenger.MyContacts.GetContact("home@server.com").Status == 1) {
Messenger.OpenChat(Contact.Email).SendMessage("Da boss is currently offline!");
} else {
Messenger.OpenChat("home@server.com").SendMessage(Message);
}
//Ends the function to stop looking for other contact matches
return;
}
}
}
}