Mopar wrote:Yeah this is an aspect of the original vanilla way of creating chat handlers. The APIs were modified in 2.0 and it's possible to make it compatible there, but not in vanilla, because of the way you have to hook the chat handling function. Sorry about that, just have to choose between the two.
Are you sure?
You can Always hook the prat function that does the registering and you just pass Prat the info it needs from your addon? haven't got prat infront of me, but look into it.
Just wait a few seconds reallife time
then do
- Code: Select all
local oldChatFrameFunction;
local function ChatFrameEvent(event, arg1,etctec)
--Do ya shizzle
if(we want the message not to be filtered)
oldChatFrameFunction(event, arg1, etcetc);
end
end
function delayedInit()
oldChatFrameFunction = ChatFrame_OnEvent;
ChatFrame_OnEvent = ChatFrameEvent;
end
edit: test this, do mind that this is all written free hand and havent been tested
- Code: Select all
--============================
--= This replaces the default ChatFrame handler with our own.
--= Implementation could conflict with other chat handling programs, but the API here is really old,
--= and was from before Chat Filters were implemented.
--============================
local OldChatFrame_OnEvent;
local SpamThrottle_ChatFrame_OnEvent;
local UpdateFrame = CreateFrame("Frame", nil);
UpdateFrame:SetScript("OnUpdate",OverHookEvents);
UpdateFrame:Show();
local StartTime = time();
local Initialized;
function OverHookEvents()
if(time() - StartTime > 10 and Initialized == nil) then
OldChatFrame_OnEvent = ChatFrame_OnEvent;
ChatFrame_OnEvent = SpamThrottle_ChatFrame_OnEvent;
StartTime = nil;
UpdateFrame:SetScript("OnUpdate", nil);
UpdateFrame = nil;
Initialized = true;
end
end
--ChatFrame_OnEvent
function SpamThrottle_ChatFrame_OnEvent(event)
-- arg1 is the actual message
-- arg2 is the player name
-- arg4 is the composite channel name (e.g. "3. global")
-- arg8 is the channel number (e.g. "3")
-- arg9 is the channel name (e.g. "global")
local hideColor = "|cFF5C5C5C";
local oppFacColor = "|cA0A00000";
local theColor = hideColor;
if SpamThrottle_Config == nil then SpamThrottle_init(); end
if not SpamThrottle_Config.STActive then
OldChatFrame_OnEvent(event);
return;
end;
if (SpamThrottle_Config.STCtrlMsgs) then -- Remove the left/joined channel spam and a few other notification messages
if (event == "CHAT_MSG_CHANNEL_JOIN" or event == "CHAT_MSG_CHANNEL_LEAVE" or event == "CHAT_MSG_CHANNEL_NOTICE" or event == "CHAT_MSG_CHANNEL_NOTICE_USER") then
return;
end
end
if arg2 then -- if this is not a server message
if (event == "CHAT_MSG_CHANNEL" or (event == "CHAT_MSG_YELL" and SpamThrottle_Config.STYellMsgs) or (event == "CHAT_MSG_SAY" and SpamThrottle_Config.STSayMsgs) or (event == "CHAT_MSG_WHISPER" and SpamThrottle_Config.STWispMsgs)) then
-- Code to handle message goes here. Just return if we are going to ignore it.
if arg1 and arg2 then -- only execute this code once although event handler is called many times per message
local NormalizedMessage = SpamThrottle_strNorm(arg1, arg2);
if time() == MessageLatestTime[NormalizedMessage] then return end;
end
local BlockType = SpamThrottle_ShouldBlock(arg1,arg2,event,arg9);
SpamThrottle_RecordMessage(arg1,arg2);
if SpamThrottle_Config.STWispBack and event == "CHAT_MSG_WHISPER" and not SpamThrottle_Config.STReverse then
if BlockType == 1 or BlockType == 2 then
SendChatMessage(SpamThrottleChatMsg.WhisperBack, "WHISPER", nil, arg2);
end
end
if BlockType == 2 then
return;
end
if BlockType == 3 then
theColor = oppFacColor;
end
if BlockType == 1 or BlockType == 3 then
local CleanText = "";
CleanText = string.gsub(arg1,"|c%x%x%x%x%x%x%x%x", "");
CleanText = string.gsub(CleanText,"|r", "");
CleanText = string.gsub(CleanText,"|H.-|h", "");
CleanText = string.gsub(CleanText,"|h", "");
if event == "CHAT_MSG_YELL" then
CleanText = theColor .. "[" .. arg2 .. "] yells: " .. CleanText .. "|r";
else
if event == "CHAT_MSG_SAY" then
CleanText = theColor .. "[" .. arg2 .. "] says: " .. CleanText .. "|r";
else
if event == "CHAT_MSG_WHISPER" then
CleanText = theColor .. "[" .. arg2 .. "] whispers: " .. CleanText .. "|r";
else
CleanText = theColor .. "[" .. arg4 .. "] [" .. arg2 .. "]: " .. CleanText .. "|r";
end
end
end
DEFAULT_CHAT_FRAME:AddMessage(CleanText);
return;
end
end
end
local theStatusValue = string.format("%7d",table.length(MessageList));
SpamThrottleStatusValue5:SetText(theStatusValue);
theStatusValue = string.format("%7d",FilteredCount);
SpamThrottleStatusValue6:SetText(theStatusValue);
OldChatFrame_OnEvent(event);
end