The function OnEvent_ChatWndMessageReceive has a parameter called pChatWnd. This is the Chat Window where the event happened. Therefore you could do something like this:
js code:
var oChatWnds = {}; // variable to hold the chat window handles and the messages we send to make sure we are not sending the message causing infinite loops
function OnEvent_ChatWndSendMessage ( pChatWnd , sMessage )
{
oChatWnds [ pChatWnd.Handle ] = sMessage; // add the message to the object
}
function OnEvent_ChatWndReceiveMessage ( pChatWnd , sOrigin , sMessage , nMessageKind )
{
if ( oChatWnds [ pChatWnd.Handle ] === sMessage ) return sMessage; // Since we just send this message we can ignore it
if ( Messenger.MyStatus === STATUS_BUSY ) // check if your status is busy
{
pChatWnd.SendMessage ( 'I currently am busy and cannot reply. Thank you for your paitence.' ); // if it is busy then send a message
}
}
function OnEvent_ChatWndDestroyed ( pChatWnd )
{
delete oChatWnds [ pChatWnd.Handle ]; // delete the message from our storage object
}