Code format

This commit is contained in:
2025-01-09 10:55:32 +01:00
parent 2e44a1ef31
commit be81a31302
15 changed files with 274 additions and 231 deletions

View File

@@ -44,7 +44,8 @@ function shared.AgentTracker.Init()
newAgents = newAgents + 1
end
if Heimdall_Data.config.agentTracker.debug then
print(string.format("[%s] %s agent: %s", ModuleName, isNewAgent and "Added new" or "Updated existing", name))
print(string.format("[%s] %s agent: %s", ModuleName, isNewAgent and "Added new" or "Updated existing",
name))
end
end
end
@@ -57,22 +58,22 @@ function shared.AgentTracker.Init()
local agentTrackerChannelSniffer = CreateFrame("Frame")
agentTrackerChannelSniffer:RegisterEvent("CHAT_MSG_CHANNEL")
agentTrackerChannelSniffer:SetScript("OnEvent", function(self, event, msg, sender, ...)
-- if Heimdall_Data.config.agentTracker.debug then
-- print(string.format("[%s] Channel message received from: %s", ModuleName, sender))
-- end
-- if Heimdall_Data.config.agentTracker.debug then
-- print(string.format("[%s] Channel message received from: %s", ModuleName, sender))
-- end
if not Heimdall_Data.config.agentTracker.enabled then
-- if Heimdall_Data.config.agentTracker.debug then
-- print(string.format("[%s] Module disabled, ignoring channel message", ModuleName))
-- end
-- if Heimdall_Data.config.agentTracker.debug then
-- print(string.format("[%s] Module disabled, ignoring channel message", ModuleName))
-- end
return
end
local channelId = select(6, ...)
local _, channelname = GetChannelName(channelId)
if channelname ~= Heimdall_Data.config.agentTracker.masterChannel then
-- if Heimdall_Data.config.agentTracker.debug then
-- print(string.format("[%s] Ignoring message from non-master channel: %s", ModuleName, channelname))
-- end
-- if Heimdall_Data.config.agentTracker.debug then
-- print(string.format("[%s] Ignoring message from non-master channel: %s", ModuleName, channelname))
-- end
return
end
if Heimdall_Data.config.agentTracker.debug then
@@ -86,7 +87,8 @@ function shared.AgentTracker.Init()
Heimdall_Data.config.agents[sender] = date("%Y-%m-%dT%H:%M:%S")
if Heimdall_Data.config.agentTracker.debug then
print(string.format("[%s] %s agent from message: %s", ModuleName, isNewAgent and "Added new" or "Updated existing", sender))
print(string.format("[%s] %s agent from message: %s", ModuleName,
isNewAgent and "Added new" or "Updated existing", sender))
end
end)

View File

@@ -53,7 +53,8 @@ function shared.CombatAlerter.Init()
if shared.stinkyTracker.stinkies and shared.stinkyTracker.stinkies[source] then
if Heimdall_Data.config.combatAlerter.debug then
print(string.format("[%s] Source is tracked stinky: %s (Already alerted: %s)", ModuleName, source, tostring(alerted[source] or false)))
print(string.format("[%s] Source is tracked stinky: %s (Already alerted: %s)", ModuleName, source,
tostring(alerted[source] or false)))
end
if alerted[source] then return end
@@ -62,7 +63,8 @@ function shared.CombatAlerter.Init()
local zone, subZone = GetZoneText(), GetSubZoneText()
if Heimdall_Data.config.combatAlerter.debug then
print(string.format("[%s] Player location: %s/%s at %.2f,%.2f", ModuleName, zone, subZone, x * 100, y * 100))
print(string.format("[%s] Player location: %s/%s at %.2f,%.2f", ModuleName, zone, subZone, x * 100,
y * 100))
end
---@type Message

View File

@@ -131,7 +131,10 @@ function shared.Commander.Init()
return text
end
local function CountClassPartitionedStinkies()
if Heimdall_Data.config.commander.debug then print(string.format("[%s] Executing: CountClassPartitionedStinkies", ModuleName)) end
if Heimdall_Data.config.commander.debug then
print(string.format("[%s] Executing: CountClassPartitionedStinkies",
ModuleName))
end
local res = CountClassPartitioned(HeimdallStinkies)
if #res == 0 then
return { "No stinkies found" }
@@ -139,7 +142,10 @@ function shared.Commander.Init()
return res
end
local function WhoPartitionedStinkies()
if Heimdall_Data.config.commander.debug then print(string.format("[%s] Executing: WhoPartitionedStinkies", ModuleName)) end
if Heimdall_Data.config.commander.debug then
print(string.format("[%s] Executing: WhoPartitionedStinkies",
ModuleName))
end
local res = WhoPartitioned(HeimdallStinkies)
if #res == 0 then
return { "No stinkies found" }
@@ -147,7 +153,10 @@ function shared.Commander.Init()
return res
end
local function CountPartitionedStinkies()
if Heimdall_Data.config.commander.debug then print(string.format("[%s] Executing: CountPartitionedStinkies", ModuleName)) end
if Heimdall_Data.config.commander.debug then
print(string.format("[%s] Executing: CountPartitionedStinkies",
ModuleName))
end
local res = CountPartitioned(HeimdallStinkies)
if #res == 0 then
return { "No stinkies found" }
@@ -212,21 +221,21 @@ function shared.Commander.Init()
local commanderChannelFrame = CreateFrame("Frame")
commanderChannelFrame:RegisterEvent("CHAT_MSG_CHANNEL")
commanderChannelFrame:SetScript("OnEvent", function(self, event, msg, sender, ...)
-- if Heimdall_Data.config.commander.debug then
-- print(string.format("[%s] Event received", ModuleName))
-- shared.dumpTable(Heimdall_Data.config.commander)
-- end
-- if Heimdall_Data.config.commander.debug then
-- print(string.format("[%s] Event received", ModuleName))
-- shared.dumpTable(Heimdall_Data.config.commander)
-- end
if not Heimdall_Data.config.commander.enabled then
-- if Heimdall_Data.config.commander.debug then
-- print(string.format("[%s] Module disabled, ignoring event", ModuleName))
-- end
-- if Heimdall_Data.config.commander.debug then
-- print(string.format("[%s] Module disabled, ignoring event", ModuleName))
-- end
return
end
local channelId = select(6, ...)
local _, channelname = GetChannelName(channelId)
-- if Heimdall_Data.config.commander.debug then
-- print(string.format("[%s] Channel received: %s", ModuleName, channelname))
-- end
-- if Heimdall_Data.config.commander.debug then
-- print(string.format("[%s] Channel received: %s", ModuleName, channelname))
-- end
if channelname ~= Heimdall_Data.config.commander.masterChannel then return end
sender = string.match(sender, "^[^-]+")
if Heimdall_Data.config.commander.debug then

View File

@@ -38,14 +38,16 @@ function shared.DeathReporter.Init()
if recentDuels[destination] and GetTime() - recentDuels[destination] < Heimdall_Data.config.deathReporter.duelThrottle then
if Heimdall_Data.config.deathReporter.debug then
print(string.format("[%s] Ignoring death report - Recent duel detected for target: %s", ModuleName, destination))
print(string.format("[%s] Ignoring death report - Recent duel detected for target: %s", ModuleName,
destination))
end
return
end
if recentDuels[source] and GetTime() - recentDuels[source] < Heimdall_Data.config.deathReporter.duelThrottle then
if Heimdall_Data.config.deathReporter.debug then
print(string.format("[%s] Ignoring death report - Recent duel detected for source: %s", ModuleName, source))
print(string.format("[%s] Ignoring death report - Recent duel detected for source: %s", ModuleName,
source))
end
return
end
@@ -58,14 +60,16 @@ function shared.DeathReporter.Init()
C_Timer.NewTimer(3, function()
if recentDuels[destination] and GetTime() - recentDuels[destination] < Heimdall_Data.config.deathReporter.duelThrottle then
if Heimdall_Data.config.deathReporter.debug then
print(string.format("[%s] Cancelling delayed death report - Recent duel detected for: %s", ModuleName, destination))
print(string.format("[%s] Cancelling delayed death report - Recent duel detected for: %s", ModuleName,
destination))
end
return
end
if recentDuels[source] and GetTime() - recentDuels[source] < Heimdall_Data.config.deathReporter.duelThrottle then
if Heimdall_Data.config.deathReporter.debug then
print(string.format("[%s] Cancelling delayed death report - Recent duel detected for: %s", ModuleName, source))
print(string.format("[%s] Cancelling delayed death report - Recent duel detected for: %s", ModuleName,
source))
end
return
end

View File

@@ -30,7 +30,7 @@ function shared.Dueler.Init()
end
AcceptDuel()
else
if Heimdall_Data.config.dueler.autoDecline then
if Heimdall_Data.config.dueler.declineOther then
if Heimdall_Data.config.dueler.debug then
print(string.format("[%s] Auto-declining duel from untrusted sender: %s", ModuleName, sender))
end
@@ -44,7 +44,8 @@ function shared.Dueler.Init()
end)
if Heimdall_Data.config.dueler.debug then
print(string.format("[%s] Module initialized with auto-decline: %s", ModuleName, tostring(Heimdall_Data.config.dueler.autoDecline)))
print(string.format("[%s] Module initialized with auto-decline: %s", ModuleName,
tostring(Heimdall_Data.config.dueler.declineOther)))
end
print("[Heimdall] Dueler loaded")
end

View File

@@ -9,27 +9,27 @@ function shared.Echoer.Init()
local frame = CreateFrame("Frame")
frame:RegisterEvent("CHAT_MSG_CHANNEL")
frame:SetScript("OnEvent", function(self, event, msg, sender, ...)
-- if Heimdall_Data.config.echoer.debug then
-- print(string.format("[%s] Channel message received from: %s", ModuleName, sender))
-- end
-- if Heimdall_Data.config.echoer.debug then
-- print(string.format("[%s] Channel message received from: %s", ModuleName, sender))
-- end
if not Heimdall_Data.config.echoer.enabled then
-- if Heimdall_Data.config.echoer.debug then
-- print(string.format("[%s] Module disabled, ignoring message", ModuleName))
-- end
-- if Heimdall_Data.config.echoer.debug then
-- print(string.format("[%s] Module disabled, ignoring message", ModuleName))
-- end
return
end
local channelId = select(6, ...)
local _, channelname = GetChannelName(channelId)
-- if Heimdall_Data.config.echoer.debug then
-- print(string.format("[%s] Processing message from channel: %s", ModuleName, channelname))
-- end
-- if Heimdall_Data.config.echoer.debug then
-- print(string.format("[%s] Processing message from channel: %s", ModuleName, channelname))
-- end
if channelname ~= Heimdall_Data.config.echoer.masterChannel then
if Heimdall_Data.config.echoer.debug then
print(string.format("[%s] Ignoring message from non-master channel", ModuleName))
end
-- if Heimdall_Data.config.echoer.debug then
-- print(string.format("[%s] Ignoring message from non-master channel", ModuleName))
-- end
return
end
if Heimdall_Data.config.echoer.debug then

View File

@@ -9,27 +9,27 @@ function shared.Emoter.Init()
local frame = CreateFrame("Frame")
frame:RegisterEvent("CHAT_MSG_CHANNEL")
frame:SetScript("OnEvent", function(self, event, msg, sender, ...)
-- if Heimdall_Data.config.emoter.debug then
-- print(string.format("[%s] Channel message received from: %s", ModuleName, sender))
-- end
-- if Heimdall_Data.config.emoter.debug then
-- print(string.format("[%s] Channel message received from: %s", ModuleName, sender))
-- end
if not Heimdall_Data.config.emoter.enabled then
-- if Heimdall_Data.config.emoter.debug then
-- print(string.format("[%s] Module disabled, ignoring message", ModuleName))
-- end
-- if Heimdall_Data.config.emoter.debug then
-- print(string.format("[%s] Module disabled, ignoring message", ModuleName))
-- end
return
end
local channelId = select(6, ...)
local _, channelname = GetChannelName(channelId)
-- if Heimdall_Data.config.emoter.debug then
-- print(string.format("[%s] Processing message from channel: %s", ModuleName, channelname))
-- end
-- if Heimdall_Data.config.emoter.debug then
-- print(string.format("[%s] Processing message from channel: %s", ModuleName, channelname))
-- end
if channelname ~= Heimdall_Data.config.emoter.masterChannel then
-- if Heimdall_Data.config.emoter.debug then
-- print(string.format("[%s] Ignoring message from non-master channel", ModuleName))
-- end
-- if Heimdall_Data.config.emoter.debug then
-- print(string.format("[%s] Ignoring message from non-master channel", ModuleName))
-- end
return
end
if Heimdall_Data.config.emoter.debug then

View File

@@ -192,6 +192,31 @@ function shared.Inviter.Init()
end
end)
if Heimdall_Data.config.inviter.debug then
print(string.format("[%s] Module initialized - All assist: %s, Agents assist: %s",
ModuleName,
tostring(Heimdall_Data.config.inviter.allAssist),
tostring(Heimdall_Data.config.inviter.agentsAssist)))
end
print("[Heimdall] Inviter loaded")
einviterChannelFrame:RegisterEvent("CHAT_MSG_CHANNEL")
inviterChannelFrame:SetScript("OnEvent", function(self, event, msg, sender, ...)
-- if Heimdall_Data.config.inviter.debug then
-- print(string.format("[%s] Chat message received: %s", ModuleName, msg))
-- shared.dumpTable(Heimdall_Data.config.inviter)
-- end
if not Heimdall_Data.config.inviter.enabled then return end
local channelId = select(6, ...)
local _, channelname = GetChannelName(channelId)
if channelname ~= Heimdall_Data.config.inviter.listeningChannel then return end
if msg == Heimdall_Data.config.inviter.keyword then
if Heimdall_Data.config.inviter.debug then
print(string.format("[%s] Inviting %s", ModuleName, sender))
end
InviteUnit(sender)
end
end)
if Heimdall_Data.config.inviter.debug then
print(string.format("[%s] Module initialized - All assist: %s, Agents assist: %s",
ModuleName,

View File

@@ -11,17 +11,6 @@ function shared.Messenger.Init()
---@field channel string
---@field data string
local function GetChannelId(channelName)
local channels = { GetChannelList() }
for i = 1, #channels, 2 do
local id = channels[i]
local name = channels[i + 1]
if name == channelName then
return id
end
end
end
local function FindOrJoinChannel(channelName, password)
local channelId = GetChannelName(channelName)
if channelId == 0 then
@@ -78,7 +67,8 @@ function shared.Messenger.Init()
if message.channel == "CHANNEL" and message.data and string.match(message.data, "%D") then
if Heimdall_Data.config.messenger.debug then
print(string.format("[%s] Processing channel message: '%s' to '%s'", ModuleName, message.message, message.data))
print(string.format("[%s] Processing channel message: '%s' to '%s'", ModuleName, message.message,
message.data))
end
local channelId = GetChannelName(message.data)
if channelId == 0 then
@@ -114,7 +104,8 @@ function shared.Messenger.Init()
end
if Heimdall_Data.config.messenger.debug then
print(string.format("[%s] Sending message: '%s' to %s:%s", ModuleName, message.message, message.channel, message.data))
print(string.format("[%s] Sending message: '%s' to %s:%s", ModuleName, message.message, message.channel,
message.data))
end
SendChatMessage(message.message, message.channel, nil, message.data)
end
@@ -130,7 +121,8 @@ function shared.Messenger.Init()
end
if Heimdall_Data.config.messenger.debug then
print(string.format("[%s] Module initialized with interval: %s", ModuleName, Heimdall_Data.config.messenger.interval))
print(string.format("[%s] Module initialized with interval: %s", ModuleName,
Heimdall_Data.config.messenger.interval))
end
print("[Heimdall] Messenger loaded")
end

View File

@@ -67,7 +67,8 @@ function shared.Spotter.Init()
end
if Heimdall_Data.config.spotter.debug then
print(string.format("[%s] Using everyone setting: %s", ModuleName, tostring(Heimdall_Data.config.spotter.everyone)))
print(string.format("[%s] Using everyone setting: %s", ModuleName,
tostring(Heimdall_Data.config.spotter.everyone)))
end
return Heimdall_Data.config.spotter.everyone
end

View File

@@ -26,7 +26,8 @@ function shared.StinkyTracker.Init()
hostile = true
}
if Heimdall_Data.config.stinkyTracker.debug then
print(string.format("[%s] Found hostile player: %s (%s) at %s", ModuleName, name, class, date("%H:%M:%S", time())))
print(string.format("[%s] Found hostile player: %s (%s) at %s", ModuleName, name, class,
date("%H:%M:%S", time())))
end
end
return stinkies
@@ -55,7 +56,8 @@ function shared.StinkyTracker.Init()
}
stinkies[name] = stinky
if Heimdall_Data.config.stinkyTracker.debug then
print(string.format("[%s] Found stinky in SEE: %s (%s) - %s at %s", ModuleName, name, class, aggression, date("%H:%M:%S", time())))
print(string.format("[%s] Found stinky in SEE: %s (%s) - %s at %s", ModuleName, name, class, aggression,
date("%H:%M:%S", time())))
end
return stinkies
end
@@ -95,21 +97,21 @@ function shared.StinkyTracker.Init()
local frame = CreateFrame("Frame")
frame:RegisterEvent("CHAT_MSG_CHANNEL")
frame:SetScript("OnEvent", function(self, event, msg, sender, ...)
-- if Heimdall_Data.config.stinkyTracker.debug then
-- print(string.format("[%s] Event received: %s from %s", ModuleName, event, sender))
-- end
-- if Heimdall_Data.config.stinkyTracker.debug then
-- print(string.format("[%s] Event received: %s from %s", ModuleName, event, sender))
-- end
if not Heimdall_Data.config.stinkyTracker.enabled then
-- if Heimdall_Data.config.stinkyTracker.debug then
-- print(string.format("[%s] Module disabled, ignoring event", ModuleName))
-- end
-- if Heimdall_Data.config.stinkyTracker.debug then
-- print(string.format("[%s] Module disabled, ignoring event", ModuleName))
-- end
return
end
local channelId = select(6, ...)
local _, channelname = GetChannelName(channelId)
if channelname ~= Heimdall_Data.config.stinkyTracker.masterChannel then
-- if Heimdall_Data.config.stinkyTracker.debug then
-- print(string.format("[%s] Ignoring message from non-master channel: %s", ModuleName, channelname))
-- end
-- if Heimdall_Data.config.stinkyTracker.debug then
-- print(string.format("[%s] Ignoring message from non-master channel: %s", ModuleName, channelname))
-- end
return
end
if Heimdall_Data.config.stinkyTracker.debug then
@@ -129,7 +131,8 @@ function shared.StinkyTracker.Init()
if stinky.hostile then
shared.stinkyTracker.stinkies[name] = stinky
if Heimdall_Data.config.stinkyTracker.debug then
print(string.format("[%s] Added hostile stinky from WHO: %s (%s)", ModuleName, name, stinky.class))
print(string.format("[%s] Added hostile stinky from WHO: %s (%s)", ModuleName, name, stinky
.class))
end
end
end
@@ -146,7 +149,8 @@ function shared.StinkyTracker.Init()
if stinky.hostile then
shared.stinkyTracker.stinkies[name] = stinky
if Heimdall_Data.config.stinkyTracker.debug then
print(string.format("[%s] Added hostile stinky from SEE: %s (%s)", ModuleName, name, stinky.class))
print(string.format("[%s] Added hostile stinky from SEE: %s (%s)", ModuleName, name, stinky
.class))
end
end
if not stinky.hostile then

View File

@@ -172,7 +172,8 @@ function shared.Whoer.Init()
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))
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
@@ -359,6 +360,9 @@ function shared.Whoer.Init()
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)
@@ -432,4 +436,3 @@ function shared.Whoer.Init()
print("Heimdall - Whoer loaded")
end