Code format
Some checks failed
Release Workflow / release (push) Failing after 23s

This commit is contained in:
2025-05-04 15:09:34 +02:00
parent 304fbcbaae
commit 1da1e7bf9f
30 changed files with 4620 additions and 4241 deletions

View File

@@ -32,7 +32,7 @@ function shared.Whoer.Init()
---@return Player
new = function(name, guild, race, class, zone)
local self = setmetatable({}, {
__index = Player
__index = Player,
})
self.name = name
self.guild = guild
@@ -47,13 +47,15 @@ function shared.Whoer.Init()
end,
---@return string
ToString = function(self)
local out = string.format("%s %s %s\nFirst: %s Last: %s Seen: %3d",
local out = string.format(
"%s %s %s\nFirst: %s Last: %s Seen: %3d",
shared.padString(self.name, 16, true),
shared.padString(self.guild, 26, false),
shared.padString(self.zone, 26, false),
shared.padString(self.firstSeen, 10, true),
shared.padString(self.lastSeen, 10, true),
self.seenCount)
self.seenCount
)
return string.format("|cFF%s%s|r", shared.classColors[self.class], out)
end,
}
@@ -67,12 +69,12 @@ function shared.Whoer.Init()
---@return WHOQuery
new = function(query, filters)
local self = setmetatable({}, {
__index = WHOQuery
__index = WHOQuery,
})
self.query = query
self.filters = filters
return self
end
end,
}
---@class WHOFilter
@@ -81,12 +83,10 @@ function shared.Whoer.Init()
---@type WHOFilter
local NotSiegeOfOrgrimmarFilter = {
Run = function(name, guild, level, race, class, zone)
if not zone then
return false
end
if not zone then return false end
return zone ~= "Siege of Orgrimmar"
end,
key = "notsoo"
key = "notsoo",
}
---@type WHOFilter
local AllianceFilter = {
@@ -95,7 +95,7 @@ function shared.Whoer.Init()
if not shared.raceMap[race] then return false end
return shared.raceMap[race] == "Alliance"
end,
key = "ally"
key = "ally",
}
---@class WhoQueryService
@@ -110,15 +110,13 @@ function shared.Whoer.Init()
queries = {},
filters = {
NotSiegeOfOrgrimmarFilter,
AllianceFilter
AllianceFilter,
},
---@param key string
---@return WHOFilter?
getFilter = function(key)
for _, filter in pairs(shared.WhoQueryService.filters) do
if filter.key == key then
return filter
end
if filter.key == key then return filter end
end
return nil
end,
@@ -176,7 +174,7 @@ function shared.Whoer.Init()
table.insert(ret, shared.WhoQueryService.WhoQueryFromString(query))
end
return ret
end
end,
}
shared.WhoQueryService.queries = shared.WhoQueryService.WhoQueriesFromString(Heimdall_Data.config.who.queries)
@@ -187,15 +185,13 @@ function shared.Whoer.Init()
print(string.format("[%s] ShouldNotifyForZone %s", ModuleName, inputZone))
end
for zone, _ in pairs(Heimdall_Data.config.who.zoneNotifyFor) do
if Heimdall_Data.config.who.debug then
print(string.format("[%s] Checking zone %s", ModuleName, zone))
end
if zone == "*" then
return true
end
if Heimdall_Data.config.who.debug then print(string.format("[%s] Checking zone %s", ModuleName, zone)) end
if zone == "*" then return true end
if string.find(inputZone, zone) then
if not Heimdall_Data.config.who.debug then
print(string.format("[%s] ShouldNotifyForZone %s is true thanks to %s", ModuleName, inputZone, zone))
print(
string.format("[%s] ShouldNotifyForZone %s is true thanks to %s", ModuleName, inputZone, zone)
)
end
return true
end
@@ -235,10 +231,25 @@ function shared.Whoer.Init()
local function Notify(player)
if Heimdall_Data.config.who.debug then
print(string.format("[%s] Processing notification for player: %s", ModuleName, player.name))
print(string.format("[%s] Player details - Guild: %s, Race: %s, Class: %s, Zone: %s", ModuleName,
player.guild, player.race, player.class, player.zone))
print(string.format("[%s] Player history - First seen: %s, Last seen: %s, Seen count: %d", ModuleName,
player.firstSeen, player.lastSeen, player.seenCount))
print(
string.format(
"[%s] Player details - Guild: %s, Race: %s, Class: %s, Zone: %s",
ModuleName,
player.guild,
player.race,
player.class,
player.zone
)
)
print(
string.format(
"[%s] Player history - First seen: %s, Last seen: %s, Seen count: %d",
ModuleName,
player.firstSeen,
player.lastSeen,
player.seenCount
)
)
end
if not Heimdall_Data.config.who.enabled then
@@ -258,26 +269,30 @@ function shared.Whoer.Init()
if not shared.Whoer.ShouldNotifyForZone(player.zone) then
--if not Heimdall_Data.config.who.zoneNotifyFor[player.zone] then
if Heimdall_Data.config.who.debug then
print(string.format("[%s] Skipping notification - Zone '%s' not in notify list", ModuleName, player.zone))
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
for _, channel in pairs(Heimdall_Data.config.who.channels) do
local locale = shared.GetLocaleForChannel(channel)
local text = string.format(shared._L("whoerNew", locale),
local text = string.format(
shared._L("whoerNew", locale),
player.name,
player.stinky and "(!!!!)" or "",
shared._L(player.class, locale),
--shared._L(player.race, locale),
shared._L(shared.raceMap[player.race] or "unknown", locale),
player.guild,
shared._L(player.zone, locale))
shared._L(player.zone, locale)
)
---@type Message
local msg = {
channel = "C",
data = channel,
message = text
message = text,
}
if Heimdall_Data.config.who.debug then
print(string.format("[%s] Queuing channel notification", ModuleName))
@@ -321,20 +336,22 @@ function shared.Whoer.Init()
end
for _, channel in pairs(Heimdall_Data.config.who.channels) do
local locale = shared.GetLocaleForChannel(channel)
local text = string.format(shared._L("whoerMoved", locale),
local text = string.format(
shared._L("whoerMoved", locale),
player.name,
player.stinky and "(!!!!)" or "",
shared._L(player.class, locale),
--shared._L(player.race, locale),
shared._L(shared.raceMap[player.race] or "unknown", locale),
player.guild,
shared._L(zone, locale))
shared._L(zone, locale)
)
---@type Message
local msg = {
channel = "C",
data = channel,
message = text
message = text,
}
if Heimdall_Data.config.who.debug then
print(string.format("[%s] Queuing channel notification", ModuleName))
@@ -370,20 +387,22 @@ function shared.Whoer.Init()
for _, channel in pairs(Heimdall_Data.config.who.channels) do
local locale = shared.GetLocaleForChannel(channel)
local text = string.format(shared._L("whoerGone", locale),
local text = string.format(
shared._L("whoerGone", locale),
player.name,
player.stinky and "(!!!!)" or "",
shared._L(player.class, locale),
--shared._L(player.race, locale),
shared._L(shared.raceMap[player.race] or "unknown", locale),
player.guild,
shared._L(player.zone, locale))
shared._L(player.zone, locale)
)
---@type Message
local msg = {
channel = "C",
data = channel,
message = text
message = text,
}
if Heimdall_Data.config.who.debug then
print(string.format("[%s] Queuing channel notification", ModuleName))
@@ -441,7 +460,9 @@ function shared.Whoer.Init()
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))
print(
string.format("[%s] Processing result %d/%d: %s/%s/%s", ModuleName, i, results, name, class, zone)
)
end
local continue = false
@@ -449,11 +470,15 @@ function shared.Whoer.Init()
local filters = query.filters
for _, filter in pairs(filters) do
if Heimdall_Data.config.who.debug then
print(string.format("[%s] Running filter %s on %s/%s/%s", ModuleName, filter.key, name, class, zone))
print(
string.format("[%s] Running filter %s on %s/%s/%s", ModuleName, filter.key, name, class, zone)
)
end
if not filter.Run(name, guild, level, race, class, zone) then
if Heimdall_Data.config.who.debug then
print(string.format("[%s] Player %s filtered out by WHO filter %s", ModuleName, name, filter.key))
print(
string.format("[%s] Player %s filtered out by WHO filter %s", ModuleName, name, filter.key)
)
end
continue = true
break
@@ -488,8 +513,15 @@ function shared.Whoer.Init()
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))
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"
@@ -516,7 +548,9 @@ function shared.Whoer.Init()
local err = Notify(player)
if err then
print(string.format("[%s] Error notifying for %s: %s", ModuleName, tostring(name), tostring(err)))
print(
string.format("[%s] Error notifying for %s: %s", ModuleName, tostring(name), tostring(err))
)
end
player.lastSeen = timestamp
@@ -527,13 +561,18 @@ function shared.Whoer.Init()
player.lastSeenInternal = GetTime()
if player.zone ~= zone then
if Heimdall_Data.config.who.debug then
print(string.format("[%s] Player %s zone changed from %s to %s", ModuleName, name, player.zone,
zone))
print(
string.format(
"[%s] Player %s zone changed from %s to %s",
ModuleName,
name,
player.zone,
zone
)
)
end
local err = NotifyZoneChanged(player, zone)
if err then
print(string.format("Error notifying for %s: %s", tostring(name), tostring(err)))
end
if err then print(string.format("Error notifying for %s: %s", tostring(name), tostring(err))) end
end
player.zone = zone
player.lastSeen = timestamp
@@ -578,17 +617,22 @@ function shared.Whoer.Init()
end
if Heimdall_Data.config.who.debug then
print(string.format("[%s] Running WHO query %d/%d: %s", ModuleName, whoQueryIdx,
#shared.WhoQueryService.queries, query.query))
print(
string.format(
"[%s] Running WHO query %d/%d: %s",
ModuleName,
whoQueryIdx,
#shared.WhoQueryService.queries,
query.query
)
)
print(string.format("[%s] Query has %d filters", ModuleName, #query.filters))
for i, filter in ipairs(query.filters) do
print(string.format("[%s] Filter %d: %s", ModuleName, i, filter.key))
end
end
whoQueryIdx = whoQueryIdx + 1
if whoQueryIdx > #shared.WhoQueryService.queries then
whoQueryIdx = 1
end
if whoQueryIdx > #shared.WhoQueryService.queries then whoQueryIdx = 1 end
lastQuery = query
---@diagnostic disable-next-line: param-type-mismatch
SetWhoToUI(1)