Ah, I missed that. The taint source for that is at the bottom.
Lua Code:
frame.DefaultAddMessage = frame.AddMessage --idk what all of this is
frame.AddMessage = AddMessage --idk what all of this is
As for the things you do in your replaced AddMessage, you already use ChatFrame_AddMessageEventFilter for some events. For the stuff you can't change through the filter return, just build your own message and feed it directly into AddMessage, then return true in the filter so that the original line is filtered. The event filters get all the returns from the chat event, so you can do anything Blizzard's chat output does without replacing AddMessage.
Here's an example of your channel header change added to colorName along with duplicate protection. Keep in mind I did not test this, but this should give you an idea to go on whether it works or not.
Lua Code:
local messages={}
local function colorName(self, event, msg, ...)
local test = msg:gsub('[^a-zA-Z%s]', '')
local words = {strsplit(' ', test)}
for i = 1, #words do
local w = words[i]
if (w and not (w == 'player' or w == 'target') and UnitName(w) and UnitIsPlayer(w)) then
local class = select(2, UnitClass(w))
local colors = RAID_CLASS_COLORS[class]
if (colors) then
msg = gsub(msg, w, '|cff'..RGBPercToHex(colors.r, colors.g, colors.b)..'%1|r')
end
end
end
-- get some of the args from the chat event
local namerealm,lang,fullchan,name,afkdnd,zoneID,chanID,channame,unusedzero,lineID,playerguid=...
-- get text color and id of event (FrameXML\ChatFrame.lua:3186)
local type = strsub(event, 10)
local info = ChatTypeInfo[type]
if event=="CHAT_MSG_CHANNEL" then
-- prevent duplicate messages
if messages[lineID] then
return true -- hide, do nothing
else
messages[lineID]=true
end
-- since we have the raw message, we have to add the channel number ourselves
msg = "|Hchannel:channel:"..chanID.."|h"..chanID..".|h "..msg
-- we also need to add the timestamp exactly how Blizzard does it
-- FrameXML\ChatFrame.lua:3540 (BetterDate @ FrameXML\UIParent.lua:4736)
if CHAT_TIMESTAMP_FORMAT then
msg= BetterDate(CHAT_TIMESTAMP_FORMAT, time())..msg
end
-- add message as if it was the original
self:AddMessage(msg,info.r,info.g,info.b,info.id)
-- hide original message
return true
end
return false, msg, ...
end