Refactor CombatAlerter, Commander, Inviter, Macroer, Sniffer modules for improved structure and clarity
This commit is contained in:
@@ -7,9 +7,9 @@ local ModuleName = "CombatAlerter"
|
|||||||
---@field debug boolean
|
---@field debug boolean
|
||||||
---@field channels string[]
|
---@field channels string[]
|
||||||
|
|
||||||
---@diagnostic disable-next-line: missing-fields
|
---@class CombatAlerter
|
||||||
shared.CombatAlerter = {}
|
shared.CombatAlerter = {
|
||||||
function shared.CombatAlerter.Init()
|
Init = function()
|
||||||
local alerted = {}
|
local alerted = {}
|
||||||
local combatAlerterFrame = CreateFrame("Frame")
|
local combatAlerterFrame = CreateFrame("Frame")
|
||||||
combatAlerterFrame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
|
combatAlerterFrame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
|
||||||
@@ -137,4 +137,5 @@ function shared.CombatAlerter.Init()
|
|||||||
|
|
||||||
if Heimdall_Data.config.combatAlerter.debug then print(string.format("[%s] Module initialized", ModuleName)) end
|
if Heimdall_Data.config.combatAlerter.debug then print(string.format("[%s] Module initialized", ModuleName)) end
|
||||||
print("[Heimdall] CombatAlerter loaded")
|
print("[Heimdall] CombatAlerter loaded")
|
||||||
end
|
end,
|
||||||
|
}
|
||||||
|
|||||||
@@ -39,9 +39,9 @@ local helpMessages = {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
---@diagnostic disable-next-line: missing-fields
|
---@class Commander
|
||||||
shared.Commander = {}
|
shared.Commander = {
|
||||||
function shared.Commander.Init()
|
Init = function()
|
||||||
---@param text string
|
---@param text string
|
||||||
---@param size number
|
---@param size number
|
||||||
---@return string[]
|
---@return string[]
|
||||||
@@ -127,7 +127,9 @@ function shared.Commander.Init()
|
|||||||
local function CountClass(arr)
|
local function CountClass(arr)
|
||||||
local ret = {}
|
local ret = {}
|
||||||
for _, player in pairs(arr) do
|
for _, player in pairs(arr) do
|
||||||
if shared.Whoer.ShouldNotifyForZone(player.zone) then ret[player.class] = (ret[player.class] or 0) + 1 end
|
if shared.Whoer.ShouldNotifyForZone(player.zone) then
|
||||||
|
ret[player.class] = (ret[player.class] or 0) + 1
|
||||||
|
end
|
||||||
end
|
end
|
||||||
local text = {}
|
local text = {}
|
||||||
for class, count in pairs(ret) do
|
for class, count in pairs(ret) do
|
||||||
@@ -343,12 +345,19 @@ function shared.Commander.Init()
|
|||||||
for _, command in ipairs(commands) do
|
for _, command in ipairs(commands) do
|
||||||
local enabled = Heimdall_Data.config.commander.commands[command.keywordRe] == true or false
|
local enabled = Heimdall_Data.config.commander.commands[command.keywordRe] == true or false
|
||||||
if Heimdall_Data.config.commander.debug then
|
if Heimdall_Data.config.commander.debug then
|
||||||
print(string.format("[%s] Command match: %s = %s", ModuleName, command.keywordRe, tostring(enabled)))
|
print(
|
||||||
|
string.format("[%s] Command match: %s = %s", ModuleName, command.keywordRe, tostring(enabled))
|
||||||
|
)
|
||||||
end
|
end
|
||||||
if
|
if
|
||||||
enabled
|
enabled
|
||||||
and (
|
and (
|
||||||
not command.commanderOnly
|
not command.commanderOnly
|
||||||
|
-- if Heimdall_Data.config.commander.debug then print(string.format("[%s] Ignoring command, sender %s not commander %s", ModuleName, sender, Heimdall_Data.config.commander.commander)) end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
or (command.commanderOnly and sender == Heimdall_Data.config.commander.commander)
|
or (command.commanderOnly and sender == Heimdall_Data.config.commander.commander)
|
||||||
)
|
)
|
||||||
then
|
then
|
||||||
@@ -357,7 +366,9 @@ function shared.Commander.Init()
|
|||||||
local messages = command.callback({ strsplit(",", msg) })
|
local messages = command.callback({ strsplit(",", msg) })
|
||||||
if Heimdall_Data.config.commander.debug then
|
if Heimdall_Data.config.commander.debug then
|
||||||
---@diagnostic disable-next-line: param-type-mismatch
|
---@diagnostic disable-next-line: param-type-mismatch
|
||||||
print(string.format("[%s] Messages to send: %s", ModuleName, strjoin(", ", unpack(messages))))
|
print(
|
||||||
|
string.format("[%s] Messages to send: %s", ModuleName, strjoin(", ", unpack(messages)))
|
||||||
|
)
|
||||||
end
|
end
|
||||||
for _, message in ipairs(messages) do
|
for _, message in ipairs(messages) do
|
||||||
---@type Message
|
---@type Message
|
||||||
@@ -379,4 +390,5 @@ function shared.Commander.Init()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
print("[Heimdall] Commander module loaded")
|
print("[Heimdall] Commander module loaded")
|
||||||
end
|
end,
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,10 +1,24 @@
|
|||||||
local _, shared = ...
|
local _, shared = ...
|
||||||
---@cast shared HeimdallShared
|
---@cast shared HeimdallShared
|
||||||
|
|
||||||
|
---@class HeimdallInviterConfig
|
||||||
|
---@field enabled boolean
|
||||||
|
---@field debug boolean
|
||||||
|
---@field channels string[]
|
||||||
|
---@field keyword string
|
||||||
|
---@field allAssist boolean
|
||||||
|
---@field agentsAssist boolean
|
||||||
|
---@field throttle number
|
||||||
|
---@field kickOffline boolean
|
||||||
|
---@field cleanupInterval number
|
||||||
|
---@field afkThreshold number
|
||||||
|
---@field listeningChannel table<string, boolean>
|
||||||
|
|
||||||
local ModuleName = "Inviter"
|
local ModuleName = "Inviter"
|
||||||
|
|
||||||
---@diagnostic disable-next-line: missing-fields
|
---@class Inviter
|
||||||
shared.Inviter = {}
|
shared.Inviter = {
|
||||||
function shared.Inviter.Init()
|
Init = function()
|
||||||
-- Fallback for old config
|
-- Fallback for old config
|
||||||
if type(Heimdall_Data.config.inviter.listeningChannel) == "string" then
|
if type(Heimdall_Data.config.inviter.listeningChannel) == "string" then
|
||||||
Heimdall_Data.config.inviter.listeningChannel = {
|
Heimdall_Data.config.inviter.listeningChannel = {
|
||||||
@@ -225,7 +239,9 @@ function shared.Inviter.Init()
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
if msg == Heimdall_Data.config.inviter.keyword then
|
if msg == Heimdall_Data.config.inviter.keyword then
|
||||||
if Heimdall_Data.config.inviter.debug then print(string.format("[%s] Inviting %s", ModuleName, sender)) end
|
if Heimdall_Data.config.inviter.debug then
|
||||||
|
print(string.format("[%s] Inviting %s", ModuleName, sender))
|
||||||
|
end
|
||||||
InviteUnit(sender)
|
InviteUnit(sender)
|
||||||
else
|
else
|
||||||
if Heimdall_Data.config.inviter.debug then
|
if Heimdall_Data.config.inviter.debug then
|
||||||
@@ -256,4 +272,5 @@ function shared.Inviter.Init()
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
print("[Heimdall] Inviter loaded")
|
print("[Heimdall] Inviter loaded")
|
||||||
end
|
end,
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,10 +1,16 @@
|
|||||||
local _, shared = ...
|
local _, shared = ...
|
||||||
---@cast shared HeimdallShared
|
---@cast shared HeimdallShared
|
||||||
|
|
||||||
|
---@class HeimdallMacroerConfig
|
||||||
|
---@field enabled boolean
|
||||||
|
---@field debug boolean
|
||||||
|
---@field priority string[]
|
||||||
|
|
||||||
local ModuleName = "Macroer"
|
local ModuleName = "Macroer"
|
||||||
|
|
||||||
---@diagnostic disable-next-line: missing-fields
|
---@class Macroer
|
||||||
shared.Macroer = {}
|
shared.Macroer = {
|
||||||
function shared.Macroer.Init()
|
Init = function()
|
||||||
local function FindOrCreateMacro(macroName)
|
local function FindOrCreateMacro(macroName)
|
||||||
if Heimdall_Data.config.macroer.debug then
|
if Heimdall_Data.config.macroer.debug then
|
||||||
print(string.format("[%s] Finding or creating macro: %s", ModuleName, macroName))
|
print(string.format("[%s] Finding or creating macro: %s", ModuleName, macroName))
|
||||||
@@ -90,7 +96,7 @@ function shared.Macroer.Init()
|
|||||||
end
|
end
|
||||||
FixMacro(stinkies)
|
FixMacro(stinkies)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
if Heimdall_Data.config.macroer.debug then print(string.format("[%s] Module initialized", ModuleName)) end
|
if Heimdall_Data.config.macroer.debug then print(string.format("[%s] Module initialized", ModuleName)) end
|
||||||
print("[Heimdall] Macroer loaded")
|
print("[Heimdall] Macroer loaded")
|
||||||
end
|
end,
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,9 +2,17 @@ local _, shared = ...
|
|||||||
---@cast shared HeimdallShared
|
---@cast shared HeimdallShared
|
||||||
local ModuleName = "Sniffer"
|
local ModuleName = "Sniffer"
|
||||||
|
|
||||||
---@diagnostic disable-next-line: missing-fields
|
---@class HeimdallSnifferConfig
|
||||||
shared.Sniffer = {}
|
---@field enabled boolean
|
||||||
function shared.Sniffer.Init()
|
---@field debug boolean
|
||||||
|
---@field channels string[]
|
||||||
|
---@field throttle number -- throttleTime in the original code, matching config name now
|
||||||
|
---@field zoneOverride string?
|
||||||
|
---@field stinky boolean
|
||||||
|
|
||||||
|
---@class Sniffer
|
||||||
|
shared.Sniffer = {
|
||||||
|
Init = function()
|
||||||
if Heimdall_Data.config.sniffer.debug then print(string.format("[%s] Module initializing", ModuleName)) end
|
if Heimdall_Data.config.sniffer.debug then print(string.format("[%s] Module initializing", ModuleName)) end
|
||||||
local smellThrottle = {}
|
local smellThrottle = {}
|
||||||
local SmellStinky = function(stinky)
|
local SmellStinky = function(stinky)
|
||||||
@@ -19,7 +27,7 @@ function shared.Sniffer.Init()
|
|||||||
end
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if smellThrottle[stinky] and GetTime() - smellThrottle[stinky] < Heimdall_Data.config.sniffer.throttleTime then
|
if smellThrottle[stinky] and GetTime() - smellThrottle[stinky] < Heimdall_Data.config.sniffer.throttle then
|
||||||
if Heimdall_Data.config.sniffer.debug then print(string.format("%s: Throttled", ModuleName)) end
|
if Heimdall_Data.config.sniffer.debug then print(string.format("%s: Throttled", ModuleName)) end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@@ -80,4 +88,5 @@ function shared.Sniffer.Init()
|
|||||||
end)
|
end)
|
||||||
if Heimdall_Data.config.sniffer.debug then print(string.format("[%s] Module initialized", ModuleName)) end
|
if Heimdall_Data.config.sniffer.debug then print(string.format("[%s] Module initialized", ModuleName)) end
|
||||||
print("[Heimdall] Sniffer loaded")
|
print("[Heimdall] Sniffer loaded")
|
||||||
end
|
end,
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user