Rename dumpTable to dump and make it work with any values
This commit is contained in:
@@ -27,7 +27,7 @@ local function init()
|
||||
---@field _L fun(key: string, locale: string): string
|
||||
---@field _Locale Localization
|
||||
---@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 padString fun(input: string, targetLength: number, left?: boolean): string
|
||||
---@field GetOrDefault fun(table: table<any, any>, keys: string[], default: any): any
|
||||
|
||||
@@ -22,7 +22,7 @@ shared.AgentTracker = {
|
||||
-- Heimdall_Data.config.agents[name] = date("%Y-%m-%dT%H:%M:%S")
|
||||
if Heimdall_Data.config.agentTracker.debug then
|
||||
print(string.format("[%s] Tracking new agent: %s", ModuleName, name))
|
||||
shared.dumpTable(shared.agentTracker.agents)
|
||||
shared.dump(shared.agentTracker.agents)
|
||||
end
|
||||
return true
|
||||
end,
|
||||
@@ -137,7 +137,7 @@ shared.AgentTracker = {
|
||||
|
||||
if Heimdall_Data.config.agentTracker.debug then
|
||||
print(string.format("[%s] Module initialized", ModuleName))
|
||||
shared.dumpTable(shared.agentTracker.agents:get(), "Agents")
|
||||
shared.dump(shared.agentTracker.agents:get(), "Agents")
|
||||
end
|
||||
print("[Heimdall] AgentTracker loaded")
|
||||
end,
|
||||
|
||||
@@ -131,7 +131,7 @@ shared.BonkDetector = {
|
||||
}
|
||||
if Heimdall_Data.config.bonkDetector.debug then
|
||||
print(string.format("[%s] Queuing bonk detector message", ModuleName))
|
||||
shared.dumpTable(message)
|
||||
shared.dump(message)
|
||||
end
|
||||
table.insert(shared.messenger.queue, message)
|
||||
end
|
||||
|
||||
@@ -111,7 +111,7 @@ shared.CombatAlerter = {
|
||||
}
|
||||
if Heimdall_Data.config.combatAlerter.debug then
|
||||
print(string.format("[%s] Queuing alert message", ModuleName))
|
||||
shared.dumpTable(msg)
|
||||
shared.dump(msg)
|
||||
end
|
||||
table.insert(shared.messenger.queue, msg)
|
||||
end
|
||||
|
||||
@@ -1,387 +1,388 @@
|
||||
local _, shared = ...
|
||||
---@cast shared HeimdallShared
|
||||
local ModuleName = "Commander"
|
||||
|
||||
---@class HeimdallCommanderConfig
|
||||
---@field enabled boolean
|
||||
---@field debug boolean
|
||||
---@field channels string[]
|
||||
---@field commander string
|
||||
---@field commands table<string, boolean>
|
||||
|
||||
local helpMessages = {
|
||||
ru = {
|
||||
"1) who - пишет вам никнеймы текущих врагов и локу.",
|
||||
"2) classes - покажет классы врагов и число.",
|
||||
"3) howmany - общее число врагов (дурик 4 . огри 2 ) ",
|
||||
"4) + - атоинвайт в сбор пати и сброса кд.",
|
||||
"5) ++ -автоинвайт в пати аликов (если нужен рефрак)",
|
||||
"6 ) note Никнейм текст - добавление заметки.",
|
||||
"7) note Никнейм - посмотреть последние заметки.",
|
||||
"8) note Никнейм 5 - посмотреть конкретную заметку.",
|
||||
"9) note Никнейм 1..5 - посмотреть заметки от 1 до 5",
|
||||
"10) note Никнейм delete 1 - удалить заметку номер 1",
|
||||
"11) note Никнейм delete 1..5 - удалить заметки 1 до 5",
|
||||
},
|
||||
en = {
|
||||
"1) who - reports currently tracked stinkies in orgrimmar and durotar",
|
||||
"2) classes - reports stinkies grouped by class",
|
||||
"3) howmany - reports stinkies grouped by zone",
|
||||
"4) + - automatically invites to group with duel rogue for cd reset",
|
||||
"5) ++ - automatically invites to alliance group",
|
||||
"6) note <name> <note> - adds a note for the specified character.",
|
||||
"7) note <name> - lists the last N notes 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.",
|
||||
"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.",
|
||||
},
|
||||
}
|
||||
|
||||
---@class Commander
|
||||
shared.Commander = {
|
||||
Init = function()
|
||||
---@param text string
|
||||
---@param size number
|
||||
---@return string[]
|
||||
local function Partition(text, size)
|
||||
local words = {}
|
||||
for word in text:gmatch("[^,]+") do
|
||||
words[#words + 1] = word
|
||||
end
|
||||
|
||||
local ret = {}
|
||||
local currentChunk = ""
|
||||
|
||||
for _, word in ipairs(words) do
|
||||
if #currentChunk + #word + 1 <= size then
|
||||
currentChunk = currentChunk .. (currentChunk == "" and word or " " .. word)
|
||||
else
|
||||
if #currentChunk > 0 then ret[#ret + 1] = currentChunk end
|
||||
currentChunk = word
|
||||
end
|
||||
end
|
||||
|
||||
if #currentChunk > 0 then ret[#ret + 1] = currentChunk end
|
||||
|
||||
return ret
|
||||
end
|
||||
---@param arr table<string, Player>
|
||||
---@return string[]
|
||||
local function Count(arr)
|
||||
local ret = {}
|
||||
for _, player in pairs(arr) do
|
||||
if shared.Whoer.ShouldNotifyForZone(player.zone) then ret[player.zone] = (ret[player.zone] or 0) + 1 end
|
||||
end
|
||||
local text = {}
|
||||
for zone, count in pairs(ret) do
|
||||
text[#text + 1] = string.format("%s: %d", zone, count)
|
||||
end
|
||||
return text
|
||||
end
|
||||
---@param arr table<string, Player>
|
||||
---@return string[]
|
||||
local function CountPartitioned(arr)
|
||||
local count = Count(arr)
|
||||
local text = {}
|
||||
---@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
|
||||
text[#text + 1] = line
|
||||
end
|
||||
return text
|
||||
end
|
||||
---@param arr table<string, Player>
|
||||
---@return string[]
|
||||
local function Who(arr)
|
||||
local ret = {}
|
||||
for _, player in pairs(arr) do
|
||||
if shared.Whoer.ShouldNotifyForZone(player.zone) then
|
||||
ret[#ret + 1] = string.format(
|
||||
"%s/%s (%s) %s",
|
||||
player.name,
|
||||
player.class,
|
||||
player.zone,
|
||||
player.stinky and "(!!!!)" or ""
|
||||
)
|
||||
end
|
||||
end
|
||||
if Heimdall_Data.config.commander.debug then
|
||||
print(string.format("[%s] Command result: %s", ModuleName, strjoin(", ", unpack(ret))))
|
||||
end
|
||||
return ret
|
||||
end
|
||||
---@param arr table<string, Player>
|
||||
---@return string[]
|
||||
local function WhoPartitioned(arr)
|
||||
local who = Who(arr)
|
||||
local text = {}
|
||||
---@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
|
||||
text[#text + 1] = "who: " .. line
|
||||
end
|
||||
return text
|
||||
end
|
||||
---@param arr table<string, Player>
|
||||
---@return string[]
|
||||
local function CountClass(arr)
|
||||
local ret = {}
|
||||
for _, player in pairs(arr) do
|
||||
if shared.Whoer.ShouldNotifyForZone(player.zone) then
|
||||
ret[player.class] = (ret[player.class] or 0) + 1
|
||||
end
|
||||
end
|
||||
local text = {}
|
||||
for class, count in pairs(ret) do
|
||||
text[#text + 1] = string.format("%s: %d", class, count)
|
||||
end
|
||||
if Heimdall_Data.config.commander.debug then
|
||||
print(string.format("[%s] Message text: %s", ModuleName, strjoin(", ", unpack(text))))
|
||||
end
|
||||
return text
|
||||
end
|
||||
---@param arr table<string, Player>
|
||||
---@return string[]
|
||||
local function CountClassPartitioned(arr)
|
||||
local countClass = CountClass(arr)
|
||||
local text = {}
|
||||
---@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
|
||||
text[#text + 1] = line
|
||||
end
|
||||
return text
|
||||
end
|
||||
local function CountClassPartitionedStinkies()
|
||||
if Heimdall_Data.config.commander.debug then
|
||||
print(string.format("[%s] Executing: CountClassPartitionedStinkies", ModuleName))
|
||||
end
|
||||
local res = CountClassPartitioned(HeimdallStinkies)
|
||||
if #res == 0 then return { "No stinkies found" } end
|
||||
return res
|
||||
end
|
||||
local function WhoPartitionedStinkies()
|
||||
if Heimdall_Data.config.commander.debug then
|
||||
print(string.format("[%s] Executing: WhoPartitionedStinkies", ModuleName))
|
||||
shared.dumpTable(HeimdallStinkies)
|
||||
end
|
||||
local res = WhoPartitioned(HeimdallStinkies)
|
||||
if #res == 0 then return { "No stinkies found" } end
|
||||
return res
|
||||
end
|
||||
local function CountPartitionedStinkies()
|
||||
if Heimdall_Data.config.commander.debug then
|
||||
print(string.format("[%s] Executing: CountPartitionedStinkies", ModuleName))
|
||||
end
|
||||
local res = CountPartitioned(HeimdallStinkies)
|
||||
if #res == 0 then return { "No stinkies found" } end
|
||||
return res
|
||||
end
|
||||
local function HelpRu()
|
||||
if Heimdall_Data.config.commander.debug then print(string.format("[%s] Executing: HelpRu", ModuleName)) end
|
||||
return helpMessages.ru
|
||||
end
|
||||
local function HelpEn()
|
||||
if Heimdall_Data.config.commander.debug then print(string.format("[%s] Executing: HelpEn", ModuleName)) end
|
||||
return helpMessages.en
|
||||
end
|
||||
local groupInviteFrame = CreateFrame("Frame")
|
||||
groupInviteFrame:SetScript("OnEvent", function(self, event, ...)
|
||||
if Heimdall_Data.config.commander.debug then print(string.format("[%s] Event received", ModuleName)) end
|
||||
AcceptGroup()
|
||||
groupInviteFrame:UnregisterEvent("PARTY_INVITE_REQUEST")
|
||||
C_Timer.NewTimer(0.1, function()
|
||||
if Heimdall_Data.config.commander.debug then
|
||||
print(string.format("[%s] Click event triggered", ModuleName))
|
||||
end
|
||||
_G["StaticPopup1Button1"]:Click()
|
||||
end, 1)
|
||||
end)
|
||||
local function JoinGroup()
|
||||
if Heimdall_Data.config.commander.debug then
|
||||
print(string.format("[%s] JoinGroup command received", ModuleName))
|
||||
end
|
||||
groupInviteFrame:RegisterEvent("PARTY_INVITE_REQUEST")
|
||||
C_Timer.NewTimer(10, function() groupInviteFrame:UnregisterEvent("PARTY_INVITE_REQUEST") end, 1)
|
||||
return { "+" }
|
||||
end
|
||||
local function LeaveGroup()
|
||||
if Heimdall_Data.config.commander.debug then
|
||||
print(string.format("[%s] LeaveGroup command received", ModuleName))
|
||||
end
|
||||
LeaveParty()
|
||||
return {}
|
||||
end
|
||||
---@param target string
|
||||
local function FollowTarget(target)
|
||||
if Heimdall_Data.config.commander.debug then
|
||||
print(string.format("[%s] Following target: %s", ModuleName, target))
|
||||
end
|
||||
if not target then return end
|
||||
FollowUnit(target)
|
||||
return {}
|
||||
end
|
||||
|
||||
---@param args string[]
|
||||
local function MacroTarget(args)
|
||||
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
|
||||
print(string.format("[%s] Macroing: %s", ModuleName, strjoin(" ", unpack(args))))
|
||||
end
|
||||
if #args < 2 or #args % 2 ~= 0 then
|
||||
if #args < 2 or #args % 2 ~= 0 then
|
||||
if Heimdall_Data.config.commander.debug then
|
||||
print(string.format("[%s] Invalid number of arguments for MacroTarget", ModuleName))
|
||||
end
|
||||
return {}
|
||||
end
|
||||
end
|
||||
table.remove(args, 1)
|
||||
|
||||
for i = 1, #args do
|
||||
local stinky = strtrim(args[i])
|
||||
local name = stinky:match("([^/]+)")
|
||||
local class = stinky:match("/([^ $]+)")
|
||||
if Heimdall_Data.config.commander.debug then
|
||||
print(string.format("[%s] Adding stinky: %s/%s", ModuleName, name, tostring(class)))
|
||||
end
|
||||
shared.StinkyTracker.Track({
|
||||
name = name,
|
||||
class = class or "unknown",
|
||||
seenAt = GetTime(),
|
||||
hostile = true,
|
||||
})
|
||||
if Heimdall_Data.config.commander.debug then
|
||||
print(string.format("[%s] Added stinky: %s/%s", ModuleName, name, tostring(class)))
|
||||
end
|
||||
end
|
||||
return {}
|
||||
end
|
||||
|
||||
---@param args string[]
|
||||
local function IgnoreMacroTarget(args)
|
||||
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
|
||||
print(string.format("[%s] Macroing: %s", ModuleName, strjoin(" ", unpack(args))))
|
||||
end
|
||||
if #args < 1 then
|
||||
if Heimdall_Data.config.commander.debug then
|
||||
print(string.format("[%s] Invalid number of arguments for IgnoreMacroTarget", ModuleName))
|
||||
end
|
||||
return {}
|
||||
end
|
||||
table.remove(args, 1)
|
||||
|
||||
for i = 1, #args do
|
||||
local stinky = strtrim(args[i])
|
||||
local name = stinky:match("([^/]+)")
|
||||
if Heimdall_Data.config.commander.debug then
|
||||
print(string.format("[%s] Ignoring stinky: %s", ModuleName, name))
|
||||
end
|
||||
shared.StinkyTracker.Ignore(name)
|
||||
end
|
||||
return {}
|
||||
end
|
||||
|
||||
---@class Command
|
||||
---@field keywordRe string
|
||||
---@field commanderOnly boolean
|
||||
---@field callback fun(...: any): string[]
|
||||
|
||||
local commands = {
|
||||
{ keywordRe = "^who$", commanderOnly = false, callback = WhoPartitionedStinkies },
|
||||
{ keywordRe = "^howmany$", commanderOnly = false, callback = CountPartitionedStinkies },
|
||||
{ keywordRe = "^classes$", commanderOnly = false, callback = CountClassPartitionedStinkies },
|
||||
{ keywordRe = "^help$", commanderOnly = false, callback = HelpRu },
|
||||
{ keywordRe = "^helpen$", commanderOnly = false, callback = HelpEn },
|
||||
{ keywordRe = "^joingroup$", commanderOnly = false, callback = JoinGroup },
|
||||
{ keywordRe = "^leavegroup$", commanderOnly = false, callback = LeaveGroup },
|
||||
{ keywordRe = "^follow$", commanderOnly = false, callback = FollowTarget },
|
||||
{ keywordRe = "^macro", commanderOnly = false, callback = MacroTarget },
|
||||
{ keywordRe = "^ignore", commanderOnly = false, callback = IgnoreMacroTarget },
|
||||
}
|
||||
|
||||
local commanderChannelFrame = CreateFrame("Frame")
|
||||
commanderChannelFrame:RegisterEvent("CHAT_MSG_CHANNEL")
|
||||
commanderChannelFrame:SetScript("OnEvent", function(self, event, msg, sender, ...)
|
||||
--if Heimdall_Data.config.commander.debug then
|
||||
-- print(string.format("[%s] Event received", ModuleName))
|
||||
-- shared.dumpTable(Heimdall_Data.config.commander)
|
||||
--end
|
||||
if not Heimdall_Data.config.commander.enabled then
|
||||
--if Heimdall_Data.config.commander.debug then
|
||||
-- print(string.format("[%s] Module disabled, ignoring event", ModuleName))
|
||||
--end
|
||||
return
|
||||
end
|
||||
local channelId = select(6, ...)
|
||||
local _, channelname = GetChannelName(channelId)
|
||||
local ok = false
|
||||
for _, channel in pairs(Heimdall_Data.config.commander.channels) do
|
||||
if channel == channelname then
|
||||
ok = true
|
||||
break
|
||||
end
|
||||
end
|
||||
if not ok then
|
||||
if Heimdall_Data.config.commander.debug then
|
||||
print(
|
||||
string.format(
|
||||
"[%s] Channel name '%s' does not match any of the channels '%s'",
|
||||
ModuleName,
|
||||
channelname,
|
||||
table.concat(Heimdall_Data.config.commander.channels, ", ")
|
||||
)
|
||||
)
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
sender = string.match(sender, "^[^-]+")
|
||||
if Heimdall_Data.config.commander.debug then
|
||||
print(string.format("[%s] Message from: %s", ModuleName, sender))
|
||||
shared.dumpTable(Heimdall_Data.config.commander)
|
||||
end
|
||||
|
||||
for _, command in ipairs(commands) do
|
||||
local enabled = Heimdall_Data.config.commander.commands[command.keywordRe] == true or false
|
||||
if Heimdall_Data.config.commander.debug then
|
||||
print(
|
||||
string.format("[%s] Command match: %s = %s", ModuleName, command.keywordRe, tostring(enabled))
|
||||
)
|
||||
end
|
||||
if
|
||||
enabled
|
||||
and (
|
||||
not command.commanderOnly
|
||||
-- if Heimdall_Data.config.commander.debug then print(string.format("[%s] Ignoring command, sender %s not commander %s", ModuleName, sender, Heimdall_Data.config.commander.commander)) end
|
||||
|
||||
or (command.commanderOnly and sender == Heimdall_Data.config.commander.commander)
|
||||
)
|
||||
then
|
||||
if msg:match(command.keywordRe) then
|
||||
---@diagnostic disable-next-line: redundant-parameter Currently luals does not support variadic functions as a @field
|
||||
local messages = command.callback({ strsplit(",", msg) })
|
||||
if Heimdall_Data.config.commander.debug then
|
||||
print(string.format("[%s] Messages to send: %s", ModuleName))
|
||||
shared.dumpTable(messages)
|
||||
end
|
||||
for _, message in ipairs(messages) do
|
||||
---@type Message
|
||||
local returnmsg = {
|
||||
channel = "C",
|
||||
data = channelname,
|
||||
message = message,
|
||||
}
|
||||
if Heimdall_Data.config.commander.debug then
|
||||
print(string.format("[%s] Queuing message", ModuleName))
|
||||
shared.dumpTable(msg)
|
||||
end
|
||||
--table.insert(shared.messenger.queue, msg)
|
||||
table.insert(shared.networkMessenger.queue, returnmsg)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
print("[Heimdall] Commander module loaded")
|
||||
end,
|
||||
local _, shared = ...
|
||||
---@cast shared HeimdallShared
|
||||
local ModuleName = "Commander"
|
||||
|
||||
---@class HeimdallCommanderConfig
|
||||
---@field enabled boolean
|
||||
---@field debug boolean
|
||||
---@field channels string[]
|
||||
---@field commander string
|
||||
---@field commands table<string, boolean>
|
||||
|
||||
local helpMessages = {
|
||||
ru = {
|
||||
"1) who - пишет вам никнеймы текущих врагов и локу.",
|
||||
"2) classes - покажет классы врагов и число.",
|
||||
"3) howmany - общее число врагов (дурик 4 . огри 2 ) ",
|
||||
"4) + - атоинвайт в сбор пати и сброса кд.",
|
||||
"5) ++ -автоинвайт в пати аликов (если нужен рефрак)",
|
||||
"6 ) note Никнейм текст - добавление заметки.",
|
||||
"7) note Никнейм - посмотреть последние заметки.",
|
||||
"8) note Никнейм 5 - посмотреть конкретную заметку.",
|
||||
"9) note Никнейм 1..5 - посмотреть заметки от 1 до 5",
|
||||
"10) note Никнейм delete 1 - удалить заметку номер 1",
|
||||
"11) note Никнейм delete 1..5 - удалить заметки 1 до 5",
|
||||
},
|
||||
en = {
|
||||
"1) who - reports currently tracked stinkies in orgrimmar and durotar",
|
||||
"2) classes - reports stinkies grouped by class",
|
||||
"3) howmany - reports stinkies grouped by zone",
|
||||
"4) + - automatically invites to group with duel rogue for cd reset",
|
||||
"5) ++ - automatically invites to alliance group",
|
||||
"6) note <name> <note> - adds a note for the specified character.",
|
||||
"7) note <name> - lists the last N notes 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.",
|
||||
"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.",
|
||||
},
|
||||
}
|
||||
|
||||
---@class Commander
|
||||
shared.Commander = {
|
||||
Init = function()
|
||||
---@param text string
|
||||
---@param size number
|
||||
---@return string[]
|
||||
local function Partition(text, size)
|
||||
local words = {}
|
||||
for word in text:gmatch("[^,]+") do
|
||||
words[#words + 1] = word
|
||||
end
|
||||
|
||||
local ret = {}
|
||||
local currentChunk = ""
|
||||
|
||||
for _, word in ipairs(words) do
|
||||
if #currentChunk + #word + 1 <= size then
|
||||
currentChunk = currentChunk .. (currentChunk == "" and word or " " .. word)
|
||||
else
|
||||
if #currentChunk > 0 then ret[#ret + 1] = currentChunk end
|
||||
currentChunk = word
|
||||
end
|
||||
end
|
||||
|
||||
if #currentChunk > 0 then ret[#ret + 1] = currentChunk end
|
||||
|
||||
return ret
|
||||
end
|
||||
---@param arr table<string, Player>
|
||||
---@return string[]
|
||||
local function Count(arr)
|
||||
local ret = {}
|
||||
for _, player in pairs(arr) do
|
||||
if shared.Whoer.ShouldNotifyForZone(player.zone) then ret[player.zone] = (ret[player.zone] or 0) + 1 end
|
||||
end
|
||||
local text = {}
|
||||
for zone, count in pairs(ret) do
|
||||
text[#text + 1] = string.format("%s: %d", zone, count)
|
||||
end
|
||||
return text
|
||||
end
|
||||
---@param arr table<string, Player>
|
||||
---@return string[]
|
||||
local function CountPartitioned(arr)
|
||||
local count = Count(arr)
|
||||
local text = {}
|
||||
---@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
|
||||
text[#text + 1] = line
|
||||
end
|
||||
return text
|
||||
end
|
||||
---@param arr table<string, Player>
|
||||
---@return string[]
|
||||
local function Who(arr)
|
||||
local ret = {}
|
||||
for _, player in pairs(arr) do
|
||||
if shared.Whoer.ShouldNotifyForZone(player.zone) then
|
||||
ret[#ret + 1] = string.format(
|
||||
"%s/%s (%s) %s",
|
||||
player.name,
|
||||
player.class,
|
||||
player.zone,
|
||||
player.stinky and "(!!!!)" or ""
|
||||
)
|
||||
end
|
||||
end
|
||||
if Heimdall_Data.config.commander.debug then
|
||||
print(string.format("[%s] Command result: %s", ModuleName, strjoin(", ", unpack(ret))))
|
||||
end
|
||||
return ret
|
||||
end
|
||||
---@param arr table<string, Player>
|
||||
---@return string[]
|
||||
local function WhoPartitioned(arr)
|
||||
local who = Who(arr)
|
||||
local text = {}
|
||||
---@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
|
||||
text[#text + 1] = "who: " .. line
|
||||
end
|
||||
return text
|
||||
end
|
||||
---@param arr table<string, Player>
|
||||
---@return string[]
|
||||
local function CountClass(arr)
|
||||
local ret = {}
|
||||
for _, player in pairs(arr) do
|
||||
if shared.Whoer.ShouldNotifyForZone(player.zone) then
|
||||
ret[player.class] = (ret[player.class] or 0) + 1
|
||||
end
|
||||
end
|
||||
local text = {}
|
||||
for class, count in pairs(ret) do
|
||||
text[#text + 1] = string.format("%s: %d", class, count)
|
||||
end
|
||||
if Heimdall_Data.config.commander.debug then
|
||||
print(string.format("[%s] Message text: %s", ModuleName, strjoin(", ", unpack(text))))
|
||||
end
|
||||
return text
|
||||
end
|
||||
---@param arr table<string, Player>
|
||||
---@return string[]
|
||||
local function CountClassPartitioned(arr)
|
||||
local countClass = CountClass(arr)
|
||||
local text = {}
|
||||
---@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
|
||||
text[#text + 1] = line
|
||||
end
|
||||
return text
|
||||
end
|
||||
local function CountClassPartitionedStinkies()
|
||||
if Heimdall_Data.config.commander.debug then
|
||||
print(string.format("[%s] Executing: CountClassPartitionedStinkies", ModuleName))
|
||||
end
|
||||
local res = CountClassPartitioned(HeimdallStinkies)
|
||||
if #res == 0 then return { "No stinkies found" } end
|
||||
return res
|
||||
end
|
||||
local function WhoPartitionedStinkies()
|
||||
if Heimdall_Data.config.commander.debug then
|
||||
print(string.format("[%s] Executing: WhoPartitionedStinkies", ModuleName))
|
||||
shared.dump(HeimdallStinkies)
|
||||
end
|
||||
local res = WhoPartitioned(HeimdallStinkies)
|
||||
if #res == 0 then return { "No stinkies found" } end
|
||||
return res
|
||||
end
|
||||
local function CountPartitionedStinkies()
|
||||
if Heimdall_Data.config.commander.debug then
|
||||
print(string.format("[%s] Executing: CountPartitionedStinkies", ModuleName))
|
||||
end
|
||||
local res = CountPartitioned(HeimdallStinkies)
|
||||
if #res == 0 then return { "No stinkies found" } end
|
||||
return res
|
||||
end
|
||||
local function HelpRu()
|
||||
if Heimdall_Data.config.commander.debug then print(string.format("[%s] Executing: HelpRu", ModuleName)) end
|
||||
return helpMessages.ru
|
||||
end
|
||||
local function HelpEn()
|
||||
if Heimdall_Data.config.commander.debug then print(string.format("[%s] Executing: HelpEn", ModuleName)) end
|
||||
return helpMessages.en
|
||||
end
|
||||
local groupInviteFrame = CreateFrame("Frame")
|
||||
groupInviteFrame:SetScript("OnEvent", function(self, event, ...)
|
||||
if Heimdall_Data.config.commander.debug then print(string.format("[%s] Event received", ModuleName)) end
|
||||
AcceptGroup()
|
||||
groupInviteFrame:UnregisterEvent("PARTY_INVITE_REQUEST")
|
||||
C_Timer.NewTimer(0.1, function()
|
||||
if Heimdall_Data.config.commander.debug then
|
||||
print(string.format("[%s] Click event triggered", ModuleName))
|
||||
end
|
||||
_G["StaticPopup1Button1"]:Click()
|
||||
end, 1)
|
||||
end)
|
||||
local function JoinGroup()
|
||||
if Heimdall_Data.config.commander.debug then
|
||||
print(string.format("[%s] JoinGroup command received", ModuleName))
|
||||
end
|
||||
groupInviteFrame:RegisterEvent("PARTY_INVITE_REQUEST")
|
||||
C_Timer.NewTimer(10, function() groupInviteFrame:UnregisterEvent("PARTY_INVITE_REQUEST") end, 1)
|
||||
return { "+" }
|
||||
end
|
||||
local function LeaveGroup()
|
||||
if Heimdall_Data.config.commander.debug then
|
||||
print(string.format("[%s] LeaveGroup command received", ModuleName))
|
||||
end
|
||||
LeaveParty()
|
||||
return {}
|
||||
end
|
||||
---@param target string
|
||||
local function FollowTarget(target)
|
||||
if Heimdall_Data.config.commander.debug then
|
||||
print(string.format("[%s] Following target: %s", ModuleName, target))
|
||||
end
|
||||
if not target then return end
|
||||
FollowUnit(target)
|
||||
return {}
|
||||
end
|
||||
|
||||
---@param args string[]
|
||||
local function MacroTarget(args)
|
||||
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
|
||||
print(string.format("[%s] Macroing: %s", ModuleName, strjoin(" ", unpack(args))))
|
||||
end
|
||||
if #args < 2 or #args % 2 ~= 0 then
|
||||
if #args < 2 or #args % 2 ~= 0 then
|
||||
if Heimdall_Data.config.commander.debug then
|
||||
print(string.format("[%s] Invalid number of arguments for MacroTarget", ModuleName))
|
||||
end
|
||||
return {}
|
||||
end
|
||||
end
|
||||
table.remove(args, 1)
|
||||
|
||||
for i = 1, #args do
|
||||
local stinky = strtrim(args[i])
|
||||
local name = stinky:match("([^/]+)")
|
||||
local class = stinky:match("/([^ $]+)")
|
||||
if Heimdall_Data.config.commander.debug then
|
||||
print(string.format("[%s] Adding stinky: %s/%s", ModuleName, name, tostring(class)))
|
||||
end
|
||||
shared.StinkyTracker.Track({
|
||||
name = name,
|
||||
class = class or "unknown",
|
||||
seenAt = GetTime(),
|
||||
hostile = true,
|
||||
})
|
||||
if Heimdall_Data.config.commander.debug then
|
||||
print(string.format("[%s] Added stinky: %s/%s", ModuleName, name, tostring(class)))
|
||||
end
|
||||
end
|
||||
return {}
|
||||
end
|
||||
|
||||
---@param args string[]
|
||||
local function IgnoreMacroTarget(args)
|
||||
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
|
||||
print(string.format("[%s] Macroing: %s", ModuleName, strjoin(" ", unpack(args))))
|
||||
end
|
||||
if #args < 1 then
|
||||
if Heimdall_Data.config.commander.debug then
|
||||
print(string.format("[%s] Invalid number of arguments for IgnoreMacroTarget", ModuleName))
|
||||
end
|
||||
return {}
|
||||
end
|
||||
table.remove(args, 1)
|
||||
|
||||
for i = 1, #args do
|
||||
local stinky = strtrim(args[i])
|
||||
local name = stinky:match("([^/]+)")
|
||||
if Heimdall_Data.config.commander.debug then
|
||||
print(string.format("[%s] Ignoring stinky: %s", ModuleName, name))
|
||||
end
|
||||
shared.StinkyTracker.Ignore(name)
|
||||
end
|
||||
return {}
|
||||
end
|
||||
|
||||
---@class Command
|
||||
---@field keywordRe string
|
||||
---@field commanderOnly boolean
|
||||
---@field callback fun(...: any): string[]
|
||||
|
||||
local commands = {
|
||||
{ keywordRe = "^who$", commanderOnly = false, callback = WhoPartitionedStinkies },
|
||||
{ keywordRe = "^howmany$", commanderOnly = false, callback = CountPartitionedStinkies },
|
||||
{ keywordRe = "^classes$", commanderOnly = false, callback = CountClassPartitionedStinkies },
|
||||
{ keywordRe = "^help$", commanderOnly = false, callback = HelpRu },
|
||||
{ keywordRe = "^helpen$", commanderOnly = false, callback = HelpEn },
|
||||
{ keywordRe = "^joingroup$", commanderOnly = false, callback = JoinGroup },
|
||||
{ keywordRe = "^leavegroup$", commanderOnly = false, callback = LeaveGroup },
|
||||
{ keywordRe = "^follow$", commanderOnly = false, callback = FollowTarget },
|
||||
{ keywordRe = "^macro", commanderOnly = false, callback = MacroTarget },
|
||||
{ keywordRe = "^ignore", commanderOnly = false, callback = IgnoreMacroTarget },
|
||||
}
|
||||
|
||||
local commanderChannelFrame = CreateFrame("Frame")
|
||||
commanderChannelFrame:RegisterEvent("CHAT_MSG_CHANNEL")
|
||||
commanderChannelFrame:SetScript("OnEvent", function(self, event, msg, sender, ...)
|
||||
--if Heimdall_Data.config.commander.debug then
|
||||
-- print(string.format("[%s] Event received", ModuleName))
|
||||
-- shared.dump(Heimdall_Data.config.commander)
|
||||
--end
|
||||
if not Heimdall_Data.config.commander.enabled then
|
||||
--if Heimdall_Data.config.commander.debug then
|
||||
-- print(string.format("[%s] Module disabled, ignoring event", ModuleName))
|
||||
--end
|
||||
return
|
||||
end
|
||||
local channelId = select(6, ...)
|
||||
local _, channelname = GetChannelName(channelId)
|
||||
local ok = false
|
||||
for _, channel in pairs(Heimdall_Data.config.commander.channels) do
|
||||
if channel == channelname then
|
||||
ok = true
|
||||
break
|
||||
end
|
||||
end
|
||||
if not ok then
|
||||
if Heimdall_Data.config.commander.debug then
|
||||
print(
|
||||
string.format(
|
||||
"[%s] Channel name '%s' does not match any of the channels '%s'",
|
||||
ModuleName,
|
||||
channelname,
|
||||
table.concat(Heimdall_Data.config.commander.channels, ", ")
|
||||
)
|
||||
)
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
sender = string.match(sender, "^[^-]+")
|
||||
if Heimdall_Data.config.commander.debug then
|
||||
print(string.format("[%s] Message from: %s", ModuleName, sender))
|
||||
shared.dump(Heimdall_Data.config.commander)
|
||||
end
|
||||
|
||||
for _, command in ipairs(commands) do
|
||||
local enabled = Heimdall_Data.config.commander.commands[command.keywordRe] == true or false
|
||||
if Heimdall_Data.config.commander.debug then
|
||||
print(
|
||||
string.format("[%s] Command match: %s = %s", ModuleName, command.keywordRe, tostring(enabled))
|
||||
)
|
||||
end
|
||||
if
|
||||
enabled
|
||||
and (
|
||||
not command.commanderOnly
|
||||
-- if Heimdall_Data.config.commander.debug then print(string.format("[%s] Ignoring command, sender %s not commander %s", ModuleName, sender, Heimdall_Data.config.commander.commander)) end
|
||||
|
||||
or (command.commanderOnly and sender == Heimdall_Data.config.commander.commander)
|
||||
)
|
||||
then
|
||||
if msg:match(command.keywordRe) then
|
||||
---@diagnostic disable-next-line: redundant-parameter Currently luals does not support variadic functions as a @field
|
||||
local messages = command.callback({ strsplit(",", msg) })
|
||||
if Heimdall_Data.config.commander.debug then
|
||||
print(string.format("[%s] Messages to send: %s", ModuleName))
|
||||
shared.dump(messages)
|
||||
end
|
||||
for _, message in ipairs(messages) do
|
||||
---@type Message
|
||||
local returnmsg = {
|
||||
channel = "C",
|
||||
data = channelname,
|
||||
message = message,
|
||||
}
|
||||
if Heimdall_Data.config.commander.debug then
|
||||
print(string.format("[%s] Queuing message", ModuleName))
|
||||
shared.dump(msg)
|
||||
end
|
||||
--table.insert(shared.messenger.queue, msg)
|
||||
table.insert(shared.networkMessenger.queue, returnmsg)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
print("[Heimdall] Commander module loaded")
|
||||
end,
|
||||
}
|
||||
|
||||
@@ -709,7 +709,7 @@ shared.Config = {
|
||||
local text = self:GetText()
|
||||
Heimdall_Data.config.spotter.channels = StringToArray(text, ",")
|
||||
print("Channels set to")
|
||||
shared.dumpTable(Heimdall_Data.config.spotter.channels)
|
||||
shared.dump(Heimdall_Data.config.spotter.channels)
|
||||
end
|
||||
)
|
||||
spotterConfigFrame:Add(channels, 2, 4)
|
||||
@@ -809,7 +809,7 @@ shared.Config = {
|
||||
local text = self:GetText()
|
||||
Heimdall_Data.config.who.channels = StringToArray(text, ",")
|
||||
print("Channels set to")
|
||||
shared.dumpTable(Heimdall_Data.config.who.channels)
|
||||
shared.dump(Heimdall_Data.config.who.channels)
|
||||
end
|
||||
)
|
||||
whoerConfigFrame:Add(channels, 2, 3)
|
||||
@@ -1021,7 +1021,7 @@ shared.Config = {
|
||||
local text = self:GetText()
|
||||
Heimdall_Data.config.deathReporter.channels = StringToArray(text, ",")
|
||||
print("Channels set to")
|
||||
shared.dumpTable(Heimdall_Data.config.deathReporter.channels)
|
||||
shared.dump(Heimdall_Data.config.deathReporter.channels)
|
||||
end
|
||||
)
|
||||
deathReporterConfigFrame:Add(channels, 2, 6)
|
||||
@@ -1146,7 +1146,7 @@ shared.Config = {
|
||||
local text = self:GetText()
|
||||
Heimdall_Data.config.inviter.channels = StringToArray(text, ",")
|
||||
print("Channels set to")
|
||||
shared.dumpTable(Heimdall_Data.config.inviter.channels)
|
||||
shared.dump(Heimdall_Data.config.inviter.channels)
|
||||
end
|
||||
)
|
||||
inviterConfigFrame:Add(channels, 2, 6)
|
||||
@@ -1301,7 +1301,7 @@ shared.Config = {
|
||||
local text = self:GetText()
|
||||
Heimdall_Data.config.agentTracker.channels = StringToArray(text, ",")
|
||||
print("Channels set to")
|
||||
shared.dumpTable(Heimdall_Data.config.agentTracker.channels)
|
||||
shared.dump(Heimdall_Data.config.agentTracker.channels)
|
||||
end
|
||||
)
|
||||
agentTrackerConfigFrame:Add(channels, 2, 6)
|
||||
@@ -1354,7 +1354,7 @@ shared.Config = {
|
||||
local text = self:GetText()
|
||||
Heimdall_Data.config.stinkyTracker.channels = StringToArray(text, ",")
|
||||
print("Channels set to")
|
||||
shared.dumpTable(Heimdall_Data.config.stinkyTracker.channels)
|
||||
shared.dump(Heimdall_Data.config.stinkyTracker.channels)
|
||||
end
|
||||
)
|
||||
stinkyTrackerConfigFrame:Add(channels, 2, 6)
|
||||
@@ -1407,7 +1407,7 @@ shared.Config = {
|
||||
local text = self:GetText()
|
||||
Heimdall_Data.config.emoter.channels = StringToArray(text, ",")
|
||||
print("Channels set to")
|
||||
shared.dumpTable(Heimdall_Data.config.emoter.channels)
|
||||
shared.dump(Heimdall_Data.config.emoter.channels)
|
||||
end
|
||||
)
|
||||
emoterConfigFrame:Add(channels, 2, 6)
|
||||
@@ -1478,7 +1478,7 @@ shared.Config = {
|
||||
local text = self:GetText()
|
||||
Heimdall_Data.config.echoer.channels = StringToArray(text, ",")
|
||||
print("Channels set to")
|
||||
shared.dumpTable(Heimdall_Data.config.echoer.channels)
|
||||
shared.dump(Heimdall_Data.config.echoer.channels)
|
||||
end
|
||||
)
|
||||
echoerConfigFrame:Add(channels, 2, 6)
|
||||
@@ -1549,7 +1549,7 @@ shared.Config = {
|
||||
local text = self:GetText()
|
||||
Heimdall_Data.config.commander.channels = StringToArray(text, ",")
|
||||
print("Channels set to")
|
||||
shared.dumpTable(Heimdall_Data.config.commander.channels)
|
||||
shared.dump(Heimdall_Data.config.commander.channels)
|
||||
end
|
||||
)
|
||||
commanderConfigFrame:Add(channels, 2, 6)
|
||||
@@ -1683,7 +1683,7 @@ shared.Config = {
|
||||
local text = self:GetText()
|
||||
Heimdall_Data.config.combatAlerter.channels = StringToArray(text, ",")
|
||||
print("Channels set to")
|
||||
shared.dumpTable(Heimdall_Data.config.combatAlerter.channels)
|
||||
shared.dump(Heimdall_Data.config.combatAlerter.channels)
|
||||
end
|
||||
)
|
||||
combatAlerterConfigFrame:Add(channels, 2, 6)
|
||||
@@ -1748,7 +1748,7 @@ shared.Config = {
|
||||
local text = self:GetText()
|
||||
Heimdall_Data.config.sniffer.channels = StringToArray(text, ",")
|
||||
print("Channels set to")
|
||||
shared.dumpTable(Heimdall_Data.config.sniffer.channels)
|
||||
shared.dump(Heimdall_Data.config.sniffer.channels)
|
||||
end
|
||||
)
|
||||
snifferConfigFrame:Add(channels, 2, 6)
|
||||
@@ -1838,7 +1838,7 @@ shared.Config = {
|
||||
local text = self:GetText()
|
||||
Heimdall_Data.config.bonkDetector.channels = StringToArray(text, ",")
|
||||
print("Channels set to")
|
||||
shared.dumpTable(Heimdall_Data.config.bonkDetector.channels)
|
||||
shared.dump(Heimdall_Data.config.bonkDetector.channels)
|
||||
end
|
||||
)
|
||||
bonkDetectorConfigFrame:Add(channels, 2, 6)
|
||||
@@ -1909,7 +1909,7 @@ shared.Config = {
|
||||
local text = self:GetText()
|
||||
Heimdall_Data.config.minimapTagger.channels = StringToArray(text, ",")
|
||||
print("Channels set to")
|
||||
shared.dumpTable(Heimdall_Data.config.minimapTagger.channels)
|
||||
shared.dump(Heimdall_Data.config.minimapTagger.channels)
|
||||
end
|
||||
)
|
||||
minimapTaggerConfigFrame:Add(channels, 2, 3)
|
||||
@@ -2278,7 +2278,7 @@ shared.Config = {
|
||||
local text = self:GetText()
|
||||
Heimdall_Data.config.noter.channels = StringToArray(text, ",")
|
||||
print("Channels set to")
|
||||
shared.dumpTable(Heimdall_Data.config.noter.channels)
|
||||
shared.dump(Heimdall_Data.config.noter.channels)
|
||||
end
|
||||
)
|
||||
noterConfigFrame:Add(channels, 2, 6)
|
||||
|
||||
@@ -178,7 +178,7 @@ shared.DeathReporter = {
|
||||
}
|
||||
if Heimdall_Data.config.deathReporter.debug then
|
||||
print(string.format("[%s] Queuing death report message", ModuleName))
|
||||
shared.dumpTable(msg)
|
||||
shared.dump(msg)
|
||||
end
|
||||
table.insert(shared.messenger.queue, msg)
|
||||
end
|
||||
|
||||
@@ -1,25 +1,29 @@
|
||||
local _, shared = ...
|
||||
---@cast shared HeimdallShared
|
||||
|
||||
if not shared.dumpTable then
|
||||
---@param table table
|
||||
if not shared.dump then
|
||||
---@param value any
|
||||
---@param msg string?
|
||||
---@param depth number?
|
||||
shared.dumpTable = function(table, msg, depth)
|
||||
if not table then
|
||||
print(tostring(table))
|
||||
shared.dump = function(value, msg, depth)
|
||||
if not value then
|
||||
print(tostring(value))
|
||||
return
|
||||
end
|
||||
if type(value) ~= "table" then
|
||||
print(tostring(value))
|
||||
return
|
||||
end
|
||||
if msg then print(msg) end
|
||||
if depth == nil then depth = 0 end
|
||||
if depth > 200 then
|
||||
print("Error: Depth > 200 in dumpTable()")
|
||||
print("Error: Depth > 200 in dump()")
|
||||
return
|
||||
end
|
||||
for k, v in pairs(table) do
|
||||
for k, v in pairs(value) do
|
||||
if type(v) == "table" then
|
||||
print(string.rep(" ", depth) .. tostring(k) .. ":")
|
||||
shared.dumpTable(v, nil, depth + 1)
|
||||
shared.dump(v, msg, depth + 1)
|
||||
else
|
||||
print(string.rep(" ", depth) .. tostring(k) .. ": " .. tostring(v))
|
||||
end
|
||||
|
||||
@@ -42,7 +42,7 @@ shared.Echoer = {
|
||||
end
|
||||
if Heimdall_Data.config.echoer.debug then
|
||||
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
|
||||
|
||||
if string.find(msg, "^" .. Heimdall_Data.config.echoer.prefix) then
|
||||
|
||||
@@ -43,7 +43,7 @@ shared.Emoter = {
|
||||
|
||||
if Heimdall_Data.config.emoter.debug then
|
||||
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
|
||||
|
||||
if string.find(msg, "^" .. Heimdall_Data.config.emoter.prefix) then
|
||||
|
||||
@@ -214,7 +214,7 @@ shared.Inviter = {
|
||||
inviterChannelFrame:SetScript("OnEvent", function(self, event, msg, sender, ...)
|
||||
--if Heimdall_Data.config.inviter.debug then
|
||||
-- print(string.format("[%s] Chat message received: %s", ModuleName, msg))
|
||||
-- shared.dumpTable(Heimdall_Data.config.inviter)
|
||||
-- shared.dump(Heimdall_Data.config.inviter)
|
||||
--end
|
||||
if not Heimdall_Data.config.inviter.enabled then return end
|
||||
local channelId = select(6, ...)
|
||||
|
||||
@@ -67,7 +67,7 @@ shared.Macroer = {
|
||||
|
||||
if Heimdall_Data.config.macroer.debug then
|
||||
print(string.format("[%s] Sorted stinkies: %d", ModuleName, #sortedStinkies))
|
||||
shared.dumpTable(sortedStinkies)
|
||||
shared.dump(sortedStinkies)
|
||||
end
|
||||
local lines = { "/targetenemy" }
|
||||
for _, stinky in pairs(sortedStinkies) do
|
||||
@@ -91,7 +91,7 @@ shared.Macroer = {
|
||||
shared.StinkyTracker.OnChange(function(stinkies)
|
||||
if Heimdall_Data.config.macroer.debug then
|
||||
print(string.format("[%s] Stinkies changed, updating macro", ModuleName))
|
||||
shared.dumpTable(stinkies)
|
||||
shared.dump(stinkies)
|
||||
end
|
||||
FixMacro(stinkies)
|
||||
end)
|
||||
|
||||
@@ -72,18 +72,18 @@ shared.Messenger = {
|
||||
return
|
||||
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 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
|
||||
return
|
||||
end
|
||||
|
||||
if not message.channel or message.channel == "" then
|
||||
if Heimdall_Data.config.messenger.debug then
|
||||
shared.dumpTable(
|
||||
shared.dump(
|
||||
message,
|
||||
string.format("[%s] Invalid message: no channel specified", ModuleName)
|
||||
)
|
||||
@@ -93,7 +93,7 @@ shared.Messenger = {
|
||||
|
||||
if string.find(message.channel, "^C") then
|
||||
if Heimdall_Data.config.messenger.debug then
|
||||
shared.dumpTable(
|
||||
shared.dump(
|
||||
message,
|
||||
string.format("[%s] Converting channel type from C to CHANNEL", ModuleName)
|
||||
)
|
||||
@@ -101,7 +101,7 @@ shared.Messenger = {
|
||||
message.channel = "CHANNEL"
|
||||
elseif string.find(message.channel, "^W") then
|
||||
if Heimdall_Data.config.messenger.debug then
|
||||
shared.dumpTable(
|
||||
shared.dump(
|
||||
message,
|
||||
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 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
|
||||
local channelId = GetChannelName(message.data)
|
||||
if channelId == 0 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
|
||||
channelId = FindOrJoinChannel(message.data)
|
||||
if Heimdall_Data.config.messenger.debug then
|
||||
@@ -129,28 +129,28 @@ shared.Messenger = {
|
||||
table.remove(shared.messenger.queue, 1)
|
||||
if not message.message or message.message == "" 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
|
||||
return
|
||||
end
|
||||
if not message.channel or message.channel == "" 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
|
||||
return
|
||||
end
|
||||
if not message.data or message.data == "" 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
|
||||
return
|
||||
end
|
||||
|
||||
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
|
||||
if string.len(message.message) > 255 then
|
||||
shared.dumpTable(
|
||||
shared.dump(
|
||||
message,
|
||||
string.format("[%s] Message too long!!!!: %s", ModuleName, message.message)
|
||||
)
|
||||
|
||||
@@ -473,7 +473,7 @@ shared.MinimapTagger = {
|
||||
end
|
||||
if Heimdall_Data.config.minimapTagger.debug then
|
||||
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
|
||||
|
||||
local doTag = true
|
||||
|
||||
@@ -61,7 +61,7 @@ shared.Network = {
|
||||
end
|
||||
if Heimdall_Data.config.network.debug then
|
||||
print(string.format("[%s] Network nodes:", ModuleName))
|
||||
shared.dumpTable(shared.networkNodes)
|
||||
shared.dump(shared.networkNodes)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -143,7 +143,7 @@ shared.NetworkMessenger = {
|
||||
local parts = shared.Split(message, "|")
|
||||
if Heimdall_Data.config.networkMessenger.debug then
|
||||
print(string.format("[%s] Received message parts:", ModuleName))
|
||||
shared.dumpTable(parts)
|
||||
shared.dump(parts)
|
||||
end
|
||||
local command = strtrim(parts[1])
|
||||
if command == "message" then
|
||||
|
||||
@@ -67,7 +67,7 @@ shared.Noter = {
|
||||
local indices = shared.Split(range, "..")
|
||||
if Heimdall_Data.config.noter.debug then
|
||||
print(string.format("[%s] Indices for range deletion: %s", ModuleName, table.concat(indices, ", ")))
|
||||
shared.dumpTable(indices)
|
||||
shared.dump(indices)
|
||||
end
|
||||
local start = tonumber(indices[1])
|
||||
local finish = tonumber(indices[2])
|
||||
@@ -98,7 +98,7 @@ shared.Noter = {
|
||||
else
|
||||
if Heimdall_Data.config.noter.debug then
|
||||
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
|
||||
Heimdall_Data.config.notes[name][i] = nil
|
||||
end
|
||||
@@ -159,7 +159,7 @@ shared.Noter = {
|
||||
local indices = shared.Split(range, "..")
|
||||
if Heimdall_Data.config.noter.debug then
|
||||
print(string.format("[%s] Indices for range printing: %s", ModuleName, table.concat(indices, ", ")))
|
||||
shared.dumpTable(indices)
|
||||
shared.dump(indices)
|
||||
end
|
||||
local start = tonumber(indices[1])
|
||||
local finish = tonumber(indices[2])
|
||||
@@ -185,7 +185,7 @@ shared.Noter = {
|
||||
else
|
||||
if Heimdall_Data.config.noter.debug then
|
||||
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
|
||||
PrintNote(channel, i, Heimdall_Data.config.notes[name][i])
|
||||
end
|
||||
@@ -200,7 +200,7 @@ shared.Noter = {
|
||||
if not Heimdall_Data.config.notes[name] then Heimdall_Data.config.notes[name] = {} end
|
||||
if Heimdall_Data.config.noter.debug then
|
||||
print(string.format("[%s] Adding note for: %s from: %s", ModuleName, name, sender))
|
||||
shared.dumpTable(args)
|
||||
shared.dump(args)
|
||||
end
|
||||
local msgparts = {}
|
||||
for i = 3, #args do
|
||||
@@ -221,7 +221,7 @@ shared.Noter = {
|
||||
|
||||
if Heimdall_Data.config.noter.debug then
|
||||
print(string.format("[%s] Adding note", ModuleName))
|
||||
shared.dumpTable(note)
|
||||
shared.dump(note)
|
||||
end
|
||||
table.insert(Heimdall_Data.config.notes[name], note)
|
||||
end
|
||||
@@ -239,7 +239,7 @@ shared.Noter = {
|
||||
noterChannelFrame:SetScript("OnEvent", function(self, event, msg, sender, ...)
|
||||
--if Heimdall_Data.config.noter.debug then
|
||||
-- print(string.format("[%s] Event received", ModuleName))
|
||||
-- shared.dumpTable(Heimdall_Data.config.noter)
|
||||
-- shared.dump(Heimdall_Data.config.noter)
|
||||
--end
|
||||
if not Heimdall_Data.config.noter.enabled then
|
||||
--if Heimdall_Data.config.noter.debug then
|
||||
@@ -266,7 +266,7 @@ shared.Noter = {
|
||||
sender = string.match(sender, "^[^-]+")
|
||||
if Heimdall_Data.config.noter.debug then
|
||||
print(string.format("[%s] Message from: %s", ModuleName, sender))
|
||||
shared.dumpTable(Heimdall_Data.config.noter)
|
||||
shared.dump(Heimdall_Data.config.noter)
|
||||
end
|
||||
|
||||
if not msg or msg == "" then
|
||||
@@ -279,7 +279,7 @@ shared.Noter = {
|
||||
local args = { strsplit(" ", msg) }
|
||||
if Heimdall_Data.config.noter.debug then
|
||||
print(string.format("[%s] Arguments received: %s", ModuleName, table.concat(args, ", ")))
|
||||
shared.dumpTable(args)
|
||||
shared.dump(args)
|
||||
end
|
||||
local command = args[1]
|
||||
if command == "note" then
|
||||
|
||||
@@ -483,7 +483,7 @@ local function Init()
|
||||
-- S local clbk = test:onChange(function(value)
|
||||
-- S invocations = invocations + 1
|
||||
-- S print("test changed to")
|
||||
-- S dumpTable(value, 0)
|
||||
-- S dump(value, 0)
|
||||
-- S end)
|
||||
-- S test:set({1, 2, 3, 4})
|
||||
-- S assert(invocations == 1)
|
||||
@@ -516,7 +516,7 @@ local function Init()
|
||||
-- S test:once(function(value)
|
||||
-- S invocations = invocations + 1
|
||||
-- S print("test changed to")
|
||||
-- S dumpTable(value, 0)
|
||||
-- S dump(value, 0)
|
||||
-- S end)
|
||||
-- S test:set({3, 2, 1})
|
||||
-- S assert(invocations == 1)
|
||||
@@ -527,7 +527,7 @@ local function Init()
|
||||
-- S test:onChange(function(value)
|
||||
-- S invocations = invocations + 1
|
||||
-- S print("test changed to")
|
||||
-- S dumpTable(value, 0)
|
||||
-- S dump(value, 0)
|
||||
-- S end)
|
||||
-- S test:onAnyFieldChange(function(field, value)
|
||||
-- S invocations = invocations + 1
|
||||
|
||||
@@ -18,7 +18,7 @@ shared.Sniffer = {
|
||||
local SmellStinky = function(stinky)
|
||||
if Heimdall_Data.config.sniffer.debug then
|
||||
print(string.format("%s: SmellStinky", ModuleName))
|
||||
shared.dumpTable(Heimdall_Data.config.sniffer)
|
||||
shared.dump(Heimdall_Data.config.sniffer)
|
||||
end
|
||||
if not Heimdall_Data.config.sniffer.enabled then return end
|
||||
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
|
||||
print(string.format("[%s] Queuing sniffer message", ModuleName))
|
||||
shared.dumpTable(msg)
|
||||
shared.dump(msg)
|
||||
end
|
||||
table.insert(shared.messenger.queue, msg)
|
||||
end
|
||||
|
||||
@@ -201,7 +201,7 @@ shared.Spotter = {
|
||||
}
|
||||
if Heimdall_Data.config.spotter.debug then
|
||||
print(string.format("[%s] Queuing spotter message", ModuleName))
|
||||
shared.dumpTable(msg)
|
||||
shared.dump(msg)
|
||||
end
|
||||
table.insert(shared.messenger.queue, msg)
|
||||
end
|
||||
|
||||
@@ -38,8 +38,8 @@ shared.StinkyTracker = {
|
||||
stinky.class
|
||||
)
|
||||
)
|
||||
shared.dumpTable(shared.stinkyTracker.ignored:get())
|
||||
shared.dumpTable(shared.stinkyTracker.stinkies:get())
|
||||
shared.dump(shared.stinkyTracker.ignored:get())
|
||||
shared.dump(shared.stinkyTracker.stinkies:get())
|
||||
end
|
||||
return false
|
||||
else
|
||||
@@ -50,8 +50,8 @@ shared.StinkyTracker = {
|
||||
shared.stinkyTracker.stinkies[stinky.name] = stinky
|
||||
if Heimdall_Data.config.stinkyTracker.debug then
|
||||
print(string.format("[%s] Stinky is now tracked: %s (%s)", ModuleName, stinky.name, stinky.class))
|
||||
shared.dumpTable(shared.stinkyTracker.stinkies:get())
|
||||
shared.dumpTable(shared.stinkyTracker.ignored:get())
|
||||
shared.dump(shared.stinkyTracker.stinkies:get())
|
||||
shared.dump(shared.stinkyTracker.ignored:get())
|
||||
end
|
||||
return true
|
||||
end,
|
||||
@@ -66,8 +66,8 @@ shared.StinkyTracker = {
|
||||
shared.stinkyTracker.stinkies[name] = nil
|
||||
if Heimdall_Data.config.stinkyTracker.debug then
|
||||
print(string.format("[%s] Stinky is now ignored: %s", ModuleName, name))
|
||||
shared.dumpTable(shared.stinkyTracker.ignored:get())
|
||||
shared.dumpTable(shared.stinkyTracker.stinkies:get())
|
||||
shared.dump(shared.stinkyTracker.ignored:get())
|
||||
shared.dump(shared.stinkyTracker.stinkies:get())
|
||||
end
|
||||
end,
|
||||
|
||||
@@ -125,7 +125,7 @@ shared.StinkyTracker = {
|
||||
date("%H:%M:%S", time())
|
||||
)
|
||||
)
|
||||
shared.dumpTable(stinkies)
|
||||
shared.dump(stinkies)
|
||||
end
|
||||
end
|
||||
return stinkies
|
||||
@@ -164,7 +164,7 @@ shared.StinkyTracker = {
|
||||
date("%H:%M:%S", time())
|
||||
)
|
||||
)
|
||||
shared.dumpTable(stinkies)
|
||||
shared.dump(stinkies)
|
||||
end
|
||||
return stinkies
|
||||
end
|
||||
@@ -197,7 +197,7 @@ shared.StinkyTracker = {
|
||||
stinkies[name] = stinky
|
||||
if Heimdall_Data.config.stinkyTracker.debug then
|
||||
print(string.format("%s: Found stinky in arrived: %s/%s", ModuleName, name, class))
|
||||
shared.dumpTable(stinkies)
|
||||
shared.dump(stinkies)
|
||||
end
|
||||
return stinkies
|
||||
end
|
||||
@@ -231,7 +231,7 @@ shared.StinkyTracker = {
|
||||
end
|
||||
if Heimdall_Data.config.stinkyTracker.debug then
|
||||
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
|
||||
|
||||
local stinkies = {}
|
||||
@@ -242,7 +242,7 @@ shared.StinkyTracker = {
|
||||
local whoStinkies = ParseWho(msg)
|
||||
if Heimdall_Data.config.stinkyTracker.debug then
|
||||
print(string.format("[%s] Found stinkies in WHO message", ModuleName))
|
||||
shared.dumpTable(whoStinkies)
|
||||
shared.dump(whoStinkies)
|
||||
end
|
||||
for name, stinky in pairs(whoStinkies) do
|
||||
stinkies[name] = stinky
|
||||
@@ -255,7 +255,7 @@ shared.StinkyTracker = {
|
||||
local seeStinkies = ParseSee(msg)
|
||||
if Heimdall_Data.config.stinkyTracker.debug then
|
||||
print(string.format("[%s] Found stinkies in SEE message", ModuleName))
|
||||
shared.dumpTable(seeStinkies)
|
||||
shared.dump(seeStinkies)
|
||||
end
|
||||
for name, stinky in pairs(seeStinkies) do
|
||||
stinkies[name] = stinky
|
||||
@@ -268,7 +268,7 @@ shared.StinkyTracker = {
|
||||
local arrivedStinkies = ParseArrived(msg)
|
||||
if Heimdall_Data.config.stinkyTracker.debug then
|
||||
print(string.format("[%s] Found stinkies in ARRIVED message", ModuleName))
|
||||
shared.dumpTable(arrivedStinkies)
|
||||
shared.dump(arrivedStinkies)
|
||||
end
|
||||
for name, stinky in pairs(arrivedStinkies) do
|
||||
stinkies[name] = stinky
|
||||
|
||||
@@ -176,7 +176,7 @@ shared.Whoer = {
|
||||
if Heimdall_Data.config.who.debug then
|
||||
print(string.format("[%s] WHO query: %s with %d filters", ModuleName, queryParts[1], #filters))
|
||||
end
|
||||
shared.dumpTable(filters)
|
||||
shared.dump(filters)
|
||||
return WHOQuery.new(queryParts[1], filters)
|
||||
end,
|
||||
---@param queryStr string
|
||||
@@ -321,7 +321,7 @@ shared.Whoer = {
|
||||
}
|
||||
if Heimdall_Data.config.who.debug then
|
||||
print(string.format("[%s] Queuing channel notification", ModuleName))
|
||||
shared.dumpTable(msg)
|
||||
shared.dump(msg)
|
||||
end
|
||||
table.insert(shared.networkMessenger.queue, msg)
|
||||
end
|
||||
@@ -380,7 +380,7 @@ shared.Whoer = {
|
||||
}
|
||||
if Heimdall_Data.config.who.debug then
|
||||
print(string.format("[%s] Queuing channel notification", ModuleName))
|
||||
shared.dumpTable(msg)
|
||||
shared.dump(msg)
|
||||
end
|
||||
table.insert(shared.networkMessenger.queue, msg)
|
||||
end
|
||||
@@ -431,7 +431,7 @@ shared.Whoer = {
|
||||
}
|
||||
if Heimdall_Data.config.who.debug then
|
||||
print(string.format("[%s] Queuing channel notification", ModuleName))
|
||||
shared.dumpTable(msg)
|
||||
shared.dump(msg)
|
||||
end
|
||||
--table.insert(shared.messenger.queue, msg)
|
||||
table.insert(shared.networkMessenger.queue, msg)
|
||||
|
||||
Reference in New Issue
Block a user