Add more error checks and logs to whoer

This commit is contained in:
2024-12-12 15:10:19 +01:00
parent 801559a25d
commit f51ce68b2e

View File

@@ -2,6 +2,11 @@ local _, data = ...
---@cast data HeimdallData
if not data.config.who.enabled then return end
if not Heimdall_Data.who then Heimdall_Data.who = {} end
if not Heimdall_Data.who.data then Heimdall_Data.who.data = {} end
print(Heimdall_Data)
print(Heimdall_Data.who)
print(Heimdall_Data.who.data)
---@type table<string, Player>
local players = {}
@@ -126,6 +131,8 @@ 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
local text = player:NotifyMessage()
---@type Message
local msg = {
@@ -189,6 +196,9 @@ end
---@param player Player
---@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
local text = string.format("%s of class %s and guild %s left %s",
player.name,
player.class,
@@ -244,6 +254,8 @@ frame:SetScript("OnEvent", function(self, event, ...)
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
@@ -282,10 +294,15 @@ frame:SetScript("OnEvent", function(self, event, ...)
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
end)
if not data.who.updateTicker then
@@ -315,7 +332,8 @@ if not data.who.whoTicker then
whoQueryIdx = 1
end
lastQuery = query
print("Running who query: " .. tostring(query.query))
print(string.format("Running who query: %s", tostring(query.query)))
SetWhoToUI(1)
SendWho(query.query)
end)
end