The online/offline messages don't distinguish between friends and guildmates, so you have to scan your friends list and figure that out yourself:
Code:
local ONLINE = ERR_FRIEND_ONLINE_SS:gsub("%%s", "(.-)"):gsub("[%[%]]", "%%%1")
local OFFLINE = ERR_FRIEND_OFFLINE_S:gsub("%%s", "(.-)")
local function IsFriend(name)
for i = 1, GetNumFriends() do
if GetFriendInfo(i) == name then
return true
end
end
end
ChatFrame_AddMessageEventFilter("CHAT_MSG_SYSTEM", function(frame, event, message)
local action = "OFFLINE"
local _, name = strmatch(message, ONLINE)
if name then
action = "ONLINE"
else
name = strmatch(message, OFFLINE)
end
if not name then
return
end
if action == "ONLINE" then
if IsFriend(name) then
-- A friend came online.
else
-- A guildmate came online.
end
elseif action == "OFFLINE" then
if IsFriend(name) then
-- A friend went offline.
else
-- A guildmate went offline.
end
end
end)
For kgPanels you'd probably want to put that in the OnLoad script for your panel. I assume you only want to change the color temporarily, in which case you'd want to (a) change the color and (b) set a variable indicating what time the color was changed in the above function, and then add an OnUpdate script to change the color back to the default after a specified amount of time:
Code:
self.text:SetTextColor(0, 1, 0) -- change it to green
self.colorTimeout = 5 -- change it back 5 seconds from now
OnUpdate:
Code:
if not self.colorTimeout then
return
end
self.colorTimeout = self.colorTimeout - elapsed
if self.colorTimeout <= 0 then
self.text:SetTextColor(1, 1, 1) -- change it back to white
self.colorTimeout = nil
end