Code from DuctTape (slightly modified for easier reading):
Code:
local function filter(_,_,msg)
msg = string.lower(msg); -- lower case the incoming text for filtering
for i= 1, #(keywords) do
if strfind(msg, keywords[i]) then -- search msg for current keyword in list
debug(keywords[i].. " found in message.") -- print verification (for debugging)
return false -- display message
else
return true -- ignore message, does not show up
end
end
end
ChatFrame_AddMessageEventFilter("CHAT_MSG_BATTLEGROUND", filter);
If it's a simple one word lookup, you can boil it down to
Code:
local function filter(_,_,msg)
msg = string.lower(msg); -- lower case the incoming text for filtering
if strfind(msg, "word") then -- search msg for word
-- word found, do something
else
-- word not present, do something else
end
return false -- IMPORTANT, WILL NOT SHOW UP IN CHAT WITHOUT THIS!!!
end
ChatFrame_AddMessageEventFilter("event", filter);