Fix up the log messages a lil

Unbutcher inviter
This commit is contained in:
2025-01-08 17:11:07 +01:00
parent fca49c6302
commit d3004019c6
15 changed files with 647 additions and 305 deletions

View File

@@ -11,79 +11,84 @@ function shared.AgentTracker.Init()
channelRosterFrame:RegisterEvent("CHANNEL_ROSTER_UPDATE") channelRosterFrame:RegisterEvent("CHANNEL_ROSTER_UPDATE")
channelRosterFrame:SetScript("OnEvent", function(self, event, index) channelRosterFrame:SetScript("OnEvent", function(self, event, index)
if Heimdall_Data.config.agentTracker.debug then if Heimdall_Data.config.agentTracker.debug then
print(string.format("%s: Received event: %s", ModuleName, event)) print(string.format("[%s] Channel roster update received", ModuleName))
shared.dumpTable(Heimdall_Data.config.agentTracker)
end end
if not Heimdall_Data.config.agentTracker.enabled then if not Heimdall_Data.config.agentTracker.enabled then
if Heimdall_Data.config.agentTracker.debug then if Heimdall_Data.config.agentTracker.debug then
print(string.format("%s: AgentTracker disabled", ModuleName)) print(string.format("[%s] Module disabled, ignoring roster update", ModuleName))
end end
return return
end end
local name = GetChannelDisplayInfo(index) local name = GetChannelDisplayInfo(index)
if Heimdall_Data.config.agentTracker.debug then if Heimdall_Data.config.agentTracker.debug then
print(string.format("%s: Processing channel: %s", ModuleName, name)) print(string.format("[%s] Processing channel update: %s (index: %d)", ModuleName, name or "nil", index))
end end
if name ~= Heimdall_Data.config.agentTracker.masterChannel then if name ~= Heimdall_Data.config.agentTracker.masterChannel then
if Heimdall_Data.config.agentTracker.debug then if Heimdall_Data.config.agentTracker.debug then
print(string.format("%s: Channel is not master channel: %s", ModuleName, name)) print(string.format("[%s] Ignoring non-master channel: %s", ModuleName, name or "nil"))
end end
return return
end end
local count = select(5, GetChannelDisplayInfo(index)) local count = select(5, GetChannelDisplayInfo(index))
if Heimdall_Data.config.agentTracker.debug then
print(string.format("[%s] Processing %d members in channel", ModuleName, count))
end
local newAgents = 0
for i = 1, count do for i = 1, count do
local name = GetChannelRosterInfo(index, i) local name = GetChannelRosterInfo(index, i)
if name then if name then
if Heimdall_Data.config.agentTracker.debug then local isNewAgent = not Heimdall_Data.config.agents[name]
print(string.format("%s: Tracking agent in channel: %s", ModuleName, name))
end
Heimdall_Data.config.agents[name] = date("%Y-%m-%dT%H:%M:%S") Heimdall_Data.config.agents[name] = date("%Y-%m-%dT%H:%M:%S")
if isNewAgent then
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))
end
end end
end end
if Heimdall_Data.config.agentTracker.debug then
print(string.format("[%s] Roster update complete - Added %d new agents", ModuleName, newAgents))
end
end) end)
local agentTrackerChannelSniffer = CreateFrame("Frame") local agentTrackerChannelSniffer = CreateFrame("Frame")
agentTrackerChannelSniffer:RegisterEvent("CHAT_MSG_CHANNEL") agentTrackerChannelSniffer:RegisterEvent("CHAT_MSG_CHANNEL")
agentTrackerChannelSniffer:SetScript("OnEvent", function(self, event, msg, sender, ...) agentTrackerChannelSniffer:SetScript("OnEvent", function(self, event, msg, sender, ...)
if Heimdall_Data.config.agentTracker.debug then if Heimdall_Data.config.agentTracker.debug then
print(string.format("%s: Received event: %s", ModuleName, event)) print(string.format("[%s] Channel message received from: %s", ModuleName, sender))
shared.dumpTable(Heimdall_Data.config.agentTracker)
end end
if not Heimdall_Data.config.agentTracker.enabled then if not Heimdall_Data.config.agentTracker.enabled then
if Heimdall_Data.config.agentTracker.debug then if Heimdall_Data.config.agentTracker.debug then
print(string.format("%s: AgentTracker disabled", ModuleName)) print(string.format("[%s] Module disabled, ignoring channel message", ModuleName))
end end
return return
end end
local channelId = select(6, ...) local channelId = select(6, ...)
local channelname = GetChannelName(channelId) 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
return
end
sender = string.match(sender, "^[^-]+")
local isNewAgent = not Heimdall_Data.config.agents[sender]
Heimdall_Data.config.agents[sender] = date("%Y-%m-%dT%H:%M:%S")
if Heimdall_Data.config.agentTracker.debug then if Heimdall_Data.config.agentTracker.debug then
print(string.format("%s: Processing message from: %s", ModuleName, sender)) print(string.format("[%s] %s agent from message: %s", ModuleName, isNewAgent and "Added new" or "Updated existing", sender))
end end
if not channelname then
if Heimdall_Data.config.agentTracker.debug then
print(string.format("%s: No channel name found", ModuleName))
end
return
end
if channelname ~= Heimdall_Data.config.who.notifyChannel then
if Heimdall_Data.config.agentTracker.debug then
print(string.format("%s: Message not in notify channel: %s", ModuleName, channelname))
end
return
end
local agentName = sender
if Heimdall_Data.config.agentTracker.debug then
print(string.format("%s: Tracking agent from message: %s", ModuleName, agentName))
end
if not agentName then
if Heimdall_Data.config.agentTracker.debug then
print(string.format("%s: No agent name found", ModuleName))
end
return
end
Heimdall_Data.config.agents[agentName] = date("%Y-%m-%dT%H:%M:%S")
end) end)
print("Heimdall - AgentTracker loaded") if Heimdall_Data.config.agentTracker.debug then
local count = 0
for _ in pairs(Heimdall_Data.config.agents) do count = count + 1 end
print(string.format("[%s] Module initialized - Tracking %d agents", ModuleName, count))
end
print("[Heimdall] AgentTracker loaded")
end end

View File

@@ -1,9 +1,13 @@
local addonname, shared = ... local addonname, shared = ...
---@cast shared HeimdallShared ---@cast shared HeimdallShared
---@cast addonname string ---@cast addonname string
local ModuleName = "Bully"
---@diagnostic disable-next-line: missing-fields ---@diagnostic disable-next-line: missing-fields
shared.Bully = {} shared.Bully = {}
function shared.Bully.Init() function shared.Bully.Init()
print("Heimdall - Bully loaded") if Heimdall_Data.config.bully.debug then
print(string.format("[%s] Module initialized", ModuleName))
end
print("[Heimdall] Bully loaded")
end end

View File

@@ -11,47 +11,77 @@ function shared.CombatAlerter.Init()
combatAlerterFrame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED") combatAlerterFrame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
combatAlerterFrame:SetScript("OnEvent", function(self, event, ...) combatAlerterFrame:SetScript("OnEvent", function(self, event, ...)
if Heimdall_Data.config.combatAlerter.debug then if Heimdall_Data.config.combatAlerter.debug then
print(string.format("%s: Received event: %s", ModuleName, event)) print(string.format("[%s] Combat log event received", ModuleName))
shared.dumpTable(Heimdall_Data.config.combatAlerter)
end end
if not Heimdall_Data.config.combatAlerter.enabled then return end if not Heimdall_Data.config.combatAlerter.enabled then
if Heimdall_Data.config.combatAlerter.debug then
print(string.format("[%s] Module disabled, ignoring combat event", ModuleName))
end
return
end
local destination, err = CLEUParser.GetDestName(...) local destination, err = CLEUParser.GetDestName(...)
if err then return end if err then
if Heimdall_Data.config.combatAlerter.debug then if Heimdall_Data.config.combatAlerter.debug then
print(string.format("%s: Destination: %s", ModuleName, destination)) print(string.format("[%s] Error getting destination: %s", ModuleName, err))
end
return
end end
if destination ~= UnitName("player") then return end
if Heimdall_Data.config.combatAlerter.debug then
print(string.format("[%s] Combat event destination: %s", ModuleName, destination))
end
if destination ~= UnitName("player") then
if Heimdall_Data.config.combatAlerter.debug then
print(string.format("[%s] Ignoring event - not targeted at player", ModuleName))
end
return
end
local source, err = CLEUParser.GetSourceName(...) local source, err = CLEUParser.GetSourceName(...)
if Heimdall_Data.config.combatAlerter.debug then if err then
print(string.format("%s: Source: %s", ModuleName, source)) if Heimdall_Data.config.combatAlerter.debug then
print(string.format("[%s] Error getting source, using 'unknown': %s", ModuleName, err))
end
source = "unknown"
end
if Heimdall_Data.config.combatAlerter.debug then
print(string.format("[%s] Combat event source: %s", ModuleName, source))
end end
if err then source = "unknown" end
if shared.stinkyTracker.stinkies and shared.stinkyTracker.stinkies[source] then if shared.stinkyTracker.stinkies and shared.stinkyTracker.stinkies[source] then
if Heimdall_Data.config.combatAlerter.debug then if Heimdall_Data.config.combatAlerter.debug then
print(string.format("%s: Alerted status for %s: %s", ModuleName, source, alerted[source])) print(string.format("[%s] Source is tracked stinky: %s (Already alerted: %s)", ModuleName, source, tostring(alerted[source] or false)))
end end
if alerted[source] then return end if alerted[source] then return end
alerted[source] = true alerted[source] = true
local x, y = GetPlayerMapPosition("player") local x, y = GetPlayerMapPosition("player")
local zone, subZone = GetZoneText(), GetSubZoneText()
if Heimdall_Data.config.combatAlerter.debug then if Heimdall_Data.config.combatAlerter.debug then
print(string.format("%s: Player position: %2.2f,%2.2f", ModuleName, x, y)) print(string.format("[%s] Player location: %s/%s at %.2f,%.2f", ModuleName, zone, subZone, x * 100, y * 100))
end end
---@type Message ---@type Message
local msg = { local msg = {
channel = "CHANNEL", channel = "CHANNEL",
data = Heimdall_Data.config.combatAlerter.masterChannel, data = Heimdall_Data.config.combatAlerter.masterChannel,
message = string.format("%s is attacking me in %s(%s) at %2.2f,%2.2f ", message = string.format("%s is attacking me in %s(%s) at %2.2f,%2.2f ",
source, source,
GetZoneText(), GetSubZoneText(), zone, subZone,
x * 100, y * 100 x * 100, y * 100
), ),
} }
if Heimdall_Data.config.combatAlerter.debug then if Heimdall_Data.config.combatAlerter.debug then
print(string.format("%s: Message:", ModuleName)) print(string.format("[%s] Queuing alert message: '%s'", ModuleName, msg.message))
shared.dumpTable(msg)
end end
table.insert(shared.messenger.queue, msg) table.insert(shared.messenger.queue, msg)
elseif Heimdall_Data.config.combatAlerter.debug then
print(string.format("[%s] Source not in stinky list, ignoring: %s", ModuleName, source))
end end
end) end)
@@ -60,11 +90,18 @@ function shared.CombatAlerter.Init()
combatTriggerFrame:RegisterEvent("PLAYER_REGEN_ENABLED") combatTriggerFrame:RegisterEvent("PLAYER_REGEN_ENABLED")
combatTriggerFrame:SetScript("OnEvent", function(self, event, ...) combatTriggerFrame:SetScript("OnEvent", function(self, event, ...)
if Heimdall_Data.config.combatAlerter.debug then if Heimdall_Data.config.combatAlerter.debug then
print(string.format("%s: Received event: %s", ModuleName, event)) print(string.format("[%s] Combat state changed: %s", ModuleName, event))
shared.dumpTable(Heimdall_Data.config.combatAlerter) if event == "PLAYER_REGEN_DISABLED" then
print(string.format("[%s] Entered combat - Resetting alerts", ModuleName))
else
print(string.format("[%s] Left combat - Resetting alerts", ModuleName))
end
end end
alerted = {} alerted = {}
end) end)
print("Heimdall - CombatAlerter loaded") if Heimdall_Data.config.combatAlerter.debug then
print(string.format("[%s] Module initialized", ModuleName))
end
print("[Heimdall] CombatAlerter loaded")
end end

View File

@@ -88,7 +88,7 @@ function shared.Commander.Init()
end end
end end
if Heimdall_Data.config.commander.debug then if Heimdall_Data.config.commander.debug then
print(string.format("%s: ret = %s", ModuleName, strjoin(", ", unpack(ret)))) print(string.format("[%s] Command result: %s", ModuleName, strjoin(", ", unpack(ret))))
end end
return ret return ret
end end
@@ -116,7 +116,7 @@ function shared.Commander.Init()
text[#text + 1] = string.format("%s: %d", class, count) text[#text + 1] = string.format("%s: %d", class, count)
end end
if Heimdall_Data.config.commander.debug then if Heimdall_Data.config.commander.debug then
print(string.format("%s: ret = %s", ModuleName, strjoin(", ", unpack(text)))) print(string.format("[%s] Message text: %s", ModuleName, strjoin(", ", unpack(text))))
end end
return text return text
end end
@@ -131,7 +131,7 @@ function shared.Commander.Init()
return text return text
end end
local function CountClassPartitionedStinkies() local function CountClassPartitionedStinkies()
if Heimdall_Data.config.commander.debug then print(string.format("%s: CountClassPartitionedStinkies", ModuleName)) end if Heimdall_Data.config.commander.debug then print(string.format("[%s] Executing: CountClassPartitionedStinkies", ModuleName)) end
local res = CountClassPartitioned(HeimdallStinkies) local res = CountClassPartitioned(HeimdallStinkies)
if #res == 0 then if #res == 0 then
return { "No stinkies found" } return { "No stinkies found" }
@@ -139,7 +139,7 @@ function shared.Commander.Init()
return res return res
end end
local function WhoPartitionedStinkies() local function WhoPartitionedStinkies()
if Heimdall_Data.config.commander.debug then print(string.format("%s: WhoPartitionedStinkies", ModuleName)) end if Heimdall_Data.config.commander.debug then print(string.format("[%s] Executing: WhoPartitionedStinkies", ModuleName)) end
local res = WhoPartitioned(HeimdallStinkies) local res = WhoPartitioned(HeimdallStinkies)
if #res == 0 then if #res == 0 then
return { "No stinkies found" } return { "No stinkies found" }
@@ -147,7 +147,7 @@ function shared.Commander.Init()
return res return res
end end
local function CountPartitionedStinkies() local function CountPartitionedStinkies()
if Heimdall_Data.config.commander.debug then print(string.format("%s: CountPartitionedStinkies", ModuleName)) end if Heimdall_Data.config.commander.debug then print(string.format("[%s] Executing: CountPartitionedStinkies", ModuleName)) end
local res = CountPartitioned(HeimdallStinkies) local res = CountPartitioned(HeimdallStinkies)
if #res == 0 then if #res == 0 then
return { "No stinkies found" } return { "No stinkies found" }
@@ -155,25 +155,25 @@ function shared.Commander.Init()
return res return res
end end
local function HelpRu() local function HelpRu()
if Heimdall_Data.config.commander.debug then print(string.format("%s: HelpRu", ModuleName)) end if Heimdall_Data.config.commander.debug then print(string.format("[%s] Executing: HelpRu", ModuleName)) end
return helpMessages.ru return helpMessages.ru
end end
local function HelpEn() local function HelpEn()
if Heimdall_Data.config.commander.debug then print(string.format("%s: HelpEn", ModuleName)) end if Heimdall_Data.config.commander.debug then print(string.format("[%s] Executing: HelpEn", ModuleName)) end
return helpMessages.en return helpMessages.en
end end
local groupInviteFrame = CreateFrame("Frame") local groupInviteFrame = CreateFrame("Frame")
groupInviteFrame:SetScript("OnEvent", function(self, event, ...) groupInviteFrame:SetScript("OnEvent", function(self, event, ...)
if Heimdall_Data.config.commander.debug then print(string.format("%s: OnEvent", ModuleName)) end if Heimdall_Data.config.commander.debug then print(string.format("[%s] Event received", ModuleName)) end
AcceptGroup() AcceptGroup()
groupInviteFrame:UnregisterEvent("PARTY_INVITE_REQUEST") groupInviteFrame:UnregisterEvent("PARTY_INVITE_REQUEST")
C_Timer.NewTimer(0.1, function() C_Timer.NewTimer(0.1, function()
if Heimdall_Data.config.commander.debug then print(string.format("%s: Click", ModuleName)) end if Heimdall_Data.config.commander.debug then print(string.format("[%s] Click event triggered", ModuleName)) end
_G["StaticPopup1Button1"]:Click() _G["StaticPopup1Button1"]:Click()
end, 1) end, 1)
end) end)
local function JoinGroup() local function JoinGroup()
if Heimdall_Data.config.commander.debug then print(string.format("%s: JoinGroup", ModuleName)) end if Heimdall_Data.config.commander.debug then print(string.format("[%s] JoinGroup command received", ModuleName)) end
groupInviteFrame:RegisterEvent("PARTY_INVITE_REQUEST") groupInviteFrame:RegisterEvent("PARTY_INVITE_REQUEST")
C_Timer.NewTimer(10, function() C_Timer.NewTimer(10, function()
groupInviteFrame:UnregisterEvent("PARTY_INVITE_REQUEST") groupInviteFrame:UnregisterEvent("PARTY_INVITE_REQUEST")
@@ -181,13 +181,13 @@ function shared.Commander.Init()
return { "+" } return { "+" }
end end
local function LeaveGroup() local function LeaveGroup()
if Heimdall_Data.config.commander.debug then print(string.format("%s: LeaveGroup", ModuleName)) end if Heimdall_Data.config.commander.debug then print(string.format("[%s] LeaveGroup command received", ModuleName)) end
LeaveParty() LeaveParty()
return {} return {}
end end
---@param target string ---@param target string
local function FollowTarget(target) local function FollowTarget(target)
if Heimdall_Data.config.commander.debug then print(string.format("%s: FollowTarget: %s", ModuleName, target)) end if Heimdall_Data.config.commander.debug then print(string.format("[%s] Following target: %s", ModuleName, target)) end
if not target then return end if not target then return end
FollowUnit(target) FollowUnit(target)
return {} return {}
@@ -213,25 +213,25 @@ function shared.Commander.Init()
commanderChannelFrame:RegisterEvent("CHAT_MSG_CHANNEL") commanderChannelFrame:RegisterEvent("CHAT_MSG_CHANNEL")
commanderChannelFrame:SetScript("OnEvent", function(self, event, msg, sender, ...) commanderChannelFrame:SetScript("OnEvent", function(self, event, msg, sender, ...)
if Heimdall_Data.config.commander.debug then if Heimdall_Data.config.commander.debug then
print(string.format("%s: OnEvent", ModuleName)) print(string.format("[%s] Event received", ModuleName))
shared.dumpTable(Heimdall_Data.config.commander) shared.dumpTable(Heimdall_Data.config.commander)
end end
if not Heimdall_Data.config.commander.enabled then return end if not Heimdall_Data.config.commander.enabled then return end
local channelId = select(6, ...) local channelId = select(6, ...)
local _, channelname = GetChannelName(channelId) local _, channelname = GetChannelName(channelId)
if Heimdall_Data.config.commander.debug then if Heimdall_Data.config.commander.debug then
print(string.format("%s: channelname = %s", ModuleName, channelname)) print(string.format("[%s] Channel received: %s", ModuleName, channelname))
end end
if channelname ~= Heimdall_Data.config.commander.masterChannel then return end if channelname ~= Heimdall_Data.config.commander.masterChannel then return end
sender = string.match(sender, "^[^-]+") sender = string.match(sender, "^[^-]+")
if Heimdall_Data.config.commander.debug then if Heimdall_Data.config.commander.debug then
print(string.format("%s: sender = %s", ModuleName, sender)) print(string.format("[%s] Message from: %s", ModuleName, sender))
end end
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.keywordRe = %s: %s", ModuleName, command.keywordRe, tostring(enabled))) print(string.format("[%s] Command match: %s = %s", ModuleName, command.keywordRe, tostring(enabled)))
end end
if enabled and if enabled and
(not command.commanderOnly (not command.commanderOnly
@@ -240,7 +240,7 @@ function shared.Commander.Init()
if msg:match(command.keywordRe) then if msg:match(command.keywordRe) then
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
print(string.format("%s: messages = %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
@@ -256,5 +256,5 @@ function shared.Commander.Init()
end end
end) end)
print("Heimdall - Commander loaded") print("[Heimdall] Commander module loaded")
end end

View File

@@ -16,106 +16,108 @@ function shared.DeathReporter.Init()
---@param spellName string ---@param spellName string
local function RegisterDeath(source, destination, spellName) local function RegisterDeath(source, destination, spellName)
if Heimdall_Data.config.deathReporter.debug then if Heimdall_Data.config.deathReporter.debug then
print(string.format("%s: RegisterDeath", ModuleName)) print(string.format("[%s] Processing death event - Source: %s, Target: %s, Spell: %s",
shared.dumpTable(Heimdall_Data.config.deathReporter) ModuleName, source, destination, spellName))
end end
if not Heimdall_Data.config.deathReporter.enabled then return end
if recentDeaths[destination] if not Heimdall_Data.config.deathReporter.enabled then
and GetTime() - recentDeaths[destination] < Heimdall_Data.config.deathReporter.throttle then
if Heimdall_Data.config.deathReporter.debug then if Heimdall_Data.config.deathReporter.debug then
print(string.format("%s: Throttled death report for %s", ModuleName, destination)) print(string.format("[%s] Module disabled, ignoring death event", ModuleName))
end end
return return
end end
if recentDuels[destination] if recentDeaths[destination] and GetTime() - recentDeaths[destination] < Heimdall_Data.config.deathReporter.throttle then
and GetTime() - recentDuels[destination] < Heimdall_Data.config.deathReporter.duelThrottle then
if Heimdall_Data.config.deathReporter.debug then if Heimdall_Data.config.deathReporter.debug then
print(string.format("Cancelling death reports for %s and %s because of recent duel", source, destination)) local timeLeft = Heimdall_Data.config.deathReporter.throttle - (GetTime() - recentDeaths[destination])
end print(string.format("[%s] Death report throttled for %s (%.1f seconds remaining)",
return ModuleName, destination, timeLeft))
end
if recentDuels[source]
and GetTime() - recentDuels[source] < Heimdall_Data.config.deathReporter.duelThrottle then
if Heimdall_Data.config.deathReporter.debug then
print(string.format("Cancelling death reports for %s and %s because of recent duel", source, destination))
end end
return return
end end
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))
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))
end
return
end
if Heimdall_Data.config.deathReporter.debug then
print(string.format("[%s] Recording death for %s", ModuleName, destination))
end
recentDeaths[destination] = GetTime() recentDeaths[destination] = GetTime()
C_Timer.NewTimer(3, function() C_Timer.NewTimer(3, function()
if recentDuels[destination] if recentDuels[destination] and GetTime() - recentDuels[destination] < Heimdall_Data.config.deathReporter.duelThrottle then
and GetTime() - recentDuels[destination] < Heimdall_Data.config.deathReporter.duelThrottle then
if Heimdall_Data.config.deathReporter.debug then if Heimdall_Data.config.deathReporter.debug then
print(string.format("Cancelling death reports for %s and %s because of recent duel", source, print(string.format("[%s] Cancelling delayed death report - Recent duel detected for: %s", ModuleName, destination))
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("Cancelling death reports for %s and %s because of recent duel", source,
destination))
end end
return return
end end
local zone = Heimdall_Data.config.deathReporter.zoneOverride if recentDuels[source] and GetTime() - recentDuels[source] < Heimdall_Data.config.deathReporter.duelThrottle then
if zone == nil or zone == "" then if Heimdall_Data.config.deathReporter.debug then
zone = string.format("%s (%s)", GetZoneText(), GetSubZoneText()) print(string.format("[%s] Cancelling delayed death report - Recent duel detected for: %s", ModuleName, source))
end end
if Heimdall_Data.config.deathReporter.debug then return
print(string.format("%s: zone = %s", ModuleName, zone))
end end
local text = string.format("%s killed %s with %s in %s",
tostring(source),
tostring(destination),
tostring(spellName),
tostring(zone))
if Heimdall_Data.config.deathReporter.debug then if Heimdall_Data.config.deathReporter.debug then
print(string.format("%s: text = %s", ModuleName, text)) print(string.format("[%s] Sending death report - %s killed %s with %s",
ModuleName, source, destination, spellName))
end end
---@type Message ---@type Message
local msg = { local msg = {
channel = "CHANNEL", channel = "CHANNEL",
data = Heimdall_Data.config.deathReporter.notifyChannel, data = Heimdall_Data.config.deathReporter.masterChannel,
message = text, message = string.format("%s killed %s with %s", source, destination, spellName)
} }
if Heimdall_Data.config.deathReporter.debug then if Heimdall_Data.config.deathReporter.debug then
print(string.format("%s: msg =", ModuleName)) print(string.format("[%s] Adding message to queue: %s", ModuleName, msg.message))
shared.dumpTable(msg)
end end
table.insert(shared.messenger.queue, msg) table.insert(shared.messenger.queue, msg)
if Heimdall_Data.config.deathReporter.doWhisper then
for _, name in pairs(Heimdall_Data.config.whisperNotify) do
local msg = {
channel = "WHISPER",
data = name,
message = text,
}
table.insert(shared.messenger.queue, msg)
end
end
end) end)
end end
local cleuFrame = CreateFrame("Frame") local cleuFrame = CreateFrame("Frame")
cleuFrame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED") cleuFrame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
cleuFrame:SetScript("OnEvent", function(self, event, ...) cleuFrame:SetScript("OnEvent", function(self, event, ...)
-- if Heimdall_Data.config.deathReporter.debug then
-- print(string.format("[%s] Received combat log event", ModuleName))
-- end
if not Heimdall_Data.config.deathReporter.enabled then return end if not Heimdall_Data.config.deathReporter.enabled then return end
local overkill, err = CLEUParser.GetOverkill(...) local overkill, err = CLEUParser.GetOverkill(...)
if not err and overkill > 0 then if not err and overkill > 0 then
local source, err = CLEUParser.GetSourceName(...) local source, err = CLEUParser.GetSourceName(...)
if err then source = "unknown" end if err then
source = "unknown"
if Heimdall_Data.config.deathReporter.debug then
print(string.format("[%s] Error getting source name", ModuleName))
end
end
local destination, err = CLEUParser.GetDestName(...) local destination, err = CLEUParser.GetDestName(...)
if err then destination = "unknown" end if err then
destination = "unknown"
if Heimdall_Data.config.deathReporter.debug then
print(string.format("[%s] Error getting destination name", ModuleName))
end
end
local spellName, err = CLEUParser.GetSpellName(...) local spellName, err = CLEUParser.GetSpellName(...)
if err then spellName = "unknown" end if err then
spellName = "unknown"
if Heimdall_Data.config.deathReporter.debug then
print(string.format("[%s] Error getting spell name", ModuleName))
end
end
local sourceGUID, err = CLEUParser.GetSourceGUID(...) local sourceGUID, err = CLEUParser.GetSourceGUID(...)
if err or not string.match(sourceGUID, "Player") then return end if err or not string.match(sourceGUID, "Player") then return end
local destinationGUID, err = CLEUParser.GetDestGUID(...) local destinationGUID, err = CLEUParser.GetDestGUID(...)
@@ -127,18 +129,66 @@ function shared.DeathReporter.Init()
local systemMessageFrame = CreateFrame("Frame") local systemMessageFrame = CreateFrame("Frame")
systemMessageFrame:RegisterEvent("CHAT_MSG_SYSTEM") systemMessageFrame:RegisterEvent("CHAT_MSG_SYSTEM")
systemMessageFrame:SetScript("OnEvent", function(self, event, msg) systemMessageFrame:SetScript("OnEvent", function(self, event, msg)
if not Heimdall_Data.config.deathReporter.enabled then return end if Heimdall_Data.config.deathReporter.debug then
local source, destination = string.match(msg, "([^ ]+) has defeated ([^ ]+) in a duel") print(string.format("[%s] Received system message: %s", ModuleName, msg))
if not source or not destination then return end
source = string.match(source, "([^-]+)")
destination = string.match(destination, "([^-]+)")
if source and destination then
print(string.format("Detected duel between %s and %s", source, destination))
local now = GetTime()
recentDuels[source] = now
recentDuels[destination] = now
end end
if not Heimdall_Data.config.deathReporter.enabled then
if Heimdall_Data.config.deathReporter.debug then
print(string.format("[%s] Module disabled, ignoring event", ModuleName))
end
return
end
if event == "DUEL_REQUESTED" then
local opponent = ...
if Heimdall_Data.config.deathReporter.debug then
print(string.format("[%s] Duel requested with: %s", ModuleName, opponent))
end
recentDuels[opponent] = GetTime()
recentDuels[UnitName("player")] = GetTime()
return
end
if event == "DUEL_FINISHED" or event == "DUEL_CANCELLED" then
if Heimdall_Data.config.deathReporter.debug then
print(string.format("[%s] Duel ended: %s", ModuleName, event))
end
return
end
local subevent = select(2, ...)
if subevent ~= "PARTY_KILL" and subevent ~= "UNIT_DIED" then return end
local source, err = CLEUParser.GetSourceName(...)
if err then
if Heimdall_Data.config.deathReporter.debug then
print(string.format("[%s] Error getting source: %s", ModuleName, err))
end
return
end
local destination, err = CLEUParser.GetDestName(...)
if err then
if Heimdall_Data.config.deathReporter.debug then
print(string.format("[%s] Error getting destination: %s", ModuleName, err))
end
return
end
if Heimdall_Data.config.deathReporter.debug then
print(string.format("[%s] Death event detected - Source: %s, Target: %s", ModuleName, source, destination))
end
local spellId = CLEUParser.GetSpellId(...)
local spellName = GetSpellInfo(spellId) or "Unknown Spell"
RegisterDeath(source, destination, spellName)
end) end)
print("Heimdall - DeathReporter loaded") if Heimdall_Data.config.deathReporter.debug then
print(string.format("[%s] Module initialized with throttle: %.1fs, duel throttle: %.1fs",
ModuleName, Heimdall_Data.config.deathReporter.throttle, Heimdall_Data.config.deathReporter.duelThrottle))
end
print("[Heimdall] DeathReporter loaded")
end end

View File

@@ -10,29 +10,41 @@ function shared.Dueler.Init()
frame:RegisterEvent("DUEL_REQUESTED") frame:RegisterEvent("DUEL_REQUESTED")
frame:SetScript("OnEvent", function(self, event, sender) frame:SetScript("OnEvent", function(self, event, sender)
if Heimdall_Data.config.dueler.debug then if Heimdall_Data.config.dueler.debug then
print(string.format("%s: OnEvent", ModuleName)) print(string.format("[%s] Duel request received from: %s", ModuleName, sender))
shared.dumpTable(Heimdall_Data.config.dueler)
end end
if not Heimdall_Data.config.dueler.enabled then return end if not Heimdall_Data.config.dueler.enabled then
if Heimdall_Data.config.dueler.debug then
print(string.format("[%s] Module disabled, ignoring duel request", ModuleName))
end
return
end
if Heimdall_Data.config.dueler.debug then if Heimdall_Data.config.dueler.debug then
print(string.format("%s: sender = %s", ModuleName, sender)) print(string.format("[%s] Checking if sender '%s' is in agents list", ModuleName, sender))
shared.dumpTable(Heimdall_Data.config.agents)
end end
local allow = Heimdall_Data.config.agents[sender] local allow = Heimdall_Data.config.agents[sender]
if allow then if allow then
if Heimdall_Data.config.dueler.debug then if Heimdall_Data.config.dueler.debug then
print(string.format("%s: Accepting duel from %s", ModuleName, sender)) print(string.format("[%s] Accepting duel from trusted agent: %s", ModuleName, sender))
end end
AcceptDuel() AcceptDuel()
else else
if Heimdall_Data.config.dueler.autoDecline then if Heimdall_Data.config.dueler.autoDecline then
if Heimdall_Data.config.dueler.debug then if Heimdall_Data.config.dueler.debug then
print(string.format("%s: Auto declining duel from %s", ModuleName, sender)) print(string.format("[%s] Auto-declining duel from untrusted sender: %s", ModuleName, sender))
end end
CancelDuel() CancelDuel()
else
if Heimdall_Data.config.dueler.debug then
print(string.format("[%s] Leaving duel request from %s for manual response", ModuleName, sender))
end
end end
end end
end) end)
print("Heimdall - Dueler loaded") if Heimdall_Data.config.dueler.debug then
print(string.format("[%s] Module initialized with auto-decline: %s", ModuleName, tostring(Heimdall_Data.config.dueler.autoDecline)))
end
print("[Heimdall] Dueler loaded")
end end

View File

@@ -10,26 +10,45 @@ function shared.Echoer.Init()
frame:RegisterEvent("CHAT_MSG_CHANNEL") frame:RegisterEvent("CHAT_MSG_CHANNEL")
frame:SetScript("OnEvent", function(self, event, msg, sender, ...) frame:SetScript("OnEvent", function(self, event, msg, sender, ...)
if Heimdall_Data.config.echoer.debug then if Heimdall_Data.config.echoer.debug then
print(string.format("%s: OnEvent", ModuleName)) print(string.format("[%s] Channel message received from: %s", ModuleName, sender))
shared.dumpTable(Heimdall_Data.config.echoer) 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
return
end end
if not Heimdall_Data.config.echoer.enabled then return end
local channelId = select(6, ...) local channelId = select(6, ...)
local _, channelname = GetChannelName(channelId) local _, channelname = GetChannelName(channelId)
if Heimdall_Data.config.echoer.debug then if Heimdall_Data.config.echoer.debug then
print(string.format("%s: channelname = %s", ModuleName, channelname)) 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
return
end end
if channelname ~= Heimdall_Data.config.echoer.masterChannel then return end
if string.find(msg, "^" .. Heimdall_Data.config.echoer.prefix) then if string.find(msg, "^" .. Heimdall_Data.config.echoer.prefix) then
if Heimdall_Data.config.echoer.debug then if Heimdall_Data.config.echoer.debug then
print(string.format("%s: msg = %s", ModuleName, msg)) print(string.format("[%s] Found echo command in message: %s", ModuleName, msg))
end end
local msg = string.sub(msg, string.len(Heimdall_Data.config.echoer.prefix) + 1) local msg = string.sub(msg, string.len(Heimdall_Data.config.echoer.prefix) + 1)
if Heimdall_Data.config.echoer.debug then
print(string.format("[%s] Echoing message: %s", ModuleName, msg))
end
SendChatMessage(msg, "SAY") SendChatMessage(msg, "SAY")
elseif Heimdall_Data.config.echoer.debug then
print(string.format("[%s] Message does not start with echo prefix", ModuleName))
end end
end) end)
print("Heimdall - Echoer loaded") if Heimdall_Data.config.echoer.debug then
print(string.format("[%s] Module initialized", ModuleName))
end
print("[Heimdall] Echoer loaded")
end end

View File

@@ -10,25 +10,45 @@ function shared.Emoter.Init()
frame:RegisterEvent("CHAT_MSG_CHANNEL") frame:RegisterEvent("CHAT_MSG_CHANNEL")
frame:SetScript("OnEvent", function(self, event, msg, sender, ...) frame:SetScript("OnEvent", function(self, event, msg, sender, ...)
if Heimdall_Data.config.emoter.debug then if Heimdall_Data.config.emoter.debug then
print(string.format("%s: OnEvent", ModuleName)) print(string.format("[%s] Channel message received from: %s", ModuleName, sender))
shared.dumpTable(Heimdall_Data.config.emoter) 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
return
end end
if not Heimdall_Data.config.emoter.enabled then return end
local channelId = select(6, ...) local channelId = select(6, ...)
local _, channelname = GetChannelName(channelId) local _, channelname = GetChannelName(channelId)
if Heimdall_Data.config.emoter.debug then if Heimdall_Data.config.emoter.debug then
print(string.format("%s: channelname = %s", ModuleName, channelname)) 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
return
end end
if channelname ~= Heimdall_Data.config.emoter.masterChannel then return end
if string.find(msg, "^" .. Heimdall_Data.config.emoter.prefix) then if string.find(msg, "^" .. Heimdall_Data.config.emoter.prefix) then
if Heimdall_Data.config.emoter.debug then if Heimdall_Data.config.emoter.debug then
print(string.format("%s: msg = %s", ModuleName, msg)) print(string.format("[%s] Found emote command in message: %s", ModuleName, msg))
end end
local emote = string.sub(msg, string.len(Heimdall_Data.config.emoter.prefix) + 1) local emote = string.sub(msg, string.len(Heimdall_Data.config.emoter.prefix) + 1)
if Heimdall_Data.config.emoter.debug then
print(string.format("[%s] Performing emote: %s", ModuleName, emote))
end
DoEmote(emote) DoEmote(emote)
elseif Heimdall_Data.config.emoter.debug then
print(string.format("[%s] Message does not start with emote prefix", ModuleName))
end end
end) end)
print("Heimdall - Emoter loaded")
if Heimdall_Data.config.emoter.debug then
print(string.format("[%s] Module initialized", ModuleName))
end
print("[Heimdall] Emoter loaded")
end end

View File

@@ -11,40 +11,53 @@ function shared.Inviter.Init()
local function FixGroup() local function FixGroup()
if Heimdall_Data.config.inviter.debug then if Heimdall_Data.config.inviter.debug then
print(string.format("%s: FixGroup", ModuleName)) print(string.format("[%s] Checking and fixing group configuration", ModuleName))
shared.dumpTable(Heimdall_Data.config.inviter)
end end
if not IsInRaid() then if not IsInRaid() then
if Heimdall_Data.config.inviter.debug then if Heimdall_Data.config.inviter.debug then
print(string.format("%s: Not in raid", ModuleName)) print(string.format("[%s] Converting party to raid", ModuleName))
end end
ConvertToRaid() ConvertToRaid()
end end
if Heimdall_Data.config.inviter.allAssist then if Heimdall_Data.config.inviter.allAssist then
if Heimdall_Data.config.inviter.debug then if Heimdall_Data.config.inviter.debug then
print(string.format("%s: Setting everyone to assistant", ModuleName)) print(string.format("[%s] Setting all members to assistant", ModuleName))
end end
SetEveryoneIsAssistant() SetEveryoneIsAssistant()
end end
if Heimdall_Data.config.inviter.agentsAssist then if Heimdall_Data.config.inviter.agentsAssist then
if Heimdall_Data.config.inviter.debug then if Heimdall_Data.config.inviter.debug then
print(string.format("%s: Setting agents to assistant", ModuleName)) local agentCount = 0
for _ in pairs(Heimdall_Data.config.agents) do agentCount = agentCount + 1 end
print(string.format("[%s] Processing %d agents for assistant promotion", ModuleName, agentCount))
end end
--shared.dumpTable(Heimdall_Data.config.agents)
for name, _ in pairs(Heimdall_Data.config.agents) do for name, _ in pairs(Heimdall_Data.config.agents) do
if UnitInParty(name) if UnitInParty(name) and not UnitIsGroupLeader(name) and not UnitIsRaidOfficer(name) then
and not UnitIsGroupLeader(name)
and not UnitIsRaidOfficer(name) then
if Heimdall_Data.config.inviter.debug then if Heimdall_Data.config.inviter.debug then
print(string.format("%s: Promoting %s to assistant", ModuleName, name)) print(string.format("[%s] Promoting agent to assistant: %s", ModuleName, name))
end end
PromoteToAssistant(name, true) PromoteToAssistant(name, true)
elseif Heimdall_Data.config.inviter.debug then
if not UnitInParty(name) then
print(string.format("[%s] Agent not in party: %s", ModuleName, name))
elseif UnitIsGroupLeader(name) then
print(string.format("[%s] Agent is already leader: %s", ModuleName, name))
elseif UnitIsRaidOfficer(name) then
print(string.format("[%s] Agent is already assistant: %s", ModuleName, name))
end
end end
end end
end end
if Heimdall_Data.config.inviter.debug then
print(string.format("[%s] Group configuration update complete", ModuleName))
end
end end
local framePool = {}
---@param name string ---@param name string
---Kicking people or othwerise people leaving will fuck up the buttons ---Kicking people or othwerise people leaving will fuck up the buttons
---We should make them reactive to GROUP_ROSTER_UPDATE ---We should make them reactive to GROUP_ROSTER_UPDATE
@@ -52,23 +65,23 @@ function shared.Inviter.Init()
---Since I'm the only one currently using this - I don't care where the buttons are ---Since I'm the only one currently using this - I don't care where the buttons are
local function OverlayKickButtonElvUI(name) local function OverlayKickButtonElvUI(name)
if Heimdall_Data.config.inviter.debug then if Heimdall_Data.config.inviter.debug then
print(string.format("%s: OverlayKickButtonElvUI", ModuleName)) print(string.format("[%s] OverlayKickButtonElvUI", ModuleName))
shared.dumpTable(Heimdall_Data.config.inviter) shared.dumpTable(Heimdall_Data.config.inviter)
end end
for group = 1, 8 do for group = 1, 8 do
for player = 1, 5 do for player = 1, 5 do
local button = _G[string.format("ElvUF_RaidGroup%dUnitButton%d", group, player)] local button = _G[string.format("ElvUF_RaidGroup%dUnitButton%d", group, player)]
if Heimdall_Data.config.inviter.debug then if Heimdall_Data.config.inviter.debug then
print(string.format("%s: button = %s", ModuleName, button)) print(string.format("[%s] button = %s", ModuleName, button))
end end
local unitName = button and button.unit and UnitName(button.unit) local unitName = button and button.unit and UnitName(button.unit)
if Heimdall_Data.config.inviter.debug then if Heimdall_Data.config.inviter.debug then
print(string.format("%s: unitName = %s", ModuleName, unitName)) print(string.format("[%s] unitName = %s", ModuleName, unitName))
end end
if unitName == name then if unitName == name then
if Heimdall_Data.config.inviter.debug then if Heimdall_Data.config.inviter.debug then
print(string.format("%s: unitName == name", ModuleName)) print(string.format("[%s] unitName == name", ModuleName))
end end
local overlayButton = framePool[button.unit] or local overlayButton = framePool[button.unit] or
CreateFrame("Button", CreateFrame("Button",
@@ -139,17 +152,23 @@ function shared.Inviter.Init()
end end
Tick() Tick()
local inviterGroupFrame = CreateFrame("Frame") local groupRosterUpdateFrame = CreateFrame("Frame")
inviterGroupFrame:RegisterEvent("GROUP_ROSTER_UPDATE") groupRosterUpdateFrame:RegisterEvent("GROUP_ROSTER_UPDATE")
inviterGroupFrame:SetScript("OnEvent", function(self, event, ...) groupRosterUpdateFrame:SetScript("OnEvent", function(self, event, ...)
if Heimdall_Data.config.inviter.debug then if Heimdall_Data.config.inviter.debug then
print(string.format("%s: OnEvent", ModuleName)) print(string.format("[%s] Event received: %s", ModuleName, event))
shared.dumpTable(Heimdall_Data.config.inviter)
print(string.format("%s: event = %s", ModuleName, UnitIsGroupLeader("player")))
end end
if not Heimdall_Data.config.inviter.enabled then return end
if not UnitIsGroupLeader("player") then return end
if not Heimdall_Data.config.inviter.enabled then
if Heimdall_Data.config.inviter.debug then
print(string.format("[%s] Module disabled, ignoring event", ModuleName))
end
return
end
if Heimdall_Data.config.inviter.debug then
print(string.format("[%s] Group roster changed - Checking configuration", ModuleName))
end
if updateTimer then updateTimer:Cancel() end if updateTimer then updateTimer:Cancel() end
updateTimer = C_Timer.NewTimer(Heimdall_Data.config.inviter.throttle, FixGroup) updateTimer = C_Timer.NewTimer(Heimdall_Data.config.inviter.throttle, FixGroup)
end) end)
@@ -157,21 +176,27 @@ function shared.Inviter.Init()
local inviterChannelFrame = CreateFrame("Frame") local inviterChannelFrame = CreateFrame("Frame")
inviterChannelFrame:RegisterEvent("CHAT_MSG_CHANNEL") inviterChannelFrame:RegisterEvent("CHAT_MSG_CHANNEL")
inviterChannelFrame:SetScript("OnEvent", function(self, event, msg, sender, ...) inviterChannelFrame:SetScript("OnEvent", function(self, event, msg, sender, ...)
if Heimdall_Data.config.inviter.debug then -- if Heimdall_Data.config.inviter.debug then
print(string.format("%s: OnEvent", ModuleName)) -- print(string.format("[%s] Chat message received: %s", ModuleName, msg))
shared.dumpTable(Heimdall_Data.config.inviter) -- shared.dumpTable(Heimdall_Data.config.inviter)
end -- end
if not Heimdall_Data.config.inviter.enabled then return end if not Heimdall_Data.config.inviter.enabled then return end
local channelId = select(6, ...) local channelId = select(6, ...)
local _, channelname = GetChannelName(channelId) local _, channelname = GetChannelName(channelId)
if channelname ~= Heimdall_Data.config.inviter.listeningChannel then return end if channelname ~= Heimdall_Data.config.inviter.listeningChannel then return end
if msg == Heimdall_Data.config.inviter.keyword then if msg == Heimdall_Data.config.inviter.keyword then
if Heimdall_Data.config.inviter.debug then if Heimdall_Data.config.inviter.debug then
print(string.format("%s: Inviting %s", ModuleName, sender)) print(string.format("[%s] Inviting %s", ModuleName, sender))
end end
InviteUnit(sender) InviteUnit(sender)
end end
end) end)
print("Heimdall - Inviter loaded") 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")
end end

View File

@@ -14,19 +14,18 @@ function shared.Macroer.Init()
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: FindOrCreateMacro", ModuleName)) print(string.format("[%s] Finding or creating macro: %s", ModuleName, macroName))
shared.dumpTable(Heimdall_Data.config.macroer)
end end
local idx = GetMacroIndexByName(macroName) local idx = GetMacroIndexByName(macroName)
if idx == 0 then if idx == 0 then
if Heimdall_Data.config.macroer.debug then if Heimdall_Data.config.macroer.debug then
print(string.format("%s: Creating macro", ModuleName)) print(string.format("[%s] Creating new macro: %s", ModuleName, macroName))
end end
CreateMacro(macroName, "INV_Misc_QuestionMark", "") CreateMacro(macroName, "INV_Misc_QuestionMark", "")
end end
idx = GetMacroIndexByName(macroName) idx = GetMacroIndexByName(macroName)
if Heimdall_Data.config.macroer.debug then if Heimdall_Data.config.macroer.debug then
print(string.format("%s: idx = %s", ModuleName, idx)) print(string.format("[%s] Macro index: %d", ModuleName, idx))
end end
return idx return idx
end end
@@ -34,15 +33,21 @@ function shared.Macroer.Init()
---@param stinkies table<string, stinky> ---@param stinkies table<string, stinky>
local function FixMacro(stinkies) local function FixMacro(stinkies)
if Heimdall_Data.config.macroer.debug then if Heimdall_Data.config.macroer.debug then
print(string.format("%s: FixMacro", ModuleName)) print(string.format("[%s] Fixing macro with %d stinkies", ModuleName, #stinkies))
shared.dumpTable(Heimdall_Data.config.macroer)
end end
if not Heimdall_Data.config.macroer.enabled then return end if not Heimdall_Data.config.macroer.enabled then
if InCombatLockdown() then return end if Heimdall_Data.config.macroer.debug then
if Heimdall_Data.config.macroer.debug then print(string.format("[%s] Module disabled, skipping macro update", ModuleName))
print(string.format("%s: InCombatLockdown", ModuleName)) end
shared.dumpTable(Heimdall_Data.config.macroer) return
end end
if InCombatLockdown() then
if Heimdall_Data.config.macroer.debug then
print(string.format("[%s] In combat, skipping macro update", ModuleName))
end
return
end
local priorityMap = {} local priorityMap = {}
for priority, className in ipairs(Heimdall_Data.config.macroer.priority) do for priority, className in ipairs(Heimdall_Data.config.macroer.priority) do
priorityMap[className] = priority priorityMap[className] = priority
@@ -56,6 +61,10 @@ function shared.Macroer.Init()
end end
end end
if Heimdall_Data.config.macroer.debug then
print(string.format("[%s] Processing %d non-agent stinkies", ModuleName, #sortedStinkies))
end
table.sort(sortedStinkies, function(a, b) table.sort(sortedStinkies, function(a, b)
local aPriority = priorityMap[a.class] or minPriority local aPriority = priorityMap[a.class] or minPriority
local bPriority = priorityMap[b.class] or minPriority local bPriority = priorityMap[b.class] or minPriority
@@ -65,23 +74,30 @@ function shared.Macroer.Init()
local lines = { "/targetenemy" } local lines = { "/targetenemy" }
for _, stinky in pairs(sortedStinkies) do for _, stinky in pairs(sortedStinkies) do
if stinky.seenAt > GetTime() - 600 then if stinky.seenAt > GetTime() - 600 then
print(string.format("Macroing %s", stinky.name)) if Heimdall_Data.config.macroer.debug then
print(string.format("[%s] Adding target macro for: %s", ModuleName, stinky.name))
end
lines[#lines + 1] = string.format("/tar %s", stinky.name) lines[#lines + 1] = string.format("/tar %s", stinky.name)
end end
end end
local idx = FindOrCreateMacro("HeimdallTarget") local idx = FindOrCreateMacro("HeimdallTarget")
local body = strjoin("\n", unpack(lines)) local body = strjoin("\n", unpack(lines))
if Heimdall_Data.config.macroer.debug then
print(string.format("[%s] Updating macro with %d lines", ModuleName, #lines))
end
EditMacro(idx, "HeimdallTarget", "INV_Misc_QuestionMark", body) EditMacro(idx, "HeimdallTarget", "INV_Misc_QuestionMark", body)
end end
shared.stinkyTracker.stinkies:onChange(function(value) shared.stinkyTracker.stinkies:onChange(function(value)
if Heimdall_Data.config.macroer.debug then if Heimdall_Data.config.macroer.debug then
print(string.format("%s: onChange", ModuleName)) print(string.format("[%s] Stinkies changed, updating macro", ModuleName))
shared.dumpTable(Heimdall_Data.config.macroer)
end end
FixMacro(value) FixMacro(value)
end) end)
print("Heimdall - Macroer loaded") if Heimdall_Data.config.macroer.debug then
print(string.format("[%s] Module initialized", ModuleName))
end
print("[Heimdall] Macroer loaded")
end end

View File

@@ -26,7 +26,7 @@ function shared.Messenger.Init()
local channelId = GetChannelName(channelName) local channelId = GetChannelName(channelName)
if channelId == 0 then if channelId == 0 then
if Heimdall_Data.config.messenger.debug then if Heimdall_Data.config.messenger.debug then
print(string.format("%s: Channel %s not found, joining", ModuleName, channelName)) print(string.format("[%s] Channel not found, joining: %s", ModuleName, channelName))
end end
if password then if password then
JoinPermanentChannel(channelName, password) JoinPermanentChannel(channelName, password)
@@ -36,7 +36,7 @@ function shared.Messenger.Init()
end end
channelId = GetChannelName(channelName) channelId = GetChannelName(channelName)
if Heimdall_Data.config.messenger.debug then if Heimdall_Data.config.messenger.debug then
print(string.format("%s: Channel %s found, id = %s", ModuleName, channelName, channelId)) print(string.format("[%s] Channel found with ID: %s (%s)", ModuleName, channelId, channelName))
end end
return channelId return channelId
end end
@@ -47,43 +47,81 @@ function shared.Messenger.Init()
if not shared.messenger.ticker then if not shared.messenger.ticker then
local function DoMessage() local function DoMessage()
if Heimdall_Data.config.messenger.debug then if Heimdall_Data.config.messenger.debug then
print(string.format("%s: DoMessage", ModuleName)) print(string.format("[%s] Processing message queue", ModuleName))
shared.dumpTable(Heimdall_Data.config.messenger) end
if not Heimdall_Data.config.messenger.enabled then
if Heimdall_Data.config.messenger.debug then
print(string.format("[%s] Module disabled, skipping message processing", ModuleName))
end
return
end end
if not Heimdall_Data.config.messenger.enabled then return end
---@type Message ---@type Message
local message = shared.messenger.queue[1] local message = shared.messenger.queue[1]
if not message then return end if not message then
if not message.message or message.message == "" then return end if Heimdall_Data.config.messenger.debug then
if not message.channel or message.channel == "" then return end print(string.format("[%s] Message queue empty", ModuleName))
end
return
end
if not message.message or message.message == "" then
if Heimdall_Data.config.messenger.debug then
print(string.format("[%s] Invalid message: empty content", ModuleName))
end
return
end
if not message.channel or message.channel == "" then
if Heimdall_Data.config.messenger.debug then
print(string.format("[%s] Invalid message: no channel specified", ModuleName))
end
return
end
if message.channel == "CHANNEL" and message.data and string.match(message.data, "%D") then if message.channel == "CHANNEL" and message.data and string.match(message.data, "%D") then
if Heimdall_Data.config.messenger.debug then if Heimdall_Data.config.messenger.debug then
print(string.format("%s: Channel presented as string: %s", ModuleName, message.data)) print(string.format("[%s] Processing channel message: '%s' to '%s'", ModuleName, message.message, message.data))
end end
local channelId = GetChannelName(message.data) local channelId = GetChannelName(message.data)
if channelId == 0 then if channelId == 0 then
if Heimdall_Data.config.messenger.debug then if Heimdall_Data.config.messenger.debug then
print(string.format("%s: Channel not found, joining %s", ModuleName, message.data)) print(string.format("[%s] Channel not found, attempting to join: %s", ModuleName, message.data))
end end
channelId = FindOrJoinChannel(message.data) channelId = FindOrJoinChannel(message.data)
end if Heimdall_Data.config.messenger.debug then
if Heimdall_Data.config.messenger.debug then print(string.format("[%s] Channel join result - ID: %s", ModuleName, channelId))
print(string.format("%s: Channel resolved to id %s", ModuleName, channelId)) end
end end
message.data = tostring(channelId) message.data = tostring(channelId)
end end
table.remove(shared.messenger.queue, 1) table.remove(shared.messenger.queue, 1)
if not message.message or message.message == "" then return end if not message.message or message.message == "" then
if not message.channel or message.channel == "" then return end if Heimdall_Data.config.messenger.debug then
if not message.data or message.data == "" then return end print(string.format("[%s] Skipping empty message", ModuleName))
end
return
end
if not message.channel or message.channel == "" then
if Heimdall_Data.config.messenger.debug then
print(string.format("[%s] Skipping message with no channel", ModuleName))
end
return
end
if not message.data or message.data == "" then
if Heimdall_Data.config.messenger.debug then
print(string.format("[%s] Skipping message with no data", ModuleName))
end
return
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))
end
SendChatMessage(message.message, message.channel, nil, message.data) SendChatMessage(message.message, message.channel, nil, message.data)
end end
local function Tick() local function Tick()
if Heimdall_Data.config.messenger.debug then if Heimdall_Data.config.messenger.debug then
print(string.format("%s: Tick", ModuleName)) local queueSize = #shared.messenger.queue
shared.dumpTable(Heimdall_Data.config.messenger) print(string.format("[%s] Queue check - Messages pending: %d", ModuleName, queueSize))
end end
DoMessage() DoMessage()
shared.messenger.ticker = C_Timer.NewTimer(Heimdall_Data.config.messenger.interval, Tick, 1) shared.messenger.ticker = C_Timer.NewTimer(Heimdall_Data.config.messenger.interval, Tick, 1)
@@ -91,14 +129,8 @@ function shared.Messenger.Init()
Tick() Tick()
end end
--C_Timer.NewTicker(2, function() if Heimdall_Data.config.messenger.debug then
-- print("Q") print(string.format("[%s] Module initialized with interval: %s", ModuleName, Heimdall_Data.config.messenger.interval))
-- table.insert(data.messenger.queue, { end
-- channel = "CHANNEL", print("[Heimdall] Messenger loaded")
-- data = "Foobar",
-- message = "TEST"
-- })
--end)
print("Heimdall - Messenger loaded")
end end

View File

@@ -29,34 +29,46 @@ function shared.Spotter.Init()
---@return string? error ---@return string? error
local function ShouldNotify(unit, name, faction, hostile) local function ShouldNotify(unit, name, faction, hostile)
if Heimdall_Data.config.spotter.debug then if Heimdall_Data.config.spotter.debug then
print(string.format("%s: ShouldNotify", ModuleName)) print(string.format("[%s] Checking notification criteria for %s (%s)", ModuleName, name, faction))
shared.dumpTable(Heimdall_Data.config.spotter)
end end
if Heimdall_Data.config.agents[name] then return false end
if Heimdall_Data.config.agents[name] then
if Heimdall_Data.config.spotter.debug then
print(string.format("[%s] Skipping agent: %s", ModuleName, name))
end
return false
end
if Heimdall_Data.config.spotter.stinky then if Heimdall_Data.config.spotter.stinky then
if Heimdall_Data.config.stinkies[name] then if Heimdall_Data.config.stinkies[name] then
if Heimdall_Data.config.spotter.debug then if Heimdall_Data.config.spotter.debug then
print(string.format("%s: Stinky found in config", ModuleName)) print(string.format("[%s] Notifying - Found stinky: %s", ModuleName, name))
end end
return true return true
end end
end end
if Heimdall_Data.config.spotter.alliance then if Heimdall_Data.config.spotter.alliance then
if faction == "Alliance" then if faction == "Alliance" then
if Heimdall_Data.config.spotter.debug then if Heimdall_Data.config.spotter.debug then
print(string.format("%s: Alliance", ModuleName)) print(string.format("[%s] Notifying - Found Alliance player: %s", ModuleName, name))
end end
return true return true
end end
end end
if Heimdall_Data.config.spotter.hostile then if Heimdall_Data.config.spotter.hostile then
if hostile then if hostile then
if Heimdall_Data.config.spotter.debug then if Heimdall_Data.config.spotter.debug then
print(string.format("%s: Hostile", ModuleName)) print(string.format("[%s] Notifying - Found hostile player: %s", ModuleName, name))
end end
return true return true
end end
end end
if Heimdall_Data.config.spotter.debug then
print(string.format("[%s] Using everyone setting: %s", ModuleName, tostring(Heimdall_Data.config.spotter.everyone)))
end
return Heimdall_Data.config.spotter.everyone return Heimdall_Data.config.spotter.everyone
end end
@@ -64,22 +76,28 @@ function shared.Spotter.Init()
---@return string? ---@return string?
local function NotifySpotted(unit) local function NotifySpotted(unit)
if Heimdall_Data.config.spotter.debug then if Heimdall_Data.config.spotter.debug then
print(string.format("%s: NotifySpotted", ModuleName)) print(string.format("[%s] Processing spotted unit: %s", ModuleName, unit))
shared.dumpTable(Heimdall_Data.config.spotter)
end end
if not unit then return string.format("Could not find unit %s", tostring(unit)) end
if not UnitIsPlayer(unit) then return nil end
if Heimdall_Data.config.spotter.debug then if not unit then return string.format("Could not find unit %s", tostring(unit)) end
print(string.format("%s: UnitIsPlayer", ModuleName)) if not UnitIsPlayer(unit) then
if Heimdall_Data.config.spotter.debug then
print(string.format("[%s] Ignoring non-player unit: %s", ModuleName, unit))
end
return nil
end end
local name = UnitName(unit) local name = UnitName(unit)
if not name then return string.format("Could not find name for unit %s", tostring(unit)) end if not name then return string.format("Could not find name for unit %s", tostring(unit)) end
if Heimdall_Data.config.spotter.debug then
print(string.format("[%s] Processing player: %s", ModuleName, name))
end
local time = GetTime() local time = GetTime()
if throttleTable[name] and time - throttleTable[name] < Heimdall_Data.config.spotter.throttleTime then if throttleTable[name] and time - throttleTable[name] < Heimdall_Data.config.spotter.throttleTime then
if Heimdall_Data.config.spotter.debug then if Heimdall_Data.config.spotter.debug then
print(string.format("%s: Throttled %s", ModuleName, tostring(name))) local remainingTime = Heimdall_Data.config.spotter.throttleTime - (time - throttleTable[name])
print(string.format("[%s] Player %s throttled for %.1f more seconds", ModuleName, name, remainingTime))
end end
return string.format("Throttled %s", tostring(name)) return string.format("Throttled %s", tostring(name))
end end
@@ -90,36 +108,32 @@ function shared.Spotter.Init()
local faction = shared.raceMap[race] local faction = shared.raceMap[race]
if not faction then return string.format("Could not find faction for race %s", tostring(race)) end if not faction then return string.format("Could not find faction for race %s", tostring(race)) end
if Heimdall_Data.config.spotter.debug then if Heimdall_Data.config.spotter.debug then
print(string.format("%s: Faction %s", ModuleName, tostring(faction))) print(string.format("[%s] Player %s is %s (%s)", ModuleName, name, race, faction))
end end
local hostile = UnitCanAttack("player", unit) local hostile = UnitCanAttack("player", unit)
if Heimdall_Data.config.spotter.debug then if Heimdall_Data.config.spotter.debug then
print(string.format("%s: Hostile %s", ModuleName, tostring(hostile))) print(string.format("[%s] Player %s is %s", ModuleName, name, hostile and "hostile" or "friendly"))
end end
local doNotify = ShouldNotify(unit, name, faction, hostile) local doNotify = ShouldNotify(unit, name, faction, hostile)
if not doNotify then return string.format("Not notifying for %s", tostring(name)) end if not doNotify then
if Heimdall_Data.config.spotter.debug then
print(string.format("[%s] Skipping notification for %s", ModuleName, name))
end
return string.format("Not notifying for %s", tostring(name))
end
local hp = UnitHealth(unit) local hp = UnitHealth(unit)
if not hp then return string.format("Could not find hp for unit %s", tostring(unit)) end if not hp then return string.format("Could not find hp for unit %s", tostring(unit)) end
if Heimdall_Data.config.spotter.debug then
print(string.format("%s: HP %s", ModuleName, tostring(hp)))
end
local maxHp = UnitHealthMax(unit) local maxHp = UnitHealthMax(unit)
if not maxHp then return string.format("Could not find maxHp for unit %s", tostring(unit)) end if not maxHp then return string.format("Could not find maxHp for unit %s", tostring(unit)) end
if Heimdall_Data.config.spotter.debug then if Heimdall_Data.config.spotter.debug then
print(string.format("%s: MaxHP %s", ModuleName, tostring(maxHp))) print(string.format("[%s] Player %s health: %s/%s", ModuleName, name, FormatHP(hp), FormatHP(maxHp)))
end end
local class = UnitClass(unit) local class = UnitClass(unit)
if not class then return string.format("Could not find class for unit %s", tostring(unit)) end if not class then return string.format("Could not find class for unit %s", tostring(unit)) end
if Heimdall_Data.config.spotter.debug then
print(string.format("%s: Class %s", ModuleName, tostring(class)))
end
local location = Heimdall_Data.config.spotter.zoneOverride local location = Heimdall_Data.config.spotter.zoneOverride
if not location or location == "" then if not location or location == "" then
@@ -128,17 +142,16 @@ function shared.Spotter.Init()
local subzone = GetSubZoneText() local subzone = GetSubZoneText()
if not subzone then subzone = "" end if not subzone then subzone = "" end
if Heimdall_Data.config.spotter.debug then if Heimdall_Data.config.spotter.debug then
print(string.format("%s: Zone %s", ModuleName, tostring(zone))) print(string.format("[%s] Player %s location: %s (%s)", ModuleName, name, zone, subzone))
print(string.format("%s: Subzone %s", ModuleName, tostring(subzone)))
end end
location = string.format("%s (%s)", zone, subzone) location = string.format("%s (%s)", zone, subzone)
end end
local x, y = GetPlayerMapPosition("player") local x, y = GetPlayerMapPosition("player")
if Heimdall_Data.config.spotter.debug then if Heimdall_Data.config.spotter.debug then
print(string.format("%s: X %s", ModuleName, tostring(x))) print(string.format("[%s] Player %s coordinates: %.2f, %.2f", ModuleName, name, x * 100, y * 100))
print(string.format("%s: Y %s", ModuleName, tostring(y)))
end end
local stinky = Heimdall_Data.config.stinkies[name] or false local stinky = Heimdall_Data.config.stinkies[name] or false
local text = string.format("I see (%s) %s/%s %s of race %s (%s) with health %s/%s at %s (%2.2f, %2.2f)", local text = string.format("I see (%s) %s/%s %s of race %s (%s) with health %s/%s at %s (%2.2f, %2.2f)",
hostile and "Hostile" or "Friendly", hostile and "Hostile" or "Friendly",
@@ -151,10 +164,10 @@ function shared.Spotter.Init()
FormatHP(maxHp), FormatHP(maxHp),
location, location,
x * 100, y * 100) x * 100, y * 100)
if Heimdall_Data.config.spotter.debug then
print(string.format("%s: Text %s", ModuleName, tostring(text)))
end
if Heimdall_Data.config.spotter.debug then
print(string.format("[%s] Sending notification: %s", ModuleName, text))
end
---@type Message ---@type Message
local msg = { local msg = {
@@ -162,10 +175,6 @@ function shared.Spotter.Init()
data = Heimdall_Data.config.spotter.notifyChannel, data = Heimdall_Data.config.spotter.notifyChannel,
message = text message = text
} }
if Heimdall_Data.config.spotter.debug then
print(string.format("%s: Inserting message into queue", ModuleName))
shared.dumpTable(msg)
end
table.insert(shared.messenger.queue, msg) table.insert(shared.messenger.queue, msg)
end end
@@ -173,15 +182,31 @@ function shared.Spotter.Init()
frame:RegisterEvent("NAME_PLATE_UNIT_ADDED") frame:RegisterEvent("NAME_PLATE_UNIT_ADDED")
frame:RegisterEvent("UNIT_TARGET") frame:RegisterEvent("UNIT_TARGET")
frame:SetScript("OnEvent", function(self, event, unit) frame:SetScript("OnEvent", function(self, event, unit)
if not Heimdall_Data.config.spotter.enabled then return end if Heimdall_Data.config.spotter.debug then
print(string.format("[%s] Event received: %s for unit: %s", ModuleName, event, unit or "target"))
end
if not Heimdall_Data.config.spotter.enabled then
if Heimdall_Data.config.spotter.debug then
print(string.format("[%s] Module disabled, ignoring event", ModuleName))
end
return
end
if event == "UNIT_TARGET" then if event == "UNIT_TARGET" then
unit = "target" unit = "target"
end end
local err = NotifySpotted(unit) local err = NotifySpotted(unit)
if err then if err then
print(string.format("Error notifying %s: %s", tostring(unit), tostring(err))) if Heimdall_Data.config.spotter.debug then
print(string.format("[%s] Error processing unit %s: %s", ModuleName, unit, err))
end
end end
end) end)
print("Heimdall - Spotter loaded") if Heimdall_Data.config.spotter.debug then
print(string.format("[%s] Module initialized", ModuleName))
end
print("[Heimdall] Spotter loaded")
end end

View File

@@ -15,7 +15,7 @@ function shared.StinkyTracker.Init()
---@return table<string, stinky> ---@return table<string, stinky>
local function ParseWho(msg) local function ParseWho(msg)
if Heimdall_Data.config.stinkyTracker.debug then if Heimdall_Data.config.stinkyTracker.debug then
print(string.format("%s: Parsing who message: %s", ModuleName, msg)) print(string.format("[%s] Parsing WHO message: '%s'", ModuleName, msg))
end end
local stinkies = {} local stinkies = {}
for name, class in string.gmatch(msg, whoRegex) do for name, class in string.gmatch(msg, whoRegex) do
@@ -26,7 +26,7 @@ function shared.StinkyTracker.Init()
hostile = true hostile = true
} }
if Heimdall_Data.config.stinkyTracker.debug then if Heimdall_Data.config.stinkyTracker.debug then
print(string.format("%s: Found stinky in who: %s/%s", ModuleName, name, class)) print(string.format("[%s] Found hostile player: %s (%s) at %s", ModuleName, name, class, date("%H:%M:%S", time())))
end end
end end
return stinkies return stinkies
@@ -37,13 +37,13 @@ function shared.StinkyTracker.Init()
---@return table<string, stinky> ---@return table<string, stinky>
local function ParseSee(msg) local function ParseSee(msg)
if Heimdall_Data.config.stinkyTracker.debug then if Heimdall_Data.config.stinkyTracker.debug then
print(string.format("%s: Parsing see message: %s", ModuleName, msg)) print(string.format("[%s] Parsing SEE message: '%s'", ModuleName, msg))
end end
local stinkies = {} local stinkies = {}
local aggression, name, class = string.match(msg, seeRegex) local aggression, name, class = string.match(msg, seeRegex)
if not name or not class then if not name or not class then
if Heimdall_Data.config.stinkyTracker.debug then if Heimdall_Data.config.stinkyTracker.debug then
print(string.format("%s: No valid stinky found in see message", ModuleName)) print(string.format("[%s] Error: Invalid SEE message format", ModuleName))
end end
return stinkies return stinkies
end end
@@ -55,7 +55,7 @@ function shared.StinkyTracker.Init()
} }
stinkies[name] = stinky stinkies[name] = stinky
if Heimdall_Data.config.stinkyTracker.debug then if Heimdall_Data.config.stinkyTracker.debug then
print(string.format("%s: Found stinky in see: %s/%s (%s)", ModuleName, name, class, aggression)) print(string.format("[%s] Found stinky in SEE: %s (%s) - %s at %s", ModuleName, name, class, aggression, date("%H:%M:%S", time())))
end end
return stinkies return stinkies
end end
@@ -96,11 +96,11 @@ function shared.StinkyTracker.Init()
frame:RegisterEvent("CHAT_MSG_CHANNEL") frame:RegisterEvent("CHAT_MSG_CHANNEL")
frame:SetScript("OnEvent", function(self, event, msg, sender, ...) frame:SetScript("OnEvent", function(self, event, msg, sender, ...)
if Heimdall_Data.config.stinkyTracker.debug then if Heimdall_Data.config.stinkyTracker.debug then
print(string.format("%s: Received event: %s", ModuleName, event)) print(string.format("[%s] Event received: %s from %s", ModuleName, event, sender))
end end
if not Heimdall_Data.config.stinkyTracker.enabled then if not Heimdall_Data.config.stinkyTracker.enabled then
if Heimdall_Data.config.stinkyTracker.debug then if Heimdall_Data.config.stinkyTracker.debug then
print(string.format("%s: StinkyTracker disabled", ModuleName)) print(string.format("[%s] Module disabled, ignoring event", ModuleName))
end end
return return
end end
@@ -108,66 +108,87 @@ function shared.StinkyTracker.Init()
local _, channelname = GetChannelName(channelId) local _, channelname = GetChannelName(channelId)
if channelname ~= Heimdall_Data.config.stinkyTracker.masterChannel then if channelname ~= Heimdall_Data.config.stinkyTracker.masterChannel then
if Heimdall_Data.config.stinkyTracker.debug then if Heimdall_Data.config.stinkyTracker.debug then
print(string.format("%s: Message not in master channel: %s", ModuleName, channelname)) print(string.format("[%s] Ignoring message from non-master channel: %s", ModuleName, channelname))
end end
return return
end end
if string.find(msg, "^who:") then if string.find(msg, "^who:") then
if Heimdall_Data.config.stinkyTracker.debug then if Heimdall_Data.config.stinkyTracker.debug then
print(string.format("%s: Processing who message", ModuleName)) print(string.format("[%s] Processing WHO message from %s", ModuleName, sender))
end end
local whoStinkies = ParseWho(msg) local whoStinkies = ParseWho(msg)
if Heimdall_Data.config.stinkyTracker.debug then
print(string.format("[%s] Found %d stinkies in WHO message", ModuleName, #whoStinkies))
end
for name, stinky in pairs(whoStinkies) do for name, stinky in pairs(whoStinkies) do
if stinky.hostile then if stinky.hostile then
shared.stinkyTracker.stinkies[name] = stinky shared.stinkyTracker.stinkies[name] = stinky
if Heimdall_Data.config.stinkyTracker.debug then if Heimdall_Data.config.stinkyTracker.debug then
print(string.format("%s: Added stinky from who: %s", ModuleName, name)) print(string.format("[%s] Added hostile stinky from WHO: %s (%s)", ModuleName, name, stinky.class))
end end
end end
end end
end end
if string.find(msg, "^I see") then if string.find(msg, "^I see") then
if Heimdall_Data.config.stinkyTracker.debug then if Heimdall_Data.config.stinkyTracker.debug then
print(string.format("%s: Processing see message", ModuleName)) print(string.format("[%s] Processing SEE message from %s", ModuleName, sender))
end end
local seeStinkies = ParseSee(msg) local seeStinkies = ParseSee(msg)
if Heimdall_Data.config.stinkyTracker.debug then
print(string.format("[%s] Found %d stinkies in SEE message", ModuleName, #seeStinkies))
end
for name, stinky in pairs(seeStinkies) do for name, stinky in pairs(seeStinkies) do
if stinky.hostile then if stinky.hostile then
shared.stinkyTracker.stinkies[name] = stinky shared.stinkyTracker.stinkies[name] = stinky
if Heimdall_Data.config.stinkyTracker.debug then if Heimdall_Data.config.stinkyTracker.debug then
print(string.format("%s: Added stinky from see: %s", ModuleName, name)) print(string.format("[%s] Added hostile stinky from SEE: %s (%s)", ModuleName, name, stinky.class))
end end
end end
if not stinky.hostile then if not stinky.hostile then
shared.stinkyTracker.stinkies[name] = nil shared.stinkyTracker.stinkies[name] = nil
if Heimdall_Data.config.stinkyTracker.debug then if Heimdall_Data.config.stinkyTracker.debug then
print(string.format("%s: Removed stinky from see: %s", ModuleName, name)) print(string.format("[%s] Removed non-hostile stinky from SEE: %s", ModuleName, name))
end end
end end
end end
end end
if string.find(msg, " and guild ") then if string.find(msg, " and guild ") then
if Heimdall_Data.config.stinkyTracker.debug then if Heimdall_Data.config.stinkyTracker.debug then
print(string.format("%s: Processing arrived message", ModuleName)) print(string.format("[%s] Processing ARRIVED message from %s", ModuleName, sender))
end end
local arrivedStinkies = ParseArrived(msg) local arrivedStinkies = ParseArrived(msg)
if Heimdall_Data.config.stinkyTracker.debug then
print(string.format("[%s] Found %d stinkies in ARRIVED message", ModuleName, #arrivedStinkies))
end
for name, stinky in pairs(arrivedStinkies) do for name, stinky in pairs(arrivedStinkies) do
shared.stinkyTracker.stinkies[name] = stinky shared.stinkyTracker.stinkies[name] = stinky
if Heimdall_Data.config.stinkyTracker.debug then if Heimdall_Data.config.stinkyTracker.debug then
print(string.format("%s: Added stinky from arrived: %s", ModuleName, name)) print(string.format("[%s] Added stinky from ARRIVED: %s (%s)", ModuleName, name, stinky.class))
end end
end end
end end
-- Log total stinky count after processing
if Heimdall_Data.config.stinkyTracker.debug then
local count = 0
for _ in pairs(shared.stinkyTracker.stinkies) do count = count + 1 end
print(string.format("[%s] Current total stinkies tracked: %d", ModuleName, count))
end
for name, stinky in pairs(shared.stinkyTracker.stinkies) do for name, stinky in pairs(shared.stinkyTracker.stinkies) do
if Heimdall_Data.config.agents[name] then if Heimdall_Data.config.agents[name] then
shared.stinkyTracker.stinkies[name] = nil shared.stinkyTracker.stinkies[name] = nil
if Heimdall_Data.config.stinkyTracker.debug then if Heimdall_Data.config.stinkyTracker.debug then
print(string.format("%s: Removed agent stinky: %s", ModuleName, name)) print(string.format("[%s] Removed agent from stinkies: %s", ModuleName, name))
end end
end end
end end
end) end)
print("Heimdall - StinkyTracker loaded") if Heimdall_Data.config.stinkyTracker.debug then
print(string.format("[%s] Module initialized", ModuleName))
end
print("[Heimdall] StinkyTracker loaded")
end end

View File

@@ -1,6 +1,7 @@
local addonname, shared = ... local addonname, shared = ...
---@cast shared HeimdallShared ---@cast shared HeimdallShared
---@cast addonname string ---@cast addonname string
local ModuleName = "Whoer"
---@diagnostic disable-next-line: missing-fields ---@diagnostic disable-next-line: missing-fields
shared.Whoer = {} shared.Whoer = {}
@@ -131,14 +132,36 @@ function shared.Whoer.Init()
---@param player Player ---@param player Player
---@return string? ---@return string?
local function Notify(player) local function Notify(player)
if not Heimdall_Data.config.who.enabled then return end if Heimdall_Data.config.who.debug then
if not player then return string.format("Cannot notify for nil player %s", tostring(player)) end 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 if not Heimdall_Data.config.who.zoneNotifyFor[player.zone] then
return string.format("Not notifying for zone %s", if Heimdall_Data.config.who.debug then
tostring(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 end
local text = player:NotifyMessage() local text = player:NotifyMessage()
if Heimdall_Data.config.who.debug then
print(string.format("[%s] Queuing channel notification: '%s'", ModuleName, text))
end
---@type Message ---@type Message
local msg = { local msg = {
channel = "CHANNEL", channel = "CHANNEL",
@@ -148,6 +171,9 @@ function shared.Whoer.Init()
table.insert(shared.messenger.queue, msg) table.insert(shared.messenger.queue, msg)
if Heimdall_Data.config.who.doWhisper then 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 for _, name in pairs(Heimdall_Data.config.whisperNotify) do
---@type Message ---@type Message
local msg = { local msg = {
@@ -155,6 +181,9 @@ function shared.Whoer.Init()
data = name, data = name,
message = text 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) table.insert(shared.messenger.queue, msg)
end end
end end
@@ -243,60 +272,98 @@ function shared.Whoer.Init()
local frame = CreateFrame("Frame") local frame = CreateFrame("Frame")
frame:RegisterEvent("WHO_LIST_UPDATE") frame:RegisterEvent("WHO_LIST_UPDATE")
frame:SetScript("OnEvent", function(self, event, ...) frame:SetScript("OnEvent", function(self, event, ...)
if not Heimdall_Data.config.who.enabled then return end if Heimdall_Data.config.who.debug then
---@type WHOQuery? print(string.format("[%s] WHO list update received", ModuleName))
local query = lastQuery end
if not query then
print("No query wtf?") 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 return
end end
for i = 1, GetNumWhoResults() do ---@type WHOQuery?
local name, guild, level, race, class, zone = GetWhoInfo(i) local query = lastQuery
local continue = false if not query then
--print(name, guild, level, race, class, zone) if Heimdall_Data.config.who.debug then
print(string.format("[%s] Error: No active WHO query found", ModuleName))
end
return
end
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[] ---@type WHOFilter[]
local filters = query.filters local filters = query.filters
for _, filter in pairs(filters) do for _, filter in pairs(filters) do
if not filter(name, guild, level, race, class, zone) then if not filter(name, guild, level, race, class, zone) then
-- Mega scuffed, yes... if Heimdall_Data.config.who.debug then
-- But wow does not have gotos print(string.format("[%s] Player %s filtered out by WHO filter", ModuleName, name))
end
continue = true continue = true
break
end end
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 if not continue then
local timestamp = date("%Y-%m-%dT%H:%M:%S") local timestamp = date("%Y-%m-%dT%H:%M:%S")
local player = HeimdallStinkies[name] local player = HeimdallStinkies[name]
if not player then 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) player = Player.new(name, guild, race, class, zone)
if not Heimdall_Data.who then Heimdall_Data.who = {} end if not Heimdall_Data.who then Heimdall_Data.who = {} end
if not Heimdall_Data.who.data then Heimdall_Data.who.data = {} end if not Heimdall_Data.who.data then Heimdall_Data.who.data = {} end
local existing = Heimdall_Data.who.data[name] local existing = Heimdall_Data.who.data[name]
if existing then 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.lastSeen = existing.lastSeen or "never"
player.firstSeen = existing.firstSeen or "never" player.firstSeen = existing.firstSeen or "never"
player.seenCount = existing.seenCount or 0 player.seenCount = existing.seenCount or 0
end end
if player.firstSeen == "never" then if player.firstSeen == "never" then
player.firstSeen = timestamp 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 end
local stinky = Heimdall_Data.config.stinkies[name] local stinky = Heimdall_Data.config.stinkies[name]
if stinky then 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 player.stinky = true
--PlaySoundFile("Interface\\Sounds\\Domination.ogg", "Master")
else
--PlaySoundFile("Interface\\Sounds\\Cloak.ogg", "Master")
end end
local err = Notify(player) local err = Notify(player)
if err then 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 end
player.lastSeen = timestamp player.lastSeen = timestamp
@@ -365,3 +432,4 @@ function shared.Whoer.Init()
print("Heimdall - Whoer loaded") print("Heimdall - Whoer loaded")
end end

8
scratch.lua Normal file
View File

@@ -0,0 +1,8 @@
print(123)
do
local test = "333"
print(test)
return nil
print("abv")
end
print(345)