quote:
Originally posted by deAd
The code I posted works in a similar way to what Plus! describes.
not at all... it will fail in many occasions...
quote:
Originally posted by deAd
However, even without optimization I'd consider it to be better than what markee posted.
it is worse though...
----------------------------
Code which checks upon the registry for StuffPlug's ChatOnly name:
code:
function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind) {
var sMyChatName = Messenger.MyName;
var sStuffPlugPath = "HKLM\\SOFTWARE\\iAvatars.com\\StuffPlug\\";
var oWSH = new ActiveXObject("WScript.Shell");
try {
var bStuffPlugEnabled = true;
var bStuffPlugEnabled = oWSH.RegRead(sStuffPlugPath + "DisabledFor" + Messenger.MyUserId) == 0;
} catch( e){}
try {
if (bStuffPlugEnabled) {
if (oWSH.RegRead(sStuffPlugPath + Messenger.MyUserId + "\\ChatName") == 1) {
var sMyChatName = "StuffPlug User";
var sMyChatName = oWSH.RegRead(sStuffPlugPath + Messenger.MyUserId + "\\szChatName");
}
}
} catch( e){}
if (Origin !== sMyChatName) {
// a contact sent the message, so do whatever
}
}
- will fail if contact has same chat name as user.
Code without checking (maybe version dependant) registry settings:
code:
var aSent = new Array();
function OnEvent_ChatWndSendMessage(ChatWnd, Message) {
aSent[ChatWnd.Handle] = Message;
}
function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind) {
if (aSent[ChatWnd.Handle] === Message) {
delete aSent[ChatWnd.Handle];
} else {
// a contact sent the message, so do whatever
}
}