update announcing adjustments

--remove ChatFrame_OnEvent hook
--register CHAT_MSG_CHANNEL events
--move the CHAT_MSG_CHANNEL hanlder into the OnEvent script
--modify the CHAT_MSG_CHANNEL handler to avoid unnecessary actions
This commit is contained in:
gnwl
2023-11-03 05:16:25 -05:00
parent e75a4bbadd
commit 6e2b18bca5
+18 -31
View File
@@ -3830,26 +3830,31 @@ local remoteversion = tonumber(AtlasLoot_updateavailable) or 0
local loginchannels = { "BATTLEGROUND", "RAID", "GUILD" } local loginchannels = { "BATTLEGROUND", "RAID", "GUILD" }
local groupchannels = { "BATTLEGROUND", "RAID" } local groupchannels = { "BATTLEGROUND", "RAID" }
AtlasLoot_updater_ChatFrame_OnEvent = ChatFrame_OnEvent
AtlasLoot_updater = CreateFrame("Frame") AtlasLoot_updater = CreateFrame("Frame")
AtlasLoot_updater:RegisterEvent("CHAT_MSG_ADDON") AtlasLoot_updater:RegisterEvent("CHAT_MSG_ADDON")
AtlasLoot_updater:RegisterEvent("CHAT_MSG_CHANNEL")
AtlasLoot_updater:RegisterEvent("PLAYER_ENTERING_WORLD") AtlasLoot_updater:RegisterEvent("PLAYER_ENTERING_WORLD")
AtlasLoot_updater:RegisterEvent("PARTY_MEMBERS_CHANGED") AtlasLoot_updater:RegisterEvent("PARTY_MEMBERS_CHANGED")
function ChatFrame_OnEvent(event) AtlasLoot_updater:SetScript("OnEvent", function()
if event == "CHAT_MSG_ADDON" and arg1 == "AtlasLoot" then
local v, remoteversion = AtlasLoot_strsplit(":", arg2)
local remoteversion = tonumber(remoteversion)
if remoteversion >= 40000 then remoteversion = 0 end --Block for people using some version from another version of WoW.
if v == "VERSION" and remoteversion then
if remoteversion > localversion then
AtlasLoot_updateavailable = remoteversion
if not alreadyshown then
DEFAULT_CHAT_FRAME:AddMessage("|cffbe5eff[AtlasLoot]|r New version available! https://github.com/Lexiebean/AtlasLoot/")
alreadyshown = true
end
end
end
end
if event == "CHAT_MSG_CHANNEL" then if event == "CHAT_MSG_CHANNEL" then
local _,_,source = string.find(arg4,"(%d+)%.")
local type = strsub(event, 10) local _,name = GetChannelName(source)
local source = strsub(type,1,1)
if type == "CHANNEL" and arg4 then
_,_,source = string.find(arg4,"(%d+)%.")
end
if source then
_,name = GetChannelName(source)
end
if name == "LFT" then if name == "LFT" then
local msg, v, remoteversion = AtlasLoot_strsplit(":", arg1) local msg, v, remoteversion = AtlasLoot_strsplit(":", arg1)
if msg == "Atlasloot" then if msg == "Atlasloot" then
@@ -3867,24 +3872,6 @@ function ChatFrame_OnEvent(event)
end end
end end
end end
AtlasLoot_updater_ChatFrame_OnEvent(event);
end
AtlasLoot_updater:SetScript("OnEvent", function()
if event == "CHAT_MSG_ADDON" and arg1 == "AtlasLoot" then
local v, remoteversion = AtlasLoot_strsplit(":", arg2)
local remoteversion = tonumber(remoteversion)
if remoteversion >= 40000 then remoteversion = 0 end --Block for people using some version from another version of WoW.
if v == "VERSION" and remoteversion then
if remoteversion > localversion then
AtlasLoot_updateavailable = remoteversion
if not alreadyshown then
DEFAULT_CHAT_FRAME:AddMessage("|cffbe5eff[AtlasLoot]|r New version available! https://github.com/Lexiebean/AtlasLoot/")
alreadyshown = true
end
end
end
end
if event == "PARTY_MEMBERS_CHANGED" then if event == "PARTY_MEMBERS_CHANGED" then
local groupsize = GetNumRaidMembers() > 0 and GetNumRaidMembers() or GetNumPartyMembers() > 0 and GetNumPartyMembers() or 0 local groupsize = GetNumRaidMembers() > 0 and GetNumRaidMembers() or GetNumPartyMembers() > 0 and GetNumPartyMembers() or 0