-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCustomNames_Chat.lua
More file actions
31 lines (27 loc) · 892 Bytes
/
CustomNames_Chat.lua
File metadata and controls
31 lines (27 loc) · 892 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
local lib = LibStub("CustomNames")
local AceHook = LibStub("AceHook-3.0")
local function convertName(msg, name)
local customName = lib.Get(name)
if customName ~= name then
local color = msg:match("|c(%x%x%x%x%x%x%x%x)(.-)|r")
if color then
local colorCodedName = WrapTextInColorCode(customName, color)
return "|Hplayer:"..name.."|h["..colorCodedName.."]|h"
else
return "|Hplayer:"..name.."|h["..customName.."]|h"
end
end
end
function AceHook:AddMessage(frame, text, ...)
if issecretvalue(text) then return self.hooks[frame].AddMessage(frame, text, ...) end
if text and type(text) == "string" then
text = text:gsub("(|Hplayer:([^:]+).-|h.-|h)", convertName)
end
return self.hooks[frame].AddMessage(frame, text, ...)
end
for i = 1, NUM_CHAT_WINDOWS do
local cf = _G["ChatFrame" .. i]
if cf ~= COMBATLOG then
AceHook:RawHook(cf, "AddMessage", true)
end
end