ChaosInc
15-10-2006, 04:11 PM
I've created a filter system to scan the received messages in BG chat and such.
**Code Begin **
local ORIG_ChatFrame_OnEvent = ChatFrame_OnEvent;
function ChatFrame_OnEvent(event)
-if (event == "CHAT_MSG_BATTLEGROUND") or (event == "CHAT_MSG_BATTLEGROUND_LEADER") or (event == "CHAT_MSG_WHISPER") then
--local arg1 = string.lower(arg1);
--local arg2 = string.lower(arg2);
--if (XRI_Debug) then
---DEFAULT_CHAT_FRAME:AddMessage("|cFFFF00FFXRI:|r Event trigged: ".. event);
--end;
--if (XRI_FilterCheck(arg1)) then -- does anything in the message match a filtered word?
---if (XRI_Debug) then
----DEFAULT_CHAT_FRAME:AddMessage("|cFFFF00FFXRI:|r Filter match found, displaying message despite author ignore status.");
---end;
---ORIG_ChatFrame_OnEvent(event);
---return;
--elseif (XRI_IgnoreCheck(arg2)) then -- is the author on the ignored list?
---return;
--end;
-end;
-ORIG_ChatFrame_OnEvent(event);
end;
**Code End**
I'm running into a problem though. It scans the messages and author just fine and takes the appropriate action, but when it's done it fires the same event a second time before it outputs a result, and sometimes prints the message twice. I'm pretty sure it has to to with registering and unregistering the event, but even after looking to wowwiki, I can't seem to get it right (tend to blow up a lot of stuff.)
The filter and ignore list functions are working correctly, so I left them out. If anyone can help with this but needs those, I'll be happy to post it up. I'm about at my wits end having worked on this for 2 days now and can't seem to get it working correctly.
Here's a screenshot of what's happening:
http://www.rucls.net/~chaosinc/wowpics/error.jpg
**Code Begin **
local ORIG_ChatFrame_OnEvent = ChatFrame_OnEvent;
function ChatFrame_OnEvent(event)
-if (event == "CHAT_MSG_BATTLEGROUND") or (event == "CHAT_MSG_BATTLEGROUND_LEADER") or (event == "CHAT_MSG_WHISPER") then
--local arg1 = string.lower(arg1);
--local arg2 = string.lower(arg2);
--if (XRI_Debug) then
---DEFAULT_CHAT_FRAME:AddMessage("|cFFFF00FFXRI:|r Event trigged: ".. event);
--end;
--if (XRI_FilterCheck(arg1)) then -- does anything in the message match a filtered word?
---if (XRI_Debug) then
----DEFAULT_CHAT_FRAME:AddMessage("|cFFFF00FFXRI:|r Filter match found, displaying message despite author ignore status.");
---end;
---ORIG_ChatFrame_OnEvent(event);
---return;
--elseif (XRI_IgnoreCheck(arg2)) then -- is the author on the ignored list?
---return;
--end;
-end;
-ORIG_ChatFrame_OnEvent(event);
end;
**Code End**
I'm running into a problem though. It scans the messages and author just fine and takes the appropriate action, but when it's done it fires the same event a second time before it outputs a result, and sometimes prints the message twice. I'm pretty sure it has to to with registering and unregistering the event, but even after looking to wowwiki, I can't seem to get it right (tend to blow up a lot of stuff.)
The filter and ignore list functions are working correctly, so I left them out. If anyone can help with this but needs those, I'll be happy to post it up. I'm about at my wits end having worked on this for 2 days now and can't seem to get it working correctly.
Here's a screenshot of what's happening:
http://www.rucls.net/~chaosinc/wowpics/error.jpg