-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
bnet.lua
42 lines (33 loc) · 1.58 KB
/
bnet.lua
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
32
33
34
35
36
37
38
39
40
41
--[[ BattleNet Module ]]--
local _, BCM = ...
BCM.modules[#BCM.modules+1] = function()
if bcmDB.BCM_BNet then bcmDB.noBNetColor = nil return end
if not bcmDB.playerLBrack then bcmDB.playerLBrack = "[" bcmDB.playerRBrack = "]" bcmDB.playerSeparator = ":" end
local GetAccountInfoByID = C_BattleNet.GetAccountInfoByID
local changeBNetName = function(icon, misc, id, moreMisc, fakeName, tag, colon)
local accountInfoTbl = GetAccountInfoByID(id)
local battleTag, englishClass = accountInfoTbl.battleTag, accountInfoTbl.gameAccountInfo.className
if not battleTag then
local msg = "Tell the BasicChatMods dev: ERROR battleTag was nil!"
print(msg)
geterrorhandler()(msg)
elseif battleTag == "" then
local msg = "Tell the BasicChatMods dev: ERROR battleTag was blank!"
print(msg)
geterrorhandler()(msg)
elseif bcmDB.noRealName then -- Replace real name with battle tag if enabled
fakeName = battleTag:gsub("^(.+)#%d+$", "%1")
end
if englishClass and englishClass ~= "" then -- Not playing wow, logging off, etc.
fakeName = bcmDB.noBNetColor and fakeName or "|cFF"..BCM:GetColor(englishClass, true)..fakeName.."|r" -- Colour name if enabled
end
if bcmDB.noBNetIcon then --Remove "person" icon if enabled
icon = icon:gsub("|[Tt][^|]+|[Tt]", "")
end
return icon..misc..id..moreMisc..bcmDB.playerLBrack..fakeName..bcmDB.playerRBrack..tag..(colon == ":" and bcmDB.playerSeparator or colon)
end
BCM.chatFuncs[#BCM.chatFuncs+1] = function(text)
text = text:gsub("^(.*)(|HBNplayer:%S-|k:)(%d-)(:%S-|h)%[(%S-)%](|?h?)(:?)", changeBNetName)
return text
end
end