From db28aa7a14c37cb4708bfb0b056af43471ac0d95 Mon Sep 17 00:00:00 2001 From: Daniel Yates Date: Tue, 7 May 2024 11:46:55 +0100 Subject: [PATCH 1/2] Remove filtering of 'Player is offline' messages These no longer fire for addon whisper messages in either 4.4.0 or 10.2.7, and should eventually be the same in Classic Era. --- .luacheckrc | 4 --- Internal.lua | 80 +--------------------------------------------------- 2 files changed, 1 insertion(+), 83 deletions(-) diff --git a/.luacheckrc b/.luacheckrc index d0aa59c..cac6e98 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -48,15 +48,11 @@ read_globals = { "C_BattleNet.GetGameAccountInfoByID", "C_ChatInfo.IsAddonMessagePrefixRegistered", "C_ChatInfo.RegisterAddonMessagePrefix", - "ChatFrame_AddMessageEventFilter", "CreateFrame", - "ERR_CHAT_PLAYER_NOT_FOUND_S", "FULL_PLAYER_NAME", "GetAutoCompleteRealms", - "GetNetStats", "GetRealmName", "GetTime", - "hooksecurefunc", "IsLoggedIn", "LE_PARTY_CATEGORY_HOME", "LE_REALM_RELATION_COALESCED", diff --git a/Internal.lua b/Internal.lua index 0b1ad73..37fff9d 100644 --- a/Internal.lua +++ b/Internal.lua @@ -14,7 +14,7 @@ CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ]] -local VERSION = 26 +local VERSION = 27 if IsLoggedIn() then error(("Chomp Message Library (embedded: %s) cannot be loaded after login."):format((...))) @@ -250,81 +250,6 @@ function Internal:TriggerEvent(event, ...) return self.callbacks:Fire(event, ...) end ---[[ - FUNCTION HOOKS -]] - --- Hooks don't trigger if the hooked function errors, so there's no need to --- check parameters, if those parameters cause errors (which most don't now). - -local FILTER_PATTERN = ERR_CHAT_PLAYER_NOT_FOUND_S:format("(.+)") -local lastFilteredLineID = nil - -if not Internal.MessageFilterKeyCache then - Internal.MessageFilterKeyCache = {} -end - -local function GenerateMessageFilterKey(target) - -- Due to systemic issues across ourselves, LibMSP, TRP, etc. this - -- filter has been hacked to only use the character name of the player - -- and to discard the realm. - - local filterKey = string.split("-", target, 2) - - if string.utf8lower then - filterKey = string.utf8lower(filterKey) - else - filterKey = string.lower(filterKey) - end - - return filterKey -end - -setmetatable(Internal.MessageFilterKeyCache, { - __index = function(self, target) - local filterKey = GenerateMessageFilterKey(target) - self[target] = filterKey - return filterKey - end, -}) - -local function MessageEventFilter_SYSTEM (self, event, text, ...) - local name = text:match(FILTER_PATTERN) - if not name then - return false - end - - local filterKey = Internal.MessageFilterKeyCache[name] - - if not Internal.Filter[filterKey] or Internal.Filter[filterKey] < GetTime() then - Internal.Filter[filterKey] = nil - return false - end - - local lineID = select(10, ...) - - if lineID ~= lastFilteredLineID then - Internal:TriggerEvent("OnError", name) - lastFilteredLineID = lineID - end - - return true -end - -local function HookSendAddonMessage(prefix, text, kind, target) - if kind == "WHISPER" and target then - local filterKey = Internal.MessageFilterKeyCache[target] - Internal.Filter[filterKey] = GetTime() + (select(3, GetNetStats()) * 0.001) + 5.000 - end -end - -local function HookSendAddonMessageLogged(prefix, text, kind, target) - if kind == "WHISPER" and target then - local filterKey = Internal.MessageFilterKeyCache[target] - Internal.Filter[filterKey] = GetTime() + (select(3, GetNetStats()) * 0.001) + 5.000 - end -end - --[[ BATTLE.NET WRAPPER API ]] @@ -469,9 +394,6 @@ Internal:SetScript("OnEvent", function(self, event, ...) Internal:UpdateBattleNetAccountData() elseif event == "PLAYER_LOGIN" then _G.__chomp_internal = nil - hooksecurefunc(C_ChatInfo, "SendAddonMessage", HookSendAddonMessage) - hooksecurefunc(C_ChatInfo, "SendAddonMessageLogged", HookSendAddonMessageLogged) - ChatFrame_AddMessageEventFilter("CHAT_MSG_SYSTEM", MessageEventFilter_SYSTEM) self.SameRealm = {} self.SameRealm[(GetRealmName():gsub("[%s%-]", ""))] = true for i, realm in ipairs(GetAutoCompleteRealms()) do From ca0ba6b09f162e70e61a415c3e8fa7315758b8d4 Mon Sep 17 00:00:00 2001 From: Daniel Yates Date: Tue, 7 May 2024 14:03:19 +0100 Subject: [PATCH 2/2] Up we go --- Internal.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Internal.lua b/Internal.lua index 37fff9d..d6162fc 100644 --- a/Internal.lua +++ b/Internal.lua @@ -14,7 +14,7 @@ CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ]] -local VERSION = 27 +local VERSION = 28 if IsLoggedIn() then error(("Chomp Message Library (embedded: %s) cannot be loaded after login."):format((...)))