Made some changes for joined/left guild messages, and to more easily support adding more message types:
Code:
local DESTINATION = UIErrorsFrame
local messageTypes = {
{
-- X has come online
pattern = ERR_FRIEND_ONLINE_SS:gsub("%%s", "(.+)"):gsub("[%[%]]", "%%%1"),
r = 0.3, g = 1, b = 0.3,
},
{
-- X has gone online
pattern = ERR_FRIEND_OFFLINE_S:gsub("%%s", "(.+)"),
r = 0.6, g = 0.6, b = 0.6,
},
{
-- X has joined the guild
pattern = ERR_GUILD_JOIN_S:gsub("%%s", "(.+)"),
r = 0.3, g = 1, b = 0.3,
},
{
-- X has left the guild
pattern = ERR_GUILD_LEAVE_S:gsub("%%s", "(.+)"),
r = 0.6, g = 0.6, b = 0.6,
},
}
local f = CreateFrame("Frame")
f:RegisterEvent("CHAT_MSG_SYSTEM")
f:SetScript("OnEvent", function(self, event, text)
for i = 1, #messageTypes do
local messageType = messageTypes[i]
if text:match(messageType.pattern) then
if not DESTINATION:IsMouseEnabled() then
-- Remove link brackets if the destination frame doesn't support clicking
text = text:gsub("%[(.-)%]", "%1")
end
return DESTINATION:AddMessage(text, messageType.r, messageType.g, messageType.b)
end
end
end)