/Tukui/modules/chat/blizzfixrealidlink.lua
http://github.com/Asphyxia/Tukui · Lua · 47 lines · 40 code · 4 blank · 3 comment · 23 complexity · d05e73a52bd4b3209613563620caf655 MD5 · raw file
- local function GetLinkColor(data)
- local type, id, arg1 = string.match(data, '(%w+):(%d+):(%d+)')
-
- -- prevent lua error for unknown item type and return yellow for these items
- if not type then return '|cffffd000' end
-
- if(type == 'item') then
- local _, _, quality = GetItemInfo(id)
- if(quality) then
- local _, _, _, hex = GetItemQualityColor(quality)
- return hex
- else
- -- Item is not cached yet, show a white color instead
- -- Would like to fix this somehow
- return '|cffffffff'
- end
- elseif(type == 'quest') then
- local color = GetQuestDifficultyColor(arg1)
- return format('|cff%02x%02x%02x', color.r * 255, color.g * 255, color.b * 255)
- elseif(type == 'spell') then
- return '|cff71d5ff'
- elseif(type == 'achievement') then
- return '|cffffff00'
- elseif(type == 'trade' or type == 'enchant') then
- return '|cffffd000'
- elseif(type == 'instancelock') then
- return '|cffff8000'
- elseif(type == 'glyph') then
- return '|cff66bbff'
- elseif(type == 'talent') then
- return '|cff4e96f7'
- elseif(type == 'levelup') then
- return '|cffFF4E00'
- end
- end
- local function AddLinkColors(self, event, msg, ...)
- local data = string.match(msg, '|H(.-)|h(.-)|h')
- if(data) then
- return false, msg:gsub('|H(.-)|h(.-)|h', GetLinkColor(data) .. '|H%1|h%2|h|r'), ...
- else
- return false, msg, ...
- end
- end
- ChatFrame_AddMessageEventFilter('CHAT_MSG_BN_WHISPER', AddLinkColors)
- ChatFrame_AddMessageEventFilter('CHAT_MSG_BN_WHISPER_INFORM', AddLinkColors)