/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

  1. local function GetLinkColor(data)
  2. local type, id, arg1 = string.match(data, '(%w+):(%d+):(%d+)')
  3. -- prevent lua error for unknown item type and return yellow for these items
  4. if not type then return '|cffffd000' end
  5. if(type == 'item') then
  6. local _, _, quality = GetItemInfo(id)
  7. if(quality) then
  8. local _, _, _, hex = GetItemQualityColor(quality)
  9. return hex
  10. else
  11. -- Item is not cached yet, show a white color instead
  12. -- Would like to fix this somehow
  13. return '|cffffffff'
  14. end
  15. elseif(type == 'quest') then
  16. local color = GetQuestDifficultyColor(arg1)
  17. return format('|cff%02x%02x%02x', color.r * 255, color.g * 255, color.b * 255)
  18. elseif(type == 'spell') then
  19. return '|cff71d5ff'
  20. elseif(type == 'achievement') then
  21. return '|cffffff00'
  22. elseif(type == 'trade' or type == 'enchant') then
  23. return '|cffffd000'
  24. elseif(type == 'instancelock') then
  25. return '|cffff8000'
  26. elseif(type == 'glyph') then
  27. return '|cff66bbff'
  28. elseif(type == 'talent') then
  29. return '|cff4e96f7'
  30. elseif(type == 'levelup') then
  31. return '|cffFF4E00'
  32. end
  33. end
  34. local function AddLinkColors(self, event, msg, ...)
  35. local data = string.match(msg, '|H(.-)|h(.-)|h')
  36. if(data) then
  37. return false, msg:gsub('|H(.-)|h(.-)|h', GetLinkColor(data) .. '|H%1|h%2|h|r'), ...
  38. else
  39. return false, msg, ...
  40. end
  41. end
  42. ChatFrame_AddMessageEventFilter('CHAT_MSG_BN_WHISPER', AddLinkColors)
  43. ChatFrame_AddMessageEventFilter('CHAT_MSG_BN_WHISPER_INFORM', AddLinkColors)