@@ -23,6 +23,8 @@ local C_AddOns_GetAddOnEnableState = API.C_AddOns_GetAddOnEnableState
2323local C_AddOns_EnableAddOn = API .C_AddOns_EnableAddOn
2424local C_AddOns_DisableAddOn = API .C_AddOns_DisableAddOn
2525local C_ChatInfo_RegisterAddonMessagePrefix = API .C_ChatInfo_RegisterAddonMessagePrefix
26+ local issecretvalue = API .issecretvalue
27+ local C_ClassColor_GetClassColor = API .C_ClassColor_GetClassColor
2628-- 引入结巴分词库
2729local jieba = LibStub (" inputinput-jieba" )
2830
@@ -579,15 +581,20 @@ end
579581--- @param name string
580582--- @param realm string
581583--- @return string
582- local function addLevel (name , realm )
583- local maxLevel = GetMaxPlayerLevel ()
584- local level = UnitLevel (name )
584+ local function addLevel (name , realm , senderGUID )
585+ local level = 0
586+ if not issecretvalue (name ) then
587+ level = UnitLevel (name )
588+ end
585589 local name_realm = name
586- if realm and # realm > 0 and realm ~= GetRealmName () then
590+ if not issecretvalue ( realm ) and realm and realm ~= GetRealmName () then
587591 name_realm = U :join (' -' , name , realm )
588592 end
589- if level and level ~= 0 and maxLevel ~= level then
590- name_realm = ' |cFF909399' .. level .. ' |r' .. name_realm
593+ if level and level ~= 0 then
594+ local maxLevel = GetMaxPlayerLevel ()
595+ if maxLevel ~= level then
596+ name_realm = ' |cFF909399' .. level .. ' |r' .. name_realm
597+ end
591598 end
592599 return name_realm
593600end
@@ -613,30 +620,31 @@ local function FormatMSG(channel, senderGUID, msg, isChannel, sender, isPlayer)
613620 name_realm = ' |BTag:' .. accountInfo .battleTag .. ' |BTag'
614621 end
615622 end
616- elseif # senderGUID > 0 then
623+ else
617624 local localizedClass , englishClass , localizedRace , englishRace , sex , name , realmName = GetPlayerInfoByGUID (
618625 senderGUID )
619- class = englishClass
620- name_realm = addLevel (name , realmName )
626+ if localizedClass then
627+ class = englishClass
628+ name_realm = addLevel (name , realmName , senderGUID )
629+ end
621630 end
622631 end
623- if # name_realm <= 0 then
632+ if not issecretvalue ( name_realm ) and # name_realm <= 0 then
624633 name_realm = sender or ' '
625634 local name , realm = strsplit (' -' , name_realm )
626635 class = UnitClass (name )
627- name_realm = addLevel (name , realm )
636+ name_realm = addLevel (name , realm , senderGUID )
628637 end
629638
630- local classColor = RAID_CLASS_COLORS [ class ]
639+ local classColor = C_ClassColor_GetClassColor ( class )
631640 if not classColor then
632641 --- @diagnostic disable-next-line : missing-fields
633642 classColor = {
634643 colorStr = ' FF' .. channelColor
635644 }
636645 else
637- U :UnitColor (name_realm , classColor .colorStr )
646+ U :UnitColor (name_realm , classColor .colorStr , senderGUID )
638647 end
639-
640648 local TO = ' '
641649 if isPlayer then
642650 TO = L [' TO' ] .. ' : '
@@ -1183,22 +1191,25 @@ local function eventSetup(editBox, bg, border, backdropFrame2, resizeButton, tex
11831191 end
11841192 end )
11851193
1186-
1187- -- hooksecurefunc("ChatEdit_UpdateHeader", function(self)
1188- -- ChannelChange(self, bg, bg3, border, backdropFrame2, texture_btn, channel_name, II_LANG)
1189- -- end)
11901194 -- 11.2.7
1191- --- @diagnostic disable-next-line : undefined-field
1192- for _ , frameName in ipairs (_G .CHAT_FRAMES ) do
1193- local chat = _G [frameName ]
1194- if chat then
1195- local editbox = chat .editBox
1196- hooksecurefunc (editbox , " UpdateHeader" , function (self )
1197- ChannelChange (self , bg , bg3 , border , backdropFrame2 , texture_btn , channel_name , II_LANG )
1198- end )
1195+ if W .ClientVersion > 110207 then
1196+ --- @diagnostic disable-next-line : undefined-field
1197+ for _ , frameName in ipairs (_G .CHAT_FRAMES ) do
1198+ local chat = _G [frameName ]
1199+ if chat then
1200+ local editbox = chat .editBox
1201+ hooksecurefunc (editbox , " UpdateHeader" , function (self )
1202+ ChannelChange (self , bg , bg3 , border , backdropFrame2 , texture_btn , channel_name , II_LANG )
1203+ end )
1204+ end
11991205 end
1206+ else
1207+ hooksecurefunc (" ChatEdit_UpdateHeader" , function (self )
1208+ ChannelChange (self , bg , bg3 , border , backdropFrame2 , texture_btn , channel_name , II_LANG )
1209+ end )
12001210 end
12011211
1212+
12021213 -- 设置焦点获得事件处理函数
12031214 editBox :HookScript (" OnEditFocusGained" , function (self )
12041215 HideEuiBorder (self )
@@ -1225,10 +1236,14 @@ local function eventSetup(editBox, bg, border, backdropFrame2, resizeButton, tex
12251236 end )
12261237
12271238 local frame_E = CreateFrame (" Frame" , " II_EVENT_FRAME" )
1228- for k , v in pairs (ChatLabels ) do
1229- frame_E :RegisterEvent (v )
1239+
1240+ -- 正式服关闭聊天信息显示功能
1241+ if W .ClientVersion >= 10100 and W .ClientVersion <= 110207 then
1242+ for k , v in pairs (ChatLabels ) do
1243+ frame_E :RegisterEvent (v )
1244+ end
1245+ frame_E :RegisterEvent (' CHAT_MSG_CHANNEL' )
12301246 end
1231- frame_E :RegisterEvent (' CHAT_MSG_CHANNEL' )
12321247
12331248 frame_E :HookScript (" OnEvent" ,
12341249 function (self , ...)
@@ -1405,7 +1420,7 @@ frame:HookScript("OnEvent", function(self_f, event, ...)
14051420 if not isInit then
14061421 editBox , bg , border , backdropFrame2 , resizeButton , resizeBtnTexture , channel_name , II_TIP , II_LANG , bg3 =
14071422 MAIN :Init ()
1408-
1423+
14091424 C_ChatInfo_RegisterAddonMessagePrefix (' INPUTINPUT_V' )
14101425 U :Delay (5 , function ()
14111426 U :InitFriends ()
@@ -1642,15 +1657,28 @@ frame:HookScript("OnEvent", function(self_f, event, ...)
16421657 local discord = ' https://discord.gg/qC9RAdXN'
16431658 local curseforge = ' https://www.curseforge.com/wow/addons/inputinput/comments'
16441659 local kook = ' https://kook.vip/vghP6R'
1645- U :Delay (5 , function (cb )
1646- LOG :Info (string.format (L [' Login Information 1' ],
1647- W .colorName ,
1648- ' |cFFF56C6C[|HInputInputURL:' ..
1649- kook .. ' |hKOOK(国服)|h]|r、' .. ' |cFFF56C6C[|HInputInputURL:' .. discord .. ' |hDiscord|h]|r' ,
1650- ' |cFFF56C6C[|HInputInputURL:' .. curseforge .. ' |hCurseForge|h]|r' ))
1651- LOG :Info (string.format (L [' Login Information 2' ], " |cff409EFF/ii|r" , " |cff409EFF/inputinput|r" ,
1652- ' |cffF56C6C|HInputInputOPT:show|h[' , ' ]|h|r' ))
1653- end )
1660+ if W .ClientVersion >= 110000 then
1661+ U :Delay (5 , function (cb )
1662+ LOG :Info (string.format (L [' Login Information 1' ],
1663+ W .colorName ,
1664+ ' |cFFF56C6C[|HInputInputURL:' ..
1665+ kook ..
1666+ ' |hKOOK(国服)|h]|r、' .. ' |cFFF56C6C[|HInputInputURL:' .. discord .. ' |hDiscord|h]|r' ,
1667+ ' |cFFF56C6C[|HInputInputURL:' .. curseforge .. ' |hCurseForge|h]|r' ))
1668+ LOG :Info (string.format (L [' Login Information 2' ], " |cff409EFF/ii|r" , " |cff409EFF/inputinput|r" ,
1669+ ' |cffF56C6C|HInputInputOPT:show|h[' , ' ]|h|r' ))
1670+ end )
1671+ else
1672+ U :Delay (5 , function (cb )
1673+ LOG :Info (string.format (L [' Login Information 1' ],
1674+ W .colorName ,
1675+ ' |cFFF56C6C' ..
1676+ ' KOOK(国服)|r、' .. ' |cFFF56C6CDiscord|r' ,
1677+ ' |cFFF56C6CCurseForge|r' ))
1678+ LOG :Info (string.format (L [' Login Information 2' ], " |cff409EFF/ii|r" , " |cff409EFF/inputinput|r" ,
1679+ ' |cffF56C6C' , ' |r' ))
1680+ end )
1681+ end
16541682 end
16551683 end )
16561684
0 commit comments