Fix up the log messages a lil
Unbutcher inviter
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
local addonname, shared = ...
|
||||
---@cast shared HeimdallShared
|
||||
---@cast addonname string
|
||||
local ModuleName = "Whoer"
|
||||
|
||||
---@diagnostic disable-next-line: missing-fields
|
||||
shared.Whoer = {}
|
||||
@@ -131,14 +132,36 @@ function shared.Whoer.Init()
|
||||
---@param player Player
|
||||
---@return string?
|
||||
local function Notify(player)
|
||||
if not Heimdall_Data.config.who.enabled then return end
|
||||
if not player then return string.format("Cannot notify for nil player %s", tostring(player)) end
|
||||
if Heimdall_Data.config.who.debug then
|
||||
print(string.format("[%s] Processing notification for player: %s", ModuleName, player.name))
|
||||
end
|
||||
|
||||
if not Heimdall_Data.config.who.enabled then
|
||||
if Heimdall_Data.config.who.debug then
|
||||
print(string.format("[%s] Module disabled, skipping notification", ModuleName))
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
if not player then
|
||||
if Heimdall_Data.config.who.debug then
|
||||
print(string.format("[%s] Error: Cannot notify for nil player", ModuleName))
|
||||
end
|
||||
return string.format("Cannot notify for nil player %s", tostring(player))
|
||||
end
|
||||
|
||||
if not Heimdall_Data.config.who.zoneNotifyFor[player.zone] then
|
||||
return string.format("Not notifying for zone %s",
|
||||
tostring(player.zone))
|
||||
if Heimdall_Data.config.who.debug then
|
||||
print(string.format("[%s] Skipping notification - Zone '%s' not in notify list", ModuleName, player.zone))
|
||||
end
|
||||
return string.format("Not notifying for zone %s", tostring(player.zone))
|
||||
end
|
||||
|
||||
local text = player:NotifyMessage()
|
||||
if Heimdall_Data.config.who.debug then
|
||||
print(string.format("[%s] Queuing channel notification: '%s'", ModuleName, text))
|
||||
end
|
||||
|
||||
---@type Message
|
||||
local msg = {
|
||||
channel = "CHANNEL",
|
||||
@@ -148,6 +171,9 @@ function shared.Whoer.Init()
|
||||
table.insert(shared.messenger.queue, msg)
|
||||
|
||||
if Heimdall_Data.config.who.doWhisper then
|
||||
if Heimdall_Data.config.who.debug then
|
||||
print(string.format("[%s] Processing whisper notifications for %d recipients", ModuleName, #Heimdall_Data.config.whisperNotify))
|
||||
end
|
||||
for _, name in pairs(Heimdall_Data.config.whisperNotify) do
|
||||
---@type Message
|
||||
local msg = {
|
||||
@@ -155,6 +181,9 @@ function shared.Whoer.Init()
|
||||
data = name,
|
||||
message = text
|
||||
}
|
||||
if Heimdall_Data.config.who.debug then
|
||||
print(string.format("[%s] Queuing whisper to %s", ModuleName, name))
|
||||
end
|
||||
table.insert(shared.messenger.queue, msg)
|
||||
end
|
||||
end
|
||||
@@ -243,60 +272,98 @@ function shared.Whoer.Init()
|
||||
local frame = CreateFrame("Frame")
|
||||
frame:RegisterEvent("WHO_LIST_UPDATE")
|
||||
frame:SetScript("OnEvent", function(self, event, ...)
|
||||
if not Heimdall_Data.config.who.enabled then return end
|
||||
if Heimdall_Data.config.who.debug then
|
||||
print(string.format("[%s] WHO list update received", ModuleName))
|
||||
end
|
||||
|
||||
if not Heimdall_Data.config.who.enabled then
|
||||
if Heimdall_Data.config.who.debug then
|
||||
print(string.format("[%s] Module disabled, ignoring WHO update", ModuleName))
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
---@type WHOQuery?
|
||||
local query = lastQuery
|
||||
if not query then
|
||||
print("No query wtf?")
|
||||
if Heimdall_Data.config.who.debug then
|
||||
print(string.format("[%s] Error: No active WHO query found", ModuleName))
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
for i = 1, GetNumWhoResults() do
|
||||
local name, guild, level, race, class, zone = GetWhoInfo(i)
|
||||
local continue = false
|
||||
--print(name, guild, level, race, class, zone)
|
||||
local results = GetNumWhoResults()
|
||||
if Heimdall_Data.config.who.debug then
|
||||
print(string.format("[%s] Processing %d WHO results for query: %s", ModuleName, results, query.query))
|
||||
end
|
||||
|
||||
for i = 1, results do
|
||||
local name, guild, level, race, class, zone = GetWhoInfo(i)
|
||||
if Heimdall_Data.config.who.debug then
|
||||
print(string.format("[%s] Processing result %d/%d: %s/%s/%s", ModuleName, i, results, name, class, zone))
|
||||
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
|
||||
-- Mega scuffed, yes...
|
||||
-- But wow does not have gotos
|
||||
if Heimdall_Data.config.who.debug then
|
||||
print(string.format("[%s] Player %s filtered out by WHO filter", ModuleName, name))
|
||||
end
|
||||
continue = true
|
||||
break
|
||||
end
|
||||
end
|
||||
if Heimdall_Data.config.who.ignored[name] then continue = true end
|
||||
--print(continue)
|
||||
|
||||
if Heimdall_Data.config.who.ignored[name] then
|
||||
if Heimdall_Data.config.who.debug then
|
||||
print(string.format("[%s] Ignoring blacklisted player: %s", ModuleName, name))
|
||||
end
|
||||
continue = true
|
||||
end
|
||||
|
||||
if not continue then
|
||||
local timestamp = date("%Y-%m-%dT%H:%M:%S")
|
||||
local player = HeimdallStinkies[name]
|
||||
if not player then
|
||||
if Heimdall_Data.config.who.debug then
|
||||
print(string.format("[%s] New player detected: %s (%s) in %s", ModuleName, name, class, zone))
|
||||
end
|
||||
|
||||
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
|
||||
if Heimdall_Data.config.who.debug then
|
||||
print(string.format("[%s] Found existing data for %s - Last seen: %s, Count: %d",
|
||||
ModuleName, name, existing.lastSeen or "never", existing.seenCount or 0))
|
||||
end
|
||||
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
|
||||
if Heimdall_Data.config.who.debug then
|
||||
print(string.format("[%s] First time seeing player: %s at %s", ModuleName, name, timestamp))
|
||||
end
|
||||
end
|
||||
|
||||
local stinky = Heimdall_Data.config.stinkies[name]
|
||||
if stinky then
|
||||
if Heimdall_Data.config.who.debug then
|
||||
print(string.format("[%s] Player %s marked as stinky!", ModuleName, name))
|
||||
end
|
||||
player.stinky = true
|
||||
--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)))
|
||||
print(string.format("[%s] Error notifying for %s: %s", ModuleName, tostring(name), tostring(err)))
|
||||
end
|
||||
|
||||
player.lastSeen = timestamp
|
||||
@@ -365,3 +432,4 @@ function shared.Whoer.Init()
|
||||
|
||||
print("Heimdall - Whoer loaded")
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user