Fix issue with whoer getting stuck on queries because of return
This commit is contained in:
121
Whoer.lua
121
Whoer.lua
@@ -131,7 +131,10 @@ local lastQuery = nil
|
||||
---@return string?
|
||||
local function Notify(player)
|
||||
if not player then return string.format("Cannot notify for nil player %s", tostring(player)) end
|
||||
if not data.config.who.zoneNotifyFor[player.zone] then return string.format("Not notifying for zone %s", tostring(player.zone)) end
|
||||
if not data.config.who.zoneNotifyFor[player.zone] then
|
||||
return string.format("Not notifying for zone %s",
|
||||
tostring(player.zone))
|
||||
end
|
||||
|
||||
local text = player:NotifyMessage()
|
||||
---@type Message
|
||||
@@ -197,7 +200,10 @@ end
|
||||
---@return string?
|
||||
local function NotifyGone(player)
|
||||
if not player then return string.format("Cannot notify for nil player %s", tostring(player)) end
|
||||
if not data.config.who.zoneNotifyFor[player.zone] then return string.format("Not notifying for zone %s", tostring(player.zone)) end
|
||||
if not data.config.who.zoneNotifyFor[player.zone] then
|
||||
return string.format("Not notifying for zone %s",
|
||||
tostring(player.zone))
|
||||
end
|
||||
|
||||
local text = string.format("%s of class %s and guild %s left %s",
|
||||
player.name,
|
||||
@@ -231,78 +237,83 @@ end
|
||||
local frame = CreateFrame("Frame")
|
||||
frame:RegisterEvent("WHO_LIST_UPDATE")
|
||||
frame:SetScript("OnEvent", function(self, event, ...)
|
||||
---@type WHOQuery?
|
||||
local query = lastQuery
|
||||
if not query then
|
||||
print("No query wtf?")
|
||||
return
|
||||
end
|
||||
|
||||
for i = 1, GetNumWhoResults() do
|
||||
local name, guild, level, race, class, zone = GetWhoInfo(i)
|
||||
if data.who.ignored[name] then return end
|
||||
|
||||
---@type WHOQuery?
|
||||
local query = lastQuery
|
||||
if not query then
|
||||
print("No query wtf?")
|
||||
return
|
||||
end
|
||||
local continue = false
|
||||
|
||||
---@type WHOFilter[]
|
||||
local filters = query.filters
|
||||
for _, filter in pairs(filters) do
|
||||
if not filter(name, guild, level, race, class, zone) then
|
||||
return
|
||||
-- Mega scuffed, yes...
|
||||
-- But wow does not have gotos
|
||||
continue = true
|
||||
end
|
||||
end
|
||||
|
||||
local timestamp = date("%Y-%m-%dT%H:%M:%S")
|
||||
local player = players[name]
|
||||
if not player then
|
||||
player = Player.new(name, guild, race, class, zone)
|
||||
if not continue then
|
||||
local timestamp = date("%Y-%m-%dT%H:%M:%S")
|
||||
local player = players[name]
|
||||
if not player then
|
||||
player = Player.new(name, guild, race, class, zone)
|
||||
if not Heimdall_Data.who then Heimdall_Data.who = {} end
|
||||
if not Heimdall_Data.who.data then Heimdall_Data.who.data = {} end
|
||||
local existing = Heimdall_Data.who.data[name]
|
||||
|
||||
if existing then
|
||||
player.lastSeen = existing.lastSeen or "never"
|
||||
player.firstSeen = existing.firstSeen or "never"
|
||||
player.seenCount = existing.seenCount or 0
|
||||
end
|
||||
if player.firstSeen == "never" then
|
||||
player.firstSeen = timestamp
|
||||
end
|
||||
|
||||
local stinky = data.stinkies[name]
|
||||
if stinky then
|
||||
PlaySoundFile("Interface\\Sounds\\Domination.ogg", "Master")
|
||||
else
|
||||
PlaySoundFile("Interface\\Sounds\\Cloak.ogg", "Master")
|
||||
end
|
||||
|
||||
local err = Notify(player)
|
||||
if err then
|
||||
print(string.format("Error notifying for %s: %s", tostring(name), tostring(err)))
|
||||
end
|
||||
|
||||
player.lastSeen = timestamp
|
||||
player.seenCount = player.seenCount + 1
|
||||
players[name] = player
|
||||
end
|
||||
|
||||
player.lastSeenInternal = GetTime()
|
||||
if player.zone ~= zone then
|
||||
local err = NotifyZoneChanged(player, zone)
|
||||
if err then
|
||||
print(string.format("Error notifying for %s: %s", tostring(name), tostring(err)))
|
||||
end
|
||||
end
|
||||
player.zone = zone
|
||||
player.lastSeen = timestamp
|
||||
players[name] = player
|
||||
if not Heimdall_Data.who then Heimdall_Data.who = {} end
|
||||
if not Heimdall_Data.who.data then Heimdall_Data.who.data = {} end
|
||||
local existing = Heimdall_Data.who.data[name]
|
||||
|
||||
if existing then
|
||||
player.lastSeen = existing.lastSeen or "never"
|
||||
player.firstSeen = existing.firstSeen or "never"
|
||||
player.seenCount = existing.seenCount or 0
|
||||
end
|
||||
if player.firstSeen == "never" then
|
||||
player.firstSeen = timestamp
|
||||
end
|
||||
|
||||
local stinky = data.stinkies[name]
|
||||
if stinky then
|
||||
PlaySoundFile("Interface\\Sounds\\Domination.ogg", "Master")
|
||||
else
|
||||
PlaySoundFile("Interface\\Sounds\\Cloak.ogg", "Master")
|
||||
end
|
||||
|
||||
local err = Notify(player)
|
||||
if err then
|
||||
print(string.format("Error notifying for %s: %s", tostring(name), tostring(err)))
|
||||
end
|
||||
|
||||
player.lastSeen = timestamp
|
||||
player.seenCount = player.seenCount + 1
|
||||
players[name] = player
|
||||
Heimdall_Data.who.data[name] = player
|
||||
end
|
||||
|
||||
player.lastSeenInternal = GetTime()
|
||||
if player.zone ~= zone then
|
||||
local err = NotifyZoneChanged(player, zone)
|
||||
if err then
|
||||
print(string.format("Error notifying for %s: %s", tostring(name), tostring(err)))
|
||||
end
|
||||
end
|
||||
player.zone = zone
|
||||
player.lastSeen = timestamp
|
||||
players[name] = player
|
||||
if not Heimdall_Data.who then Heimdall_Data.who = {} end
|
||||
if not Heimdall_Data.who.data then Heimdall_Data.who.data = {} end
|
||||
Heimdall_Data.who.data[name] = player
|
||||
end
|
||||
print("Done?")
|
||||
-- Turns out WA cannot do this (
|
||||
-- aura_env.UpdateMacro()
|
||||
_G["FriendsFrameCloseButton"]:Click()
|
||||
queryPending = false
|
||||
print(queryPending)
|
||||
end)
|
||||
|
||||
if not data.who.updateTicker then
|
||||
|
Reference in New Issue
Block a user