View Single Post
12-15-11, 08:27 PM   #15
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
@Vladinator:

1. You didn't pass the message back to the real AddMessage method, so your hook completely breaks the chat frame.

2. If a message contains more than one icon, your pattern will delete the first and last icons, and everything in between, icon or otherwise. Using a - instead of a + will match the shortest possible string, instead of the longest.

3. Your code will only remove icons from the first chat frame.

Code:
local orig = {}
local function AddMessage(self, msg, ...)
	if type(msg) == "string" then
		msg = msg:gsub("|T.-|t", "")
	end
	return orig[self](self, msg, ...)
end
for i = 1, 10 do
	local f = _G["ChatFrame"..i]
	if f then
		orig[f] = f.AddMessage
		f.AddMessage = AddMessage
	end
end
  Reply With Quote