Rename dumpTable to dump and make it work with any values

This commit is contained in:
2025-05-20 20:40:25 +02:00
parent 26e783ee2e
commit 8532db5a25
22 changed files with 472 additions and 467 deletions

View File

@@ -27,7 +27,7 @@ local function init()
---@field _L fun(key: string, locale: string): string ---@field _L fun(key: string, locale: string): string
---@field _Locale Localization ---@field _Locale Localization
---@field VERSION string ---@field VERSION string
---@field dumpTable fun(table: any, msg?: string, depth?: number): nil ---@field dump fun(table: any, msg?: string, depth?: number): nil
---@field utf8len fun(input: string): number ---@field utf8len fun(input: string): number
---@field padString fun(input: string, targetLength: number, left?: boolean): string ---@field padString fun(input: string, targetLength: number, left?: boolean): string
---@field GetOrDefault fun(table: table<any, any>, keys: string[], default: any): any ---@field GetOrDefault fun(table: table<any, any>, keys: string[], default: any): any

View File

@@ -22,7 +22,7 @@ shared.AgentTracker = {
-- 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 Heimdall_Data.config.agentTracker.debug then if Heimdall_Data.config.agentTracker.debug then
print(string.format("[%s] Tracking new agent: %s", ModuleName, name)) print(string.format("[%s] Tracking new agent: %s", ModuleName, name))
shared.dumpTable(shared.agentTracker.agents) shared.dump(shared.agentTracker.agents)
end end
return true return true
end, end,
@@ -137,7 +137,7 @@ shared.AgentTracker = {
if Heimdall_Data.config.agentTracker.debug then if Heimdall_Data.config.agentTracker.debug then
print(string.format("[%s] Module initialized", ModuleName)) print(string.format("[%s] Module initialized", ModuleName))
shared.dumpTable(shared.agentTracker.agents:get(), "Agents") shared.dump(shared.agentTracker.agents:get(), "Agents")
end end
print("[Heimdall] AgentTracker loaded") print("[Heimdall] AgentTracker loaded")
end, end,

View File

@@ -131,7 +131,7 @@ shared.BonkDetector = {
} }
if Heimdall_Data.config.bonkDetector.debug then if Heimdall_Data.config.bonkDetector.debug then
print(string.format("[%s] Queuing bonk detector message", ModuleName)) print(string.format("[%s] Queuing bonk detector message", ModuleName))
shared.dumpTable(message) shared.dump(message)
end end
table.insert(shared.messenger.queue, message) table.insert(shared.messenger.queue, message)
end end

View File

@@ -111,7 +111,7 @@ shared.CombatAlerter = {
} }
if Heimdall_Data.config.combatAlerter.debug then if Heimdall_Data.config.combatAlerter.debug then
print(string.format("[%s] Queuing alert message", ModuleName)) print(string.format("[%s] Queuing alert message", ModuleName))
shared.dumpTable(msg) shared.dump(msg)
end end
table.insert(shared.messenger.queue, msg) table.insert(shared.messenger.queue, msg)
end end

View File

@@ -1,387 +1,388 @@
local _, shared = ... local _, shared = ...
---@cast shared HeimdallShared ---@cast shared HeimdallShared
local ModuleName = "Commander" local ModuleName = "Commander"
---@class HeimdallCommanderConfig ---@class HeimdallCommanderConfig
---@field enabled boolean ---@field enabled boolean
---@field debug boolean ---@field debug boolean
---@field channels string[] ---@field channels string[]
---@field commander string ---@field commander string
---@field commands table<string, boolean> ---@field commands table<string, boolean>
local helpMessages = { local helpMessages = {
ru = { ru = {
"1) who - пишет вам никнеймы текущих врагов и локу.", "1) who - пишет вам никнеймы текущих врагов и локу.",
"2) classes - покажет классы врагов и число.", "2) classes - покажет классы врагов и число.",
"3) howmany - общее число врагов (дурик 4 . огри 2 ) ", "3) howmany - общее число врагов (дурик 4 . огри 2 ) ",
"4) + - атоинвайт в сбор пати и сброса кд.", "4) + - атоинвайт в сбор пати и сброса кд.",
"5) ++ -автоинвайт в пати аликов (если нужен рефрак)", "5) ++ -автоинвайт в пати аликов (если нужен рефрак)",
"6 ) note Никнейм текст - добавление заметки.", "6 ) note Никнейм текст - добавление заметки.",
"7) note Никнейм - посмотреть последние заметки.", "7) note Никнейм - посмотреть последние заметки.",
"8) note Никнейм 5 - посмотреть конкретную заметку.", "8) note Никнейм 5 - посмотреть конкретную заметку.",
"9) note Никнейм 1..5 - посмотреть заметки от 1 до 5", "9) note Никнейм 1..5 - посмотреть заметки от 1 до 5",
"10) note Никнейм delete 1 - удалить заметку номер 1", "10) note Никнейм delete 1 - удалить заметку номер 1",
"11) note Никнейм delete 1..5 - удалить заметки 1 до 5", "11) note Никнейм delete 1..5 - удалить заметки 1 до 5",
}, },
en = { en = {
"1) who - reports currently tracked stinkies in orgrimmar and durotar", "1) who - reports currently tracked stinkies in orgrimmar and durotar",
"2) classes - reports stinkies grouped by class", "2) classes - reports stinkies grouped by class",
"3) howmany - reports stinkies grouped by zone", "3) howmany - reports stinkies grouped by zone",
"4) + - automatically invites to group with duel rogue for cd reset", "4) + - automatically invites to group with duel rogue for cd reset",
"5) ++ - automatically invites to alliance group", "5) ++ - automatically invites to alliance group",
"6) note <name> <note> - adds a note for the specified character.", "6) note <name> <note> - adds a note for the specified character.",
"7) note <name> - lists the last N notes for the character.", "7) note <name> - lists the last N notes for the character.",
"8) note <name> i - lists the i-th note for the character.", "8) note <name> i - lists the i-th note for the character.",
"9) note <name> i..j - lists notes from i to j for the character.", "9) note <name> i..j - lists notes from i to j for the character.",
"10) note <name> delete i - deletes the i-th note for the character.", "10) note <name> delete i - deletes the i-th note for the character.",
"11) note <name> delete i..j - deletes notes from i to j for the character.", "11) note <name> delete i..j - deletes notes from i to j for the character.",
}, },
} }
---@class Commander ---@class Commander
shared.Commander = { shared.Commander = {
Init = function() Init = function()
---@param text string ---@param text string
---@param size number ---@param size number
---@return string[] ---@return string[]
local function Partition(text, size) local function Partition(text, size)
local words = {} local words = {}
for word in text:gmatch("[^,]+") do for word in text:gmatch("[^,]+") do
words[#words + 1] = word words[#words + 1] = word
end end
local ret = {} local ret = {}
local currentChunk = "" local currentChunk = ""
for _, word in ipairs(words) do for _, word in ipairs(words) do
if #currentChunk + #word + 1 <= size then if #currentChunk + #word + 1 <= size then
currentChunk = currentChunk .. (currentChunk == "" and word or " " .. word) currentChunk = currentChunk .. (currentChunk == "" and word or " " .. word)
else else
if #currentChunk > 0 then ret[#ret + 1] = currentChunk end if #currentChunk > 0 then ret[#ret + 1] = currentChunk end
currentChunk = word currentChunk = word
end end
end end
if #currentChunk > 0 then ret[#ret + 1] = currentChunk end if #currentChunk > 0 then ret[#ret + 1] = currentChunk end
return ret return ret
end end
---@param arr table<string, Player> ---@param arr table<string, Player>
---@return string[] ---@return string[]
local function Count(arr) local function Count(arr)
local ret = {} local ret = {}
for _, player in pairs(arr) do for _, player in pairs(arr) do
if shared.Whoer.ShouldNotifyForZone(player.zone) then ret[player.zone] = (ret[player.zone] or 0) + 1 end if shared.Whoer.ShouldNotifyForZone(player.zone) then ret[player.zone] = (ret[player.zone] or 0) + 1 end
end end
local text = {} local text = {}
for zone, count in pairs(ret) do for zone, count in pairs(ret) do
text[#text + 1] = string.format("%s: %d", zone, count) text[#text + 1] = string.format("%s: %d", zone, count)
end end
return text return text
end end
---@param arr table<string, Player> ---@param arr table<string, Player>
---@return string[] ---@return string[]
local function CountPartitioned(arr) local function CountPartitioned(arr)
local count = Count(arr) local count = Count(arr)
local text = {} local text = {}
---@diagnostic disable-next-line: param-type-mismatch something wrong with luals, it's picking up the "wrong" unpack ---@diagnostic disable-next-line: param-type-mismatch something wrong with luals, it's picking up the "wrong" unpack
for _, line in pairs(Partition(strjoin(", ", unpack(count)), 200)) do for _, line in pairs(Partition(strjoin(", ", unpack(count)), 200)) do
text[#text + 1] = line text[#text + 1] = line
end end
return text return text
end end
---@param arr table<string, Player> ---@param arr table<string, Player>
---@return string[] ---@return string[]
local function Who(arr) local function Who(arr)
local ret = {} local ret = {}
for _, player in pairs(arr) do for _, player in pairs(arr) do
if shared.Whoer.ShouldNotifyForZone(player.zone) then if shared.Whoer.ShouldNotifyForZone(player.zone) then
ret[#ret + 1] = string.format( ret[#ret + 1] = string.format(
"%s/%s (%s) %s", "%s/%s (%s) %s",
player.name, player.name,
player.class, player.class,
player.zone, player.zone,
player.stinky and "(!!!!)" or "" player.stinky and "(!!!!)" or ""
) )
end end
end end
if Heimdall_Data.config.commander.debug then if Heimdall_Data.config.commander.debug then
print(string.format("[%s] Command result: %s", ModuleName, strjoin(", ", unpack(ret)))) print(string.format("[%s] Command result: %s", ModuleName, strjoin(", ", unpack(ret))))
end end
return ret return ret
end end
---@param arr table<string, Player> ---@param arr table<string, Player>
---@return string[] ---@return string[]
local function WhoPartitioned(arr) local function WhoPartitioned(arr)
local who = Who(arr) local who = Who(arr)
local text = {} local text = {}
---@diagnostic disable-next-line: param-type-mismatch something wrong with luals, it's picking up the "wrong" unpack ---@diagnostic disable-next-line: param-type-mismatch something wrong with luals, it's picking up the "wrong" unpack
for _, line in pairs(Partition(strjoin(", ", unpack(who)), 200)) do for _, line in pairs(Partition(strjoin(", ", unpack(who)), 200)) do
text[#text + 1] = "who: " .. line text[#text + 1] = "who: " .. line
end end
return text return text
end end
---@param arr table<string, Player> ---@param arr table<string, Player>
---@return string[] ---@return string[]
local function CountClass(arr) local function CountClass(arr)
local ret = {} local ret = {}
for _, player in pairs(arr) do for _, player in pairs(arr) do
if shared.Whoer.ShouldNotifyForZone(player.zone) then if shared.Whoer.ShouldNotifyForZone(player.zone) then
ret[player.class] = (ret[player.class] or 0) + 1 ret[player.class] = (ret[player.class] or 0) + 1
end end
end end
local text = {} local text = {}
for class, count in pairs(ret) do for class, count in pairs(ret) do
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] Message text: %s", ModuleName, strjoin(", ", unpack(text)))) print(string.format("[%s] Message text: %s", ModuleName, strjoin(", ", unpack(text))))
end end
return text return text
end end
---@param arr table<string, Player> ---@param arr table<string, Player>
---@return string[] ---@return string[]
local function CountClassPartitioned(arr) local function CountClassPartitioned(arr)
local countClass = CountClass(arr) local countClass = CountClass(arr)
local text = {} local text = {}
---@diagnostic disable-next-line: param-type-mismatch something wrong with luals, it's picking up the "wrong" unpack ---@diagnostic disable-next-line: param-type-mismatch something wrong with luals, it's picking up the "wrong" unpack
for _, line in pairs(Partition(strjoin(", ", unpack(countClass)), 200)) do for _, line in pairs(Partition(strjoin(", ", unpack(countClass)), 200)) do
text[#text + 1] = line text[#text + 1] = line
end end
return text return text
end end
local function CountClassPartitionedStinkies() local function CountClassPartitionedStinkies()
if Heimdall_Data.config.commander.debug then if Heimdall_Data.config.commander.debug then
print(string.format("[%s] Executing: CountClassPartitionedStinkies", ModuleName)) print(string.format("[%s] Executing: CountClassPartitionedStinkies", ModuleName))
end end
local res = CountClassPartitioned(HeimdallStinkies) local res = CountClassPartitioned(HeimdallStinkies)
if #res == 0 then return { "No stinkies found" } end if #res == 0 then return { "No stinkies found" } end
return res return res
end end
local function WhoPartitionedStinkies() local function WhoPartitionedStinkies()
if Heimdall_Data.config.commander.debug then if Heimdall_Data.config.commander.debug then
print(string.format("[%s] Executing: WhoPartitionedStinkies", ModuleName)) print(string.format("[%s] Executing: WhoPartitionedStinkies", ModuleName))
shared.dumpTable(HeimdallStinkies) shared.dump(HeimdallStinkies)
end end
local res = WhoPartitioned(HeimdallStinkies) local res = WhoPartitioned(HeimdallStinkies)
if #res == 0 then return { "No stinkies found" } end if #res == 0 then return { "No stinkies found" } end
return res return res
end end
local function CountPartitionedStinkies() local function CountPartitionedStinkies()
if Heimdall_Data.config.commander.debug then if Heimdall_Data.config.commander.debug then
print(string.format("[%s] Executing: CountPartitionedStinkies", ModuleName)) print(string.format("[%s] Executing: CountPartitionedStinkies", ModuleName))
end end
local res = CountPartitioned(HeimdallStinkies) local res = CountPartitioned(HeimdallStinkies)
if #res == 0 then return { "No stinkies found" } end if #res == 0 then return { "No stinkies found" } end
return res return res
end end
local function HelpRu() local function HelpRu()
if Heimdall_Data.config.commander.debug then print(string.format("[%s] Executing: 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] Executing: 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] Event received", 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 if Heimdall_Data.config.commander.debug then
print(string.format("[%s] Click event triggered", ModuleName)) print(string.format("[%s] Click event triggered", ModuleName))
end 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 if Heimdall_Data.config.commander.debug then
print(string.format("[%s] JoinGroup command received", ModuleName)) print(string.format("[%s] JoinGroup command received", ModuleName))
end end
groupInviteFrame:RegisterEvent("PARTY_INVITE_REQUEST") groupInviteFrame:RegisterEvent("PARTY_INVITE_REQUEST")
C_Timer.NewTimer(10, function() groupInviteFrame:UnregisterEvent("PARTY_INVITE_REQUEST") end, 1) C_Timer.NewTimer(10, function() groupInviteFrame:UnregisterEvent("PARTY_INVITE_REQUEST") end, 1)
return { "+" } return { "+" }
end end
local function LeaveGroup() local function LeaveGroup()
if Heimdall_Data.config.commander.debug then if Heimdall_Data.config.commander.debug then
print(string.format("[%s] LeaveGroup command received", ModuleName)) print(string.format("[%s] LeaveGroup command received", ModuleName))
end 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 if Heimdall_Data.config.commander.debug then
print(string.format("[%s] Following target: %s", ModuleName, target)) print(string.format("[%s] Following target: %s", ModuleName, target))
end end
if not target then return end if not target then return end
FollowUnit(target) FollowUnit(target)
return {} return {}
end end
---@param args string[] ---@param args string[]
local function MacroTarget(args) local function MacroTarget(args)
if Heimdall_Data.config.commander.debug then if Heimdall_Data.config.commander.debug then
---@diagnostic disable-next-line: param-type-mismatch something wrong with luals, it's picking up the "wrong" unpack ---@diagnostic disable-next-line: param-type-mismatch something wrong with luals, it's picking up the "wrong" unpack
print(string.format("[%s] Macroing: %s", ModuleName, strjoin(" ", unpack(args)))) print(string.format("[%s] Macroing: %s", ModuleName, strjoin(" ", unpack(args))))
end end
if #args < 2 or #args % 2 ~= 0 then if #args < 2 or #args % 2 ~= 0 then
if #args < 2 or #args % 2 ~= 0 then if #args < 2 or #args % 2 ~= 0 then
if Heimdall_Data.config.commander.debug then if Heimdall_Data.config.commander.debug then
print(string.format("[%s] Invalid number of arguments for MacroTarget", ModuleName)) print(string.format("[%s] Invalid number of arguments for MacroTarget", ModuleName))
end end
return {} return {}
end end
end end
table.remove(args, 1) table.remove(args, 1)
for i = 1, #args do for i = 1, #args do
local stinky = strtrim(args[i]) local stinky = strtrim(args[i])
local name = stinky:match("([^/]+)") local name = stinky:match("([^/]+)")
local class = stinky:match("/([^ $]+)") local class = stinky:match("/([^ $]+)")
if Heimdall_Data.config.commander.debug then if Heimdall_Data.config.commander.debug then
print(string.format("[%s] Adding stinky: %s/%s", ModuleName, name, tostring(class))) print(string.format("[%s] Adding stinky: %s/%s", ModuleName, name, tostring(class)))
end end
shared.StinkyTracker.Track({ shared.StinkyTracker.Track({
name = name, name = name,
class = class or "unknown", class = class or "unknown",
seenAt = GetTime(), seenAt = GetTime(),
hostile = true, hostile = true,
}) })
if Heimdall_Data.config.commander.debug then if Heimdall_Data.config.commander.debug then
print(string.format("[%s] Added stinky: %s/%s", ModuleName, name, tostring(class))) print(string.format("[%s] Added stinky: %s/%s", ModuleName, name, tostring(class)))
end end
end end
return {} return {}
end end
---@param args string[] ---@param args string[]
local function IgnoreMacroTarget(args) local function IgnoreMacroTarget(args)
if Heimdall_Data.config.commander.debug then if Heimdall_Data.config.commander.debug then
---@diagnostic disable-next-line: param-type-mismatch something wrong with luals, it's picking up the "wrong" unpack ---@diagnostic disable-next-line: param-type-mismatch something wrong with luals, it's picking up the "wrong" unpack
print(string.format("[%s] Macroing: %s", ModuleName, strjoin(" ", unpack(args)))) print(string.format("[%s] Macroing: %s", ModuleName, strjoin(" ", unpack(args))))
end end
if #args < 1 then if #args < 1 then
if Heimdall_Data.config.commander.debug then if Heimdall_Data.config.commander.debug then
print(string.format("[%s] Invalid number of arguments for IgnoreMacroTarget", ModuleName)) print(string.format("[%s] Invalid number of arguments for IgnoreMacroTarget", ModuleName))
end end
return {} return {}
end end
table.remove(args, 1) table.remove(args, 1)
for i = 1, #args do for i = 1, #args do
local stinky = strtrim(args[i]) local stinky = strtrim(args[i])
local name = stinky:match("([^/]+)") local name = stinky:match("([^/]+)")
if Heimdall_Data.config.commander.debug then if Heimdall_Data.config.commander.debug then
print(string.format("[%s] Ignoring stinky: %s", ModuleName, name)) print(string.format("[%s] Ignoring stinky: %s", ModuleName, name))
end end
shared.StinkyTracker.Ignore(name) shared.StinkyTracker.Ignore(name)
end end
return {} return {}
end end
---@class Command ---@class Command
---@field keywordRe string ---@field keywordRe string
---@field commanderOnly boolean ---@field commanderOnly boolean
---@field callback fun(...: any): string[] ---@field callback fun(...: any): string[]
local commands = { local commands = {
{ keywordRe = "^who$", commanderOnly = false, callback = WhoPartitionedStinkies }, { keywordRe = "^who$", commanderOnly = false, callback = WhoPartitionedStinkies },
{ keywordRe = "^howmany$", commanderOnly = false, callback = CountPartitionedStinkies }, { keywordRe = "^howmany$", commanderOnly = false, callback = CountPartitionedStinkies },
{ keywordRe = "^classes$", commanderOnly = false, callback = CountClassPartitionedStinkies }, { keywordRe = "^classes$", commanderOnly = false, callback = CountClassPartitionedStinkies },
{ keywordRe = "^help$", commanderOnly = false, callback = HelpRu }, { keywordRe = "^help$", commanderOnly = false, callback = HelpRu },
{ keywordRe = "^helpen$", commanderOnly = false, callback = HelpEn }, { keywordRe = "^helpen$", commanderOnly = false, callback = HelpEn },
{ keywordRe = "^joingroup$", commanderOnly = false, callback = JoinGroup }, { keywordRe = "^joingroup$", commanderOnly = false, callback = JoinGroup },
{ keywordRe = "^leavegroup$", commanderOnly = false, callback = LeaveGroup }, { keywordRe = "^leavegroup$", commanderOnly = false, callback = LeaveGroup },
{ keywordRe = "^follow$", commanderOnly = false, callback = FollowTarget }, { keywordRe = "^follow$", commanderOnly = false, callback = FollowTarget },
{ keywordRe = "^macro", commanderOnly = false, callback = MacroTarget }, { keywordRe = "^macro", commanderOnly = false, callback = MacroTarget },
{ keywordRe = "^ignore", commanderOnly = false, callback = IgnoreMacroTarget }, { keywordRe = "^ignore", commanderOnly = false, callback = IgnoreMacroTarget },
} }
local commanderChannelFrame = CreateFrame("Frame") local commanderChannelFrame = CreateFrame("Frame")
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] Event received", ModuleName)) -- print(string.format("[%s] Event received", ModuleName))
-- shared.dumpTable(Heimdall_Data.config.commander) -- shared.dump(Heimdall_Data.config.commander)
--end --end
if not Heimdall_Data.config.commander.enabled then if not Heimdall_Data.config.commander.enabled then
--if Heimdall_Data.config.commander.debug then --if Heimdall_Data.config.commander.debug then
-- print(string.format("[%s] Module disabled, ignoring event", ModuleName)) -- print(string.format("[%s] Module disabled, ignoring event", ModuleName))
--end --end
return return
end end
local channelId = select(6, ...) local channelId = select(6, ...)
local _, channelname = GetChannelName(channelId) local _, channelname = GetChannelName(channelId)
local ok = false local ok = false
for _, channel in pairs(Heimdall_Data.config.commander.channels) do for _, channel in pairs(Heimdall_Data.config.commander.channels) do
if channel == channelname then if channel == channelname then
ok = true ok = true
break break
end end
end end
if not ok then if not ok then
if Heimdall_Data.config.commander.debug then if Heimdall_Data.config.commander.debug then
print( print(
string.format( string.format(
"[%s] Channel name '%s' does not match any of the channels '%s'", "[%s] Channel name '%s' does not match any of the channels '%s'",
ModuleName, ModuleName,
channelname, channelname,
table.concat(Heimdall_Data.config.commander.channels, ", ") table.concat(Heimdall_Data.config.commander.channels, ", ")
) )
) )
end end
return return
end 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] Message from: %s", ModuleName, sender)) print(string.format("[%s] Message from: %s", ModuleName, sender))
shared.dumpTable(Heimdall_Data.config.commander) shared.dump(Heimdall_Data.config.commander)
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( print(
string.format("[%s] Command match: %s = %s", ModuleName, command.keywordRe, tostring(enabled)) string.format("[%s] Command match: %s = %s", ModuleName, command.keywordRe, tostring(enabled))
) )
end end
if if
enabled enabled
and ( and (
not command.commanderOnly not command.commanderOnly
-- if Heimdall_Data.config.commander.debug then print(string.format("[%s] Ignoring command, sender %s not commander %s", ModuleName, sender, Heimdall_Data.config.commander.commander)) end -- if Heimdall_Data.config.commander.debug then print(string.format("[%s] Ignoring command, sender %s not commander %s", ModuleName, sender, Heimdall_Data.config.commander.commander)) end
or (command.commanderOnly and sender == Heimdall_Data.config.commander.commander) or (command.commanderOnly and sender == Heimdall_Data.config.commander.commander)
) )
then then
if msg:match(command.keywordRe) then if msg:match(command.keywordRe) then
---@diagnostic disable-next-line: redundant-parameter Currently luals does not support variadic functions as a @field ---@diagnostic disable-next-line: redundant-parameter Currently luals does not support variadic functions as a @field
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 to send: %s", ModuleName)) print(string.format("[%s] Messages to send: %s", ModuleName))
shared.dumpTable(messages) shared.dump(messages)
end end
for _, message in ipairs(messages) do for _, message in ipairs(messages) do
---@type Message ---@type Message
local returnmsg = { local returnmsg = {
channel = "C", channel = "C",
data = channelname, data = channelname,
message = message, message = message,
} }
if Heimdall_Data.config.commander.debug then if Heimdall_Data.config.commander.debug then
print(string.format("[%s] Queuing message", ModuleName)) print(string.format("[%s] Queuing message", ModuleName))
shared.dumpTable(msg) shared.dump(msg)
end end
--table.insert(shared.messenger.queue, msg) --table.insert(shared.messenger.queue, msg)
table.insert(shared.networkMessenger.queue, returnmsg) table.insert(shared.networkMessenger.queue, returnmsg)
end end
end end
end end
end end
end) end)
print("[Heimdall] Commander module loaded") print("[Heimdall] Commander module loaded")
end, end,
}

View File

@@ -709,7 +709,7 @@ shared.Config = {
local text = self:GetText() local text = self:GetText()
Heimdall_Data.config.spotter.channels = StringToArray(text, ",") Heimdall_Data.config.spotter.channels = StringToArray(text, ",")
print("Channels set to") print("Channels set to")
shared.dumpTable(Heimdall_Data.config.spotter.channels) shared.dump(Heimdall_Data.config.spotter.channels)
end end
) )
spotterConfigFrame:Add(channels, 2, 4) spotterConfigFrame:Add(channels, 2, 4)
@@ -809,7 +809,7 @@ shared.Config = {
local text = self:GetText() local text = self:GetText()
Heimdall_Data.config.who.channels = StringToArray(text, ",") Heimdall_Data.config.who.channels = StringToArray(text, ",")
print("Channels set to") print("Channels set to")
shared.dumpTable(Heimdall_Data.config.who.channels) shared.dump(Heimdall_Data.config.who.channels)
end end
) )
whoerConfigFrame:Add(channels, 2, 3) whoerConfigFrame:Add(channels, 2, 3)
@@ -1021,7 +1021,7 @@ shared.Config = {
local text = self:GetText() local text = self:GetText()
Heimdall_Data.config.deathReporter.channels = StringToArray(text, ",") Heimdall_Data.config.deathReporter.channels = StringToArray(text, ",")
print("Channels set to") print("Channels set to")
shared.dumpTable(Heimdall_Data.config.deathReporter.channels) shared.dump(Heimdall_Data.config.deathReporter.channels)
end end
) )
deathReporterConfigFrame:Add(channels, 2, 6) deathReporterConfigFrame:Add(channels, 2, 6)
@@ -1146,7 +1146,7 @@ shared.Config = {
local text = self:GetText() local text = self:GetText()
Heimdall_Data.config.inviter.channels = StringToArray(text, ",") Heimdall_Data.config.inviter.channels = StringToArray(text, ",")
print("Channels set to") print("Channels set to")
shared.dumpTable(Heimdall_Data.config.inviter.channels) shared.dump(Heimdall_Data.config.inviter.channels)
end end
) )
inviterConfigFrame:Add(channels, 2, 6) inviterConfigFrame:Add(channels, 2, 6)
@@ -1301,7 +1301,7 @@ shared.Config = {
local text = self:GetText() local text = self:GetText()
Heimdall_Data.config.agentTracker.channels = StringToArray(text, ",") Heimdall_Data.config.agentTracker.channels = StringToArray(text, ",")
print("Channels set to") print("Channels set to")
shared.dumpTable(Heimdall_Data.config.agentTracker.channels) shared.dump(Heimdall_Data.config.agentTracker.channels)
end end
) )
agentTrackerConfigFrame:Add(channels, 2, 6) agentTrackerConfigFrame:Add(channels, 2, 6)
@@ -1354,7 +1354,7 @@ shared.Config = {
local text = self:GetText() local text = self:GetText()
Heimdall_Data.config.stinkyTracker.channels = StringToArray(text, ",") Heimdall_Data.config.stinkyTracker.channels = StringToArray(text, ",")
print("Channels set to") print("Channels set to")
shared.dumpTable(Heimdall_Data.config.stinkyTracker.channels) shared.dump(Heimdall_Data.config.stinkyTracker.channels)
end end
) )
stinkyTrackerConfigFrame:Add(channels, 2, 6) stinkyTrackerConfigFrame:Add(channels, 2, 6)
@@ -1407,7 +1407,7 @@ shared.Config = {
local text = self:GetText() local text = self:GetText()
Heimdall_Data.config.emoter.channels = StringToArray(text, ",") Heimdall_Data.config.emoter.channels = StringToArray(text, ",")
print("Channels set to") print("Channels set to")
shared.dumpTable(Heimdall_Data.config.emoter.channels) shared.dump(Heimdall_Data.config.emoter.channels)
end end
) )
emoterConfigFrame:Add(channels, 2, 6) emoterConfigFrame:Add(channels, 2, 6)
@@ -1478,7 +1478,7 @@ shared.Config = {
local text = self:GetText() local text = self:GetText()
Heimdall_Data.config.echoer.channels = StringToArray(text, ",") Heimdall_Data.config.echoer.channels = StringToArray(text, ",")
print("Channels set to") print("Channels set to")
shared.dumpTable(Heimdall_Data.config.echoer.channels) shared.dump(Heimdall_Data.config.echoer.channels)
end end
) )
echoerConfigFrame:Add(channels, 2, 6) echoerConfigFrame:Add(channels, 2, 6)
@@ -1549,7 +1549,7 @@ shared.Config = {
local text = self:GetText() local text = self:GetText()
Heimdall_Data.config.commander.channels = StringToArray(text, ",") Heimdall_Data.config.commander.channels = StringToArray(text, ",")
print("Channels set to") print("Channels set to")
shared.dumpTable(Heimdall_Data.config.commander.channels) shared.dump(Heimdall_Data.config.commander.channels)
end end
) )
commanderConfigFrame:Add(channels, 2, 6) commanderConfigFrame:Add(channels, 2, 6)
@@ -1683,7 +1683,7 @@ shared.Config = {
local text = self:GetText() local text = self:GetText()
Heimdall_Data.config.combatAlerter.channels = StringToArray(text, ",") Heimdall_Data.config.combatAlerter.channels = StringToArray(text, ",")
print("Channels set to") print("Channels set to")
shared.dumpTable(Heimdall_Data.config.combatAlerter.channels) shared.dump(Heimdall_Data.config.combatAlerter.channels)
end end
) )
combatAlerterConfigFrame:Add(channels, 2, 6) combatAlerterConfigFrame:Add(channels, 2, 6)
@@ -1748,7 +1748,7 @@ shared.Config = {
local text = self:GetText() local text = self:GetText()
Heimdall_Data.config.sniffer.channels = StringToArray(text, ",") Heimdall_Data.config.sniffer.channels = StringToArray(text, ",")
print("Channels set to") print("Channels set to")
shared.dumpTable(Heimdall_Data.config.sniffer.channels) shared.dump(Heimdall_Data.config.sniffer.channels)
end end
) )
snifferConfigFrame:Add(channels, 2, 6) snifferConfigFrame:Add(channels, 2, 6)
@@ -1838,7 +1838,7 @@ shared.Config = {
local text = self:GetText() local text = self:GetText()
Heimdall_Data.config.bonkDetector.channels = StringToArray(text, ",") Heimdall_Data.config.bonkDetector.channels = StringToArray(text, ",")
print("Channels set to") print("Channels set to")
shared.dumpTable(Heimdall_Data.config.bonkDetector.channels) shared.dump(Heimdall_Data.config.bonkDetector.channels)
end end
) )
bonkDetectorConfigFrame:Add(channels, 2, 6) bonkDetectorConfigFrame:Add(channels, 2, 6)
@@ -1909,7 +1909,7 @@ shared.Config = {
local text = self:GetText() local text = self:GetText()
Heimdall_Data.config.minimapTagger.channels = StringToArray(text, ",") Heimdall_Data.config.minimapTagger.channels = StringToArray(text, ",")
print("Channels set to") print("Channels set to")
shared.dumpTable(Heimdall_Data.config.minimapTagger.channels) shared.dump(Heimdall_Data.config.minimapTagger.channels)
end end
) )
minimapTaggerConfigFrame:Add(channels, 2, 3) minimapTaggerConfigFrame:Add(channels, 2, 3)
@@ -2278,7 +2278,7 @@ shared.Config = {
local text = self:GetText() local text = self:GetText()
Heimdall_Data.config.noter.channels = StringToArray(text, ",") Heimdall_Data.config.noter.channels = StringToArray(text, ",")
print("Channels set to") print("Channels set to")
shared.dumpTable(Heimdall_Data.config.noter.channels) shared.dump(Heimdall_Data.config.noter.channels)
end end
) )
noterConfigFrame:Add(channels, 2, 6) noterConfigFrame:Add(channels, 2, 6)

View File

@@ -178,7 +178,7 @@ shared.DeathReporter = {
} }
if Heimdall_Data.config.deathReporter.debug then if Heimdall_Data.config.deathReporter.debug then
print(string.format("[%s] Queuing death report message", ModuleName)) print(string.format("[%s] Queuing death report message", ModuleName))
shared.dumpTable(msg) shared.dump(msg)
end end
table.insert(shared.messenger.queue, msg) table.insert(shared.messenger.queue, msg)
end end

View File

@@ -1,25 +1,29 @@
local _, shared = ... local _, shared = ...
---@cast shared HeimdallShared ---@cast shared HeimdallShared
if not shared.dumpTable then if not shared.dump then
---@param table table ---@param value any
---@param msg string? ---@param msg string?
---@param depth number? ---@param depth number?
shared.dumpTable = function(table, msg, depth) shared.dump = function(value, msg, depth)
if not table then if not value then
print(tostring(table)) print(tostring(value))
return
end
if type(value) ~= "table" then
print(tostring(value))
return return
end end
if msg then print(msg) end if msg then print(msg) end
if depth == nil then depth = 0 end if depth == nil then depth = 0 end
if depth > 200 then if depth > 200 then
print("Error: Depth > 200 in dumpTable()") print("Error: Depth > 200 in dump()")
return return
end end
for k, v in pairs(table) do for k, v in pairs(value) do
if type(v) == "table" then if type(v) == "table" then
print(string.rep(" ", depth) .. tostring(k) .. ":") print(string.rep(" ", depth) .. tostring(k) .. ":")
shared.dumpTable(v, nil, depth + 1) shared.dump(v, msg, depth + 1)
else else
print(string.rep(" ", depth) .. tostring(k) .. ": " .. tostring(v)) print(string.rep(" ", depth) .. tostring(k) .. ": " .. tostring(v))
end end

View File

@@ -42,7 +42,7 @@ shared.Echoer = {
end end
if Heimdall_Data.config.echoer.debug then if Heimdall_Data.config.echoer.debug then
print(string.format("[%s] Processing message from master channel: %s", ModuleName, sender)) print(string.format("[%s] Processing message from master channel: %s", ModuleName, sender))
shared.dumpTable(Heimdall_Data.config.echoer) shared.dump(Heimdall_Data.config.echoer)
end end
if string.find(msg, "^" .. Heimdall_Data.config.echoer.prefix) then if string.find(msg, "^" .. Heimdall_Data.config.echoer.prefix) then

View File

@@ -43,7 +43,7 @@ shared.Emoter = {
if Heimdall_Data.config.emoter.debug then if Heimdall_Data.config.emoter.debug then
print(string.format("[%s] Processing message from master channel: %s", ModuleName, sender)) print(string.format("[%s] Processing message from master channel: %s", ModuleName, sender))
shared.dumpTable(Heimdall_Data.config.emoter) shared.dump(Heimdall_Data.config.emoter)
end end
if string.find(msg, "^" .. Heimdall_Data.config.emoter.prefix) then if string.find(msg, "^" .. Heimdall_Data.config.emoter.prefix) then

View File

@@ -214,7 +214,7 @@ shared.Inviter = {
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] Chat message received: %s", ModuleName, msg)) -- print(string.format("[%s] Chat message received: %s", ModuleName, msg))
-- shared.dumpTable(Heimdall_Data.config.inviter) -- shared.dump(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, ...)

View File

@@ -67,7 +67,7 @@ shared.Macroer = {
if Heimdall_Data.config.macroer.debug then if Heimdall_Data.config.macroer.debug then
print(string.format("[%s] Sorted stinkies: %d", ModuleName, #sortedStinkies)) print(string.format("[%s] Sorted stinkies: %d", ModuleName, #sortedStinkies))
shared.dumpTable(sortedStinkies) shared.dump(sortedStinkies)
end end
local lines = { "/targetenemy" } local lines = { "/targetenemy" }
for _, stinky in pairs(sortedStinkies) do for _, stinky in pairs(sortedStinkies) do
@@ -91,7 +91,7 @@ shared.Macroer = {
shared.StinkyTracker.OnChange(function(stinkies) shared.StinkyTracker.OnChange(function(stinkies)
if Heimdall_Data.config.macroer.debug then if Heimdall_Data.config.macroer.debug then
print(string.format("[%s] Stinkies changed, updating macro", ModuleName)) print(string.format("[%s] Stinkies changed, updating macro", ModuleName))
shared.dumpTable(stinkies) shared.dump(stinkies)
end end
FixMacro(stinkies) FixMacro(stinkies)
end) end)

View File

@@ -72,18 +72,18 @@ shared.Messenger = {
return return
end end
if Heimdall_Data.config.messenger.debug then shared.dumpTable(message, "[%s] Processing message:") end if Heimdall_Data.config.messenger.debug then shared.dump(message, "[%s] Processing message:") end
if not message.message or message.message == "" then if not message.message or message.message == "" then
if Heimdall_Data.config.messenger.debug then if Heimdall_Data.config.messenger.debug then
shared.dumpTable(message, string.format("[%s] Invalid message: empty content", ModuleName)) shared.dump(message, string.format("[%s] Invalid message: empty content", ModuleName))
end end
return return
end end
if not message.channel or message.channel == "" then if not message.channel or message.channel == "" then
if Heimdall_Data.config.messenger.debug then if Heimdall_Data.config.messenger.debug then
shared.dumpTable( shared.dump(
message, message,
string.format("[%s] Invalid message: no channel specified", ModuleName) string.format("[%s] Invalid message: no channel specified", ModuleName)
) )
@@ -93,7 +93,7 @@ shared.Messenger = {
if string.find(message.channel, "^C") then if string.find(message.channel, "^C") then
if Heimdall_Data.config.messenger.debug then if Heimdall_Data.config.messenger.debug then
shared.dumpTable( shared.dump(
message, message,
string.format("[%s] Converting channel type from C to CHANNEL", ModuleName) string.format("[%s] Converting channel type from C to CHANNEL", ModuleName)
) )
@@ -101,7 +101,7 @@ shared.Messenger = {
message.channel = "CHANNEL" message.channel = "CHANNEL"
elseif string.find(message.channel, "^W") then elseif string.find(message.channel, "^W") then
if Heimdall_Data.config.messenger.debug then if Heimdall_Data.config.messenger.debug then
shared.dumpTable( shared.dump(
message, message,
string.format("[%s] Converting channel type from W to WHISPER", ModuleName) string.format("[%s] Converting channel type from W to WHISPER", ModuleName)
) )
@@ -111,12 +111,12 @@ shared.Messenger = {
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
shared.dumpTable(message, string.format("[%s] Processing channel message:", ModuleName)) shared.dump(message, string.format("[%s] Processing channel message:", ModuleName))
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
shared.dumpTable(message, string.format("[%s] Channel not found, joining:", ModuleName)) shared.dump(message, string.format("[%s] Channel not found, joining:", ModuleName))
end end
channelId = FindOrJoinChannel(message.data) channelId = FindOrJoinChannel(message.data)
if Heimdall_Data.config.messenger.debug then if Heimdall_Data.config.messenger.debug then
@@ -129,28 +129,28 @@ shared.Messenger = {
table.remove(shared.messenger.queue, 1) table.remove(shared.messenger.queue, 1)
if not message.message or message.message == "" then if not message.message or message.message == "" then
if Heimdall_Data.config.messenger.debug then if Heimdall_Data.config.messenger.debug then
shared.dumpTable(message, string.format("[%s] Skipping empty message", ModuleName)) shared.dump(message, string.format("[%s] Skipping empty message", ModuleName))
end end
return return
end end
if not message.channel or message.channel == "" then if not message.channel or message.channel == "" then
if Heimdall_Data.config.messenger.debug then if Heimdall_Data.config.messenger.debug then
shared.dumpTable(message, string.format("[%s] Skipping message with no channel", ModuleName)) shared.dump(message, string.format("[%s] Skipping message with no channel", ModuleName))
end end
return return
end end
if not message.data or message.data == "" then if not message.data or message.data == "" then
if Heimdall_Data.config.messenger.debug then if Heimdall_Data.config.messenger.debug then
shared.dumpTable(message, string.format("[%s] Skipping message with no data", ModuleName)) shared.dump(message, string.format("[%s] Skipping message with no data", ModuleName))
end end
return return
end end
if Heimdall_Data.config.messenger.debug then if Heimdall_Data.config.messenger.debug then
shared.dumpTable(message, string.format("[%s] Sending message:", ModuleName)) shared.dump(message, string.format("[%s] Sending message:", ModuleName))
end end
if string.len(message.message) > 255 then if string.len(message.message) > 255 then
shared.dumpTable( shared.dump(
message, message,
string.format("[%s] Message too long!!!!: %s", ModuleName, message.message) string.format("[%s] Message too long!!!!: %s", ModuleName, message.message)
) )

View File

@@ -473,7 +473,7 @@ shared.MinimapTagger = {
end end
if Heimdall_Data.config.minimapTagger.debug then if Heimdall_Data.config.minimapTagger.debug then
print(string.format("[%s] Processing message from master channel: %s", ModuleName, sender)) print(string.format("[%s] Processing message from master channel: %s", ModuleName, sender))
shared.dumpTable(Heimdall_Data.config.minimapTagger) shared.dump(Heimdall_Data.config.minimapTagger)
end end
local doTag = true local doTag = true

View File

@@ -61,7 +61,7 @@ shared.Network = {
end end
if Heimdall_Data.config.network.debug then if Heimdall_Data.config.network.debug then
print(string.format("[%s] Network nodes:", ModuleName)) print(string.format("[%s] Network nodes:", ModuleName))
shared.dumpTable(shared.networkNodes) shared.dump(shared.networkNodes)
end end
end end

View File

@@ -143,7 +143,7 @@ shared.NetworkMessenger = {
local parts = shared.Split(message, "|") local parts = shared.Split(message, "|")
if Heimdall_Data.config.networkMessenger.debug then if Heimdall_Data.config.networkMessenger.debug then
print(string.format("[%s] Received message parts:", ModuleName)) print(string.format("[%s] Received message parts:", ModuleName))
shared.dumpTable(parts) shared.dump(parts)
end end
local command = strtrim(parts[1]) local command = strtrim(parts[1])
if command == "message" then if command == "message" then

View File

@@ -67,7 +67,7 @@ shared.Noter = {
local indices = shared.Split(range, "..") local indices = shared.Split(range, "..")
if Heimdall_Data.config.noter.debug then if Heimdall_Data.config.noter.debug then
print(string.format("[%s] Indices for range deletion: %s", ModuleName, table.concat(indices, ", "))) print(string.format("[%s] Indices for range deletion: %s", ModuleName, table.concat(indices, ", ")))
shared.dumpTable(indices) shared.dump(indices)
end end
local start = tonumber(indices[1]) local start = tonumber(indices[1])
local finish = tonumber(indices[2]) local finish = tonumber(indices[2])
@@ -98,7 +98,7 @@ shared.Noter = {
else else
if Heimdall_Data.config.noter.debug then if Heimdall_Data.config.noter.debug then
print(string.format("[%s] Deleting note %s at index %s", ModuleName, name, i)) print(string.format("[%s] Deleting note %s at index %s", ModuleName, name, i))
shared.dumpTable(Heimdall_Data.config.notes[name][i]) shared.dump(Heimdall_Data.config.notes[name][i])
end end
Heimdall_Data.config.notes[name][i] = nil Heimdall_Data.config.notes[name][i] = nil
end end
@@ -159,7 +159,7 @@ shared.Noter = {
local indices = shared.Split(range, "..") local indices = shared.Split(range, "..")
if Heimdall_Data.config.noter.debug then if Heimdall_Data.config.noter.debug then
print(string.format("[%s] Indices for range printing: %s", ModuleName, table.concat(indices, ", "))) print(string.format("[%s] Indices for range printing: %s", ModuleName, table.concat(indices, ", ")))
shared.dumpTable(indices) shared.dump(indices)
end end
local start = tonumber(indices[1]) local start = tonumber(indices[1])
local finish = tonumber(indices[2]) local finish = tonumber(indices[2])
@@ -185,7 +185,7 @@ shared.Noter = {
else else
if Heimdall_Data.config.noter.debug then if Heimdall_Data.config.noter.debug then
print(string.format("[%s] Printing note %s at index %s", ModuleName, name, i)) print(string.format("[%s] Printing note %s at index %s", ModuleName, name, i))
shared.dumpTable(Heimdall_Data.config.notes[name][i]) shared.dump(Heimdall_Data.config.notes[name][i])
end end
PrintNote(channel, i, Heimdall_Data.config.notes[name][i]) PrintNote(channel, i, Heimdall_Data.config.notes[name][i])
end end
@@ -200,7 +200,7 @@ shared.Noter = {
if not Heimdall_Data.config.notes[name] then Heimdall_Data.config.notes[name] = {} end if not Heimdall_Data.config.notes[name] then Heimdall_Data.config.notes[name] = {} end
if Heimdall_Data.config.noter.debug then if Heimdall_Data.config.noter.debug then
print(string.format("[%s] Adding note for: %s from: %s", ModuleName, name, sender)) print(string.format("[%s] Adding note for: %s from: %s", ModuleName, name, sender))
shared.dumpTable(args) shared.dump(args)
end end
local msgparts = {} local msgparts = {}
for i = 3, #args do for i = 3, #args do
@@ -221,7 +221,7 @@ shared.Noter = {
if Heimdall_Data.config.noter.debug then if Heimdall_Data.config.noter.debug then
print(string.format("[%s] Adding note", ModuleName)) print(string.format("[%s] Adding note", ModuleName))
shared.dumpTable(note) shared.dump(note)
end end
table.insert(Heimdall_Data.config.notes[name], note) table.insert(Heimdall_Data.config.notes[name], note)
end end
@@ -239,7 +239,7 @@ shared.Noter = {
noterChannelFrame:SetScript("OnEvent", function(self, event, msg, sender, ...) noterChannelFrame:SetScript("OnEvent", function(self, event, msg, sender, ...)
--if Heimdall_Data.config.noter.debug then --if Heimdall_Data.config.noter.debug then
-- print(string.format("[%s] Event received", ModuleName)) -- print(string.format("[%s] Event received", ModuleName))
-- shared.dumpTable(Heimdall_Data.config.noter) -- shared.dump(Heimdall_Data.config.noter)
--end --end
if not Heimdall_Data.config.noter.enabled then if not Heimdall_Data.config.noter.enabled then
--if Heimdall_Data.config.noter.debug then --if Heimdall_Data.config.noter.debug then
@@ -266,7 +266,7 @@ shared.Noter = {
sender = string.match(sender, "^[^-]+") sender = string.match(sender, "^[^-]+")
if Heimdall_Data.config.noter.debug then if Heimdall_Data.config.noter.debug then
print(string.format("[%s] Message from: %s", ModuleName, sender)) print(string.format("[%s] Message from: %s", ModuleName, sender))
shared.dumpTable(Heimdall_Data.config.noter) shared.dump(Heimdall_Data.config.noter)
end end
if not msg or msg == "" then if not msg or msg == "" then
@@ -279,7 +279,7 @@ shared.Noter = {
local args = { strsplit(" ", msg) } local args = { strsplit(" ", msg) }
if Heimdall_Data.config.noter.debug then if Heimdall_Data.config.noter.debug then
print(string.format("[%s] Arguments received: %s", ModuleName, table.concat(args, ", "))) print(string.format("[%s] Arguments received: %s", ModuleName, table.concat(args, ", ")))
shared.dumpTable(args) shared.dump(args)
end end
local command = args[1] local command = args[1]
if command == "note" then if command == "note" then

View File

@@ -483,7 +483,7 @@ local function Init()
-- S local clbk = test:onChange(function(value) -- S local clbk = test:onChange(function(value)
-- S invocations = invocations + 1 -- S invocations = invocations + 1
-- S print("test changed to") -- S print("test changed to")
-- S dumpTable(value, 0) -- S dump(value, 0)
-- S end) -- S end)
-- S test:set({1, 2, 3, 4}) -- S test:set({1, 2, 3, 4})
-- S assert(invocations == 1) -- S assert(invocations == 1)
@@ -516,7 +516,7 @@ local function Init()
-- S test:once(function(value) -- S test:once(function(value)
-- S invocations = invocations + 1 -- S invocations = invocations + 1
-- S print("test changed to") -- S print("test changed to")
-- S dumpTable(value, 0) -- S dump(value, 0)
-- S end) -- S end)
-- S test:set({3, 2, 1}) -- S test:set({3, 2, 1})
-- S assert(invocations == 1) -- S assert(invocations == 1)
@@ -527,7 +527,7 @@ local function Init()
-- S test:onChange(function(value) -- S test:onChange(function(value)
-- S invocations = invocations + 1 -- S invocations = invocations + 1
-- S print("test changed to") -- S print("test changed to")
-- S dumpTable(value, 0) -- S dump(value, 0)
-- S end) -- S end)
-- S test:onAnyFieldChange(function(field, value) -- S test:onAnyFieldChange(function(field, value)
-- S invocations = invocations + 1 -- S invocations = invocations + 1

View File

@@ -18,7 +18,7 @@ shared.Sniffer = {
local SmellStinky = function(stinky) local SmellStinky = function(stinky)
if Heimdall_Data.config.sniffer.debug then if Heimdall_Data.config.sniffer.debug then
print(string.format("%s: SmellStinky", ModuleName)) print(string.format("%s: SmellStinky", ModuleName))
shared.dumpTable(Heimdall_Data.config.sniffer) shared.dump(Heimdall_Data.config.sniffer)
end end
if not Heimdall_Data.config.sniffer.enabled then return end if not Heimdall_Data.config.sniffer.enabled then return end
if Heimdall_Data.config.sniffer.stinky and not shared.IsStinky(stinky) then if Heimdall_Data.config.sniffer.stinky and not shared.IsStinky(stinky) then
@@ -44,7 +44,7 @@ shared.Sniffer = {
} }
if Heimdall_Data.config.sniffer.debug then if Heimdall_Data.config.sniffer.debug then
print(string.format("[%s] Queuing sniffer message", ModuleName)) print(string.format("[%s] Queuing sniffer message", ModuleName))
shared.dumpTable(msg) shared.dump(msg)
end end
table.insert(shared.messenger.queue, msg) table.insert(shared.messenger.queue, msg)
end end

View File

@@ -201,7 +201,7 @@ shared.Spotter = {
} }
if Heimdall_Data.config.spotter.debug then if Heimdall_Data.config.spotter.debug then
print(string.format("[%s] Queuing spotter message", ModuleName)) print(string.format("[%s] Queuing spotter message", ModuleName))
shared.dumpTable(msg) shared.dump(msg)
end end
table.insert(shared.messenger.queue, msg) table.insert(shared.messenger.queue, msg)
end end

View File

@@ -38,8 +38,8 @@ shared.StinkyTracker = {
stinky.class stinky.class
) )
) )
shared.dumpTable(shared.stinkyTracker.ignored:get()) shared.dump(shared.stinkyTracker.ignored:get())
shared.dumpTable(shared.stinkyTracker.stinkies:get()) shared.dump(shared.stinkyTracker.stinkies:get())
end end
return false return false
else else
@@ -50,8 +50,8 @@ shared.StinkyTracker = {
shared.stinkyTracker.stinkies[stinky.name] = stinky shared.stinkyTracker.stinkies[stinky.name] = stinky
if Heimdall_Data.config.stinkyTracker.debug then if Heimdall_Data.config.stinkyTracker.debug then
print(string.format("[%s] Stinky is now tracked: %s (%s)", ModuleName, stinky.name, stinky.class)) print(string.format("[%s] Stinky is now tracked: %s (%s)", ModuleName, stinky.name, stinky.class))
shared.dumpTable(shared.stinkyTracker.stinkies:get()) shared.dump(shared.stinkyTracker.stinkies:get())
shared.dumpTable(shared.stinkyTracker.ignored:get()) shared.dump(shared.stinkyTracker.ignored:get())
end end
return true return true
end, end,
@@ -66,8 +66,8 @@ shared.StinkyTracker = {
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] Stinky is now ignored: %s", ModuleName, name)) print(string.format("[%s] Stinky is now ignored: %s", ModuleName, name))
shared.dumpTable(shared.stinkyTracker.ignored:get()) shared.dump(shared.stinkyTracker.ignored:get())
shared.dumpTable(shared.stinkyTracker.stinkies:get()) shared.dump(shared.stinkyTracker.stinkies:get())
end end
end, end,
@@ -125,7 +125,7 @@ shared.StinkyTracker = {
date("%H:%M:%S", time()) date("%H:%M:%S", time())
) )
) )
shared.dumpTable(stinkies) shared.dump(stinkies)
end end
end end
return stinkies return stinkies
@@ -164,7 +164,7 @@ shared.StinkyTracker = {
date("%H:%M:%S", time()) date("%H:%M:%S", time())
) )
) )
shared.dumpTable(stinkies) shared.dump(stinkies)
end end
return stinkies return stinkies
end end
@@ -197,7 +197,7 @@ shared.StinkyTracker = {
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 arrived: %s/%s", ModuleName, name, class)) print(string.format("%s: Found stinky in arrived: %s/%s", ModuleName, name, class))
shared.dumpTable(stinkies) shared.dump(stinkies)
end end
return stinkies return stinkies
end end
@@ -231,7 +231,7 @@ shared.StinkyTracker = {
end end
if Heimdall_Data.config.stinkyTracker.debug then if Heimdall_Data.config.stinkyTracker.debug then
print(string.format("[%s] Processing message from master channel: %s", ModuleName, sender)) print(string.format("[%s] Processing message from master channel: %s", ModuleName, sender))
shared.dumpTable(Heimdall_Data.config.stinkyTracker) shared.dump(Heimdall_Data.config.stinkyTracker)
end end
local stinkies = {} local stinkies = {}
@@ -242,7 +242,7 @@ shared.StinkyTracker = {
local whoStinkies = ParseWho(msg) local whoStinkies = ParseWho(msg)
if Heimdall_Data.config.stinkyTracker.debug then if Heimdall_Data.config.stinkyTracker.debug then
print(string.format("[%s] Found stinkies in WHO message", ModuleName)) print(string.format("[%s] Found stinkies in WHO message", ModuleName))
shared.dumpTable(whoStinkies) shared.dump(whoStinkies)
end end
for name, stinky in pairs(whoStinkies) do for name, stinky in pairs(whoStinkies) do
stinkies[name] = stinky stinkies[name] = stinky
@@ -255,7 +255,7 @@ shared.StinkyTracker = {
local seeStinkies = ParseSee(msg) local seeStinkies = ParseSee(msg)
if Heimdall_Data.config.stinkyTracker.debug then if Heimdall_Data.config.stinkyTracker.debug then
print(string.format("[%s] Found stinkies in SEE message", ModuleName)) print(string.format("[%s] Found stinkies in SEE message", ModuleName))
shared.dumpTable(seeStinkies) shared.dump(seeStinkies)
end end
for name, stinky in pairs(seeStinkies) do for name, stinky in pairs(seeStinkies) do
stinkies[name] = stinky stinkies[name] = stinky
@@ -268,7 +268,7 @@ shared.StinkyTracker = {
local arrivedStinkies = ParseArrived(msg) local arrivedStinkies = ParseArrived(msg)
if Heimdall_Data.config.stinkyTracker.debug then if Heimdall_Data.config.stinkyTracker.debug then
print(string.format("[%s] Found stinkies in ARRIVED message", ModuleName)) print(string.format("[%s] Found stinkies in ARRIVED message", ModuleName))
shared.dumpTable(arrivedStinkies) shared.dump(arrivedStinkies)
end end
for name, stinky in pairs(arrivedStinkies) do for name, stinky in pairs(arrivedStinkies) do
stinkies[name] = stinky stinkies[name] = stinky

View File

@@ -176,7 +176,7 @@ shared.Whoer = {
if Heimdall_Data.config.who.debug then if Heimdall_Data.config.who.debug then
print(string.format("[%s] WHO query: %s with %d filters", ModuleName, queryParts[1], #filters)) print(string.format("[%s] WHO query: %s with %d filters", ModuleName, queryParts[1], #filters))
end end
shared.dumpTable(filters) shared.dump(filters)
return WHOQuery.new(queryParts[1], filters) return WHOQuery.new(queryParts[1], filters)
end, end,
---@param queryStr string ---@param queryStr string
@@ -321,7 +321,7 @@ shared.Whoer = {
} }
if Heimdall_Data.config.who.debug then if Heimdall_Data.config.who.debug then
print(string.format("[%s] Queuing channel notification", ModuleName)) print(string.format("[%s] Queuing channel notification", ModuleName))
shared.dumpTable(msg) shared.dump(msg)
end end
table.insert(shared.networkMessenger.queue, msg) table.insert(shared.networkMessenger.queue, msg)
end end
@@ -380,7 +380,7 @@ shared.Whoer = {
} }
if Heimdall_Data.config.who.debug then if Heimdall_Data.config.who.debug then
print(string.format("[%s] Queuing channel notification", ModuleName)) print(string.format("[%s] Queuing channel notification", ModuleName))
shared.dumpTable(msg) shared.dump(msg)
end end
table.insert(shared.networkMessenger.queue, msg) table.insert(shared.networkMessenger.queue, msg)
end end
@@ -431,7 +431,7 @@ shared.Whoer = {
} }
if Heimdall_Data.config.who.debug then if Heimdall_Data.config.who.debug then
print(string.format("[%s] Queuing channel notification", ModuleName)) print(string.format("[%s] Queuing channel notification", ModuleName))
shared.dumpTable(msg) shared.dump(msg)
end end
--table.insert(shared.messenger.queue, msg) --table.insert(shared.messenger.queue, msg)
table.insert(shared.networkMessenger.queue, msg) table.insert(shared.networkMessenger.queue, msg)