The gsub function accepts three arguments: the string, what to look for, and what to substitute.
msg=gsub(msg,find,replace)
or
msg=msg:gsub(find,replace)
This means that replace being an empty string, "", you are deleting what the function finds.
Lua Code:
ChatFrame_AddMessageEventFilter("CHAT_MSG_BG_SYSTEM_ALLIANCE",function(_,_,msg,...)
msg=msg:gsub(" If left unchallenged, the Alliance will control it in 1 minute!","")
msg=msg:gsub(" control it in 1 minute!","")
return nil,msg,...
end)
The above code only filters the blue text. To alter the red text, you need to filter the Horde event.
Lua Code:
ChatFrame_AddMessageEventFilter("CHAT_MSG_BG_SYSTEM_HORDE",function(_,_,msg,...)
msg=msg:gsub("The Horde Flag was picked up by ","")
msg=msg:gsub("The Horde Flag was captured by ","")
return nil,msg,...
end)
If I got the colors wrong, I apologize. The messages above may all be blue, it's been a long time since I played battlegrounds.
Edit:
Now that I think about it, you don't have to worry about the different events if you just filter all of them at once.
Lua Code:
local filterfunc=function(_,_,msg,...)
msg=msg:gsub(" If left unchallenged, the Alliance will control it in 1 minute!","")
msg=msg:gsub(" control it in 1 minute!","")
msg=msg:gsub("The Horde Flag was picked up by ","")
msg=msg:gsub("The Horde Flag was captured by ","")
return nil,msg,...
end
ChatFrame_AddMessageEventFilter("CHAT_MSG_BG_SYSTEM_ALLIANCE",filterfunc)
ChatFrame_AddMessageEventFilter("CHAT_MSG_BG_SYSTEM_HORDE",filterfunc)
ChatFrame_AddMessageEventFilter("CHAT_MSG_BG_SYSTEM_NEUTRAL",filterfunc)
This takes one filter function and applies it to all three BG announcement events.