2323-- LICENSE: ChatThrottleLib is released into the Public Domain
2424--
2525
26- local CTL_VERSION = 29
26+ local CTL_VERSION = 31
2727
2828local _G = _G
2929
@@ -232,9 +232,15 @@ function ChatThrottleLib:Init()
232232 -- Use secure hooks as of v16. Old regular hook support yanked out in v21.
233233 self .securelyHooked = true
234234 -- SendChatMessage
235- hooksecurefunc (" SendChatMessage" , function (...)
236- return ChatThrottleLib .Hook_SendChatMessage (... )
237- end )
235+ if _G .C_ChatInfo and _G .C_ChatInfo .SendChatMessage then
236+ hooksecurefunc (_G .C_ChatInfo , " SendChatMessage" , function (...)
237+ return ChatThrottleLib .Hook_SendChatMessage (... )
238+ end )
239+ else
240+ hooksecurefunc (" SendChatMessage" , function (...)
241+ return ChatThrottleLib .Hook_SendChatMessage (... )
242+ end )
243+ end
238244 -- SendAddonMessage
239245 hooksecurefunc (_G .C_ChatInfo , " SendAddonMessage" , function (...)
240246 return ChatThrottleLib .Hook_SendAddonMessage (... )
@@ -252,9 +258,15 @@ function ChatThrottleLib:Init()
252258 -- v29: Hook BNSendGameData for traffic logging
253259 if not self .securelyHookedBNGameData then
254260 self .securelyHookedBNGameData = true
255- hooksecurefunc (" BNSendGameData" , function (...)
256- return ChatThrottleLib .Hook_BNSendGameData (... )
257- end )
261+ if _G .C_BattleNet and _G .C_BattleNet .SendGameData then
262+ hooksecurefunc (_G .C_BattleNet , " SendGameData" , function (...)
263+ return ChatThrottleLib .Hook_BNSendGameData (... )
264+ end )
265+ else
266+ hooksecurefunc (" BNSendGameData" , function (...)
267+ return ChatThrottleLib .Hook_BNSendGameData (... )
268+ end )
269+ end
258270 end
259271
260272 self .nBypass = 0
@@ -541,7 +553,7 @@ function ChatThrottleLib:SendChatMessage(prio, prefix, text, chattype, languag
541553
542554 -- Check if there's room in the global available bandwidth gauge to send directly
543555 if not self .bQueueing and nSize < self :UpdateAvail () then
544- local sendResult = PerformSend (_G .SendChatMessage , text , chattype , language , destination )
556+ local sendResult = PerformSend (_G .C_ChatInfo . SendChatMessage or _G . SendChatMessage , text , chattype , language , destination )
545557
546558 if not IsThrottledSendResult (sendResult ) then
547559 local didSend = (sendResult == SendAddonMessageResult .Success )
@@ -561,7 +573,7 @@ function ChatThrottleLib:SendChatMessage(prio, prefix, text, chattype, languag
561573
562574 -- Message needs to be queued
563575 local msg = NewMsg ()
564- msg .f = _G .SendChatMessage
576+ msg .f = _G .C_ChatInfo . SendChatMessage or _G . SendChatMessage
565577 msg [1 ] = text
566578 msg [2 ] = chattype or " SAY"
567579 msg [3 ] = language
@@ -642,7 +654,8 @@ function ChatThrottleLib:SendAddonMessageLogged(prio, prefix, text, chattype, ta
642654end
643655
644656local function BNSendGameDataReordered (prefix , text , _ , gameAccountID )
645- return _G .BNSendGameData (gameAccountID , prefix , text )
657+ local bnSendFunc = _G .C_BattleNet and _G .C_BattleNet .SendGameData or _G .BNSendGameData
658+ return bnSendFunc (gameAccountID , prefix , text )
646659end
647660
648661function ChatThrottleLib :BNSendGameData (prio , prefix , text , chattype , gameAccountID , queueName , callbackFn , callbackArg )
0 commit comments