Would look something like this:
js code:
var oChats = {};
function OnEvent_ChatWndSendMessage(pChatWnd, sMessage) {
oChats[pChatWnd.Handle] = sMessage;
}
function OnEvent_ChatWndReceiveMessage(pChatWnd, sOrigin, sMessage, nKind) {
if (oChats[pChatWnd.Handle] === sMessage) {
// Looks like we sent the message
// Do whatever it is we need to do
OnEvent_ChatWndDestroyed(pChatWnd);
return sMessage;
}
// Oh doesn't look like we sent the message
// so do whatever it is we need to do
}
function OnEvent_ChatWndDestroyed(pChatWnd) {
delete oChats[pChatWnd.Handle];
}