Fix up the log messages a lil
Unbutcher inviter
This commit is contained in:
@@ -16,106 +16,108 @@ function shared.DeathReporter.Init()
|
||||
---@param spellName string
|
||||
local function RegisterDeath(source, destination, spellName)
|
||||
if Heimdall_Data.config.deathReporter.debug then
|
||||
print(string.format("%s: RegisterDeath", ModuleName))
|
||||
shared.dumpTable(Heimdall_Data.config.deathReporter)
|
||||
print(string.format("[%s] Processing death event - Source: %s, Target: %s, Spell: %s",
|
||||
ModuleName, source, destination, spellName))
|
||||
end
|
||||
if not Heimdall_Data.config.deathReporter.enabled then return end
|
||||
if recentDeaths[destination]
|
||||
and GetTime() - recentDeaths[destination] < Heimdall_Data.config.deathReporter.throttle then
|
||||
|
||||
if not Heimdall_Data.config.deathReporter.enabled 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
|
||||
return
|
||||
end
|
||||
|
||||
if recentDeaths[destination] and GetTime() - recentDeaths[destination] < Heimdall_Data.config.deathReporter.throttle then
|
||||
if Heimdall_Data.config.deathReporter.debug then
|
||||
local timeLeft = Heimdall_Data.config.deathReporter.throttle - (GetTime() - recentDeaths[destination])
|
||||
print(string.format("[%s] Death report throttled for %s (%.1f seconds remaining)",
|
||||
ModuleName, destination, timeLeft))
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
if recentDuels[destination]
|
||||
and GetTime() - recentDuels[destination] < Heimdall_Data.config.deathReporter.duelThrottle then
|
||||
if recentDuels[destination] and GetTime() - recentDuels[destination] < 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))
|
||||
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 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))
|
||||
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()
|
||||
|
||||
C_Timer.NewTimer(3, function()
|
||||
if recentDuels[destination]
|
||||
and GetTime() - recentDuels[destination] < Heimdall_Data.config.deathReporter.duelThrottle then
|
||||
if recentDuels[destination] and GetTime() - recentDuels[destination] < 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))
|
||||
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 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))
|
||||
print(string.format("[%s] Cancelling delayed death report - Recent duel detected for: %s", ModuleName, source))
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
local zone = Heimdall_Data.config.deathReporter.zoneOverride
|
||||
if zone == nil or zone == "" then
|
||||
zone = string.format("%s (%s)", GetZoneText(), GetSubZoneText())
|
||||
end
|
||||
if Heimdall_Data.config.deathReporter.debug then
|
||||
print(string.format("%s: zone = %s", ModuleName, zone))
|
||||
print(string.format("[%s] Sending death report - %s killed %s with %s",
|
||||
ModuleName, source, destination, spellName))
|
||||
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
|
||||
print(string.format("%s: text = %s", ModuleName, text))
|
||||
end
|
||||
|
||||
|
||||
---@type Message
|
||||
local msg = {
|
||||
channel = "CHANNEL",
|
||||
data = Heimdall_Data.config.deathReporter.notifyChannel,
|
||||
message = text,
|
||||
data = Heimdall_Data.config.deathReporter.masterChannel,
|
||||
message = string.format("%s killed %s with %s", source, destination, spellName)
|
||||
}
|
||||
if Heimdall_Data.config.deathReporter.debug then
|
||||
print(string.format("%s: msg =", ModuleName))
|
||||
shared.dumpTable(msg)
|
||||
print(string.format("[%s] Adding message to queue: %s", ModuleName, msg.message))
|
||||
end
|
||||
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
|
||||
|
||||
local cleuFrame = CreateFrame("Frame")
|
||||
cleuFrame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
|
||||
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
|
||||
local overkill, err = CLEUParser.GetOverkill(...)
|
||||
if not err and overkill > 0 then
|
||||
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(...)
|
||||
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(...)
|
||||
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(...)
|
||||
if err or not string.match(sourceGUID, "Player") then return end
|
||||
local destinationGUID, err = CLEUParser.GetDestGUID(...)
|
||||
@@ -127,18 +129,66 @@ function shared.DeathReporter.Init()
|
||||
local systemMessageFrame = CreateFrame("Frame")
|
||||
systemMessageFrame:RegisterEvent("CHAT_MSG_SYSTEM")
|
||||
systemMessageFrame:SetScript("OnEvent", function(self, event, msg)
|
||||
if not Heimdall_Data.config.deathReporter.enabled then return end
|
||||
local source, destination = string.match(msg, "([^ ]+) has defeated ([^ ]+) in a duel")
|
||||
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
|
||||
if Heimdall_Data.config.deathReporter.debug then
|
||||
print(string.format("[%s] Received system message: %s", ModuleName, msg))
|
||||
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)
|
||||
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user