Code format
Some checks failed
Release Workflow / release (push) Failing after 23s

This commit is contained in:
2025-05-04 15:09:34 +02:00
parent 304fbcbaae
commit 1da1e7bf9f
30 changed files with 4620 additions and 4241 deletions

View File

@@ -29,7 +29,7 @@ local helpMessages = {
"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.",
}
},
}
---@diagnostic disable-next-line: missing-fields
@@ -51,16 +51,12 @@ function shared.Commander.Init()
if #currentChunk + #word + 1 <= size then
currentChunk = currentChunk .. (currentChunk == "" and word or " " .. word)
else
if #currentChunk > 0 then
ret[#ret + 1] = currentChunk
end
if #currentChunk > 0 then ret[#ret + 1] = currentChunk end
currentChunk = word
end
end
if #currentChunk > 0 then
ret[#ret + 1] = currentChunk
end
if #currentChunk > 0 then ret[#ret + 1] = currentChunk end
return ret
end
@@ -69,9 +65,7 @@ function shared.Commander.Init()
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
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
@@ -95,8 +89,13 @@ function shared.Commander.Init()
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 "")
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
@@ -119,9 +118,7 @@ function shared.Commander.Init()
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
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
@@ -144,36 +141,27 @@ function shared.Commander.Init()
end
local function CountClassPartitionedStinkies()
if Heimdall_Data.config.commander.debug then
print(string.format("[%s] Executing: CountClassPartitionedStinkies",
ModuleName))
print(string.format("[%s] Executing: CountClassPartitionedStinkies", ModuleName))
end
local res = CountClassPartitioned(HeimdallStinkies)
if #res == 0 then
return { "No stinkies found" }
end
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))
print(string.format("[%s] Executing: WhoPartitionedStinkies", ModuleName))
shared.dumpTable(HeimdallStinkies)
end
local res = WhoPartitioned(HeimdallStinkies)
if #res == 0 then
return { "No stinkies found" }
end
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))
print(string.format("[%s] Executing: CountPartitionedStinkies", ModuleName))
end
local res = CountPartitioned(HeimdallStinkies)
if #res == 0 then
return { "No stinkies found" }
end
if #res == 0 then return { "No stinkies found" } end
return res
end
local function HelpRu()
@@ -190,26 +178,32 @@ function shared.Commander.Init()
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
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
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)
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
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 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 {}
@@ -218,14 +212,12 @@ function shared.Commander.Init()
---@param args string[]
local function MacroTarget(args)
if Heimdall_Data.config.commander.debug then
print(string.format("[%s] Macroing: %s", ModuleName,
strjoin(" ", unpack(args))))
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))
print(string.format("[%s] Invalid number of arguments for MacroTarget", ModuleName))
end
return {}
end
@@ -243,7 +235,7 @@ function shared.Commander.Init()
name = name,
class = class or "unknown",
seenAt = GetTime(),
hostile = true
hostile = true,
}
end
return {}
@@ -255,15 +247,15 @@ function shared.Commander.Init()
---@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 = "^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 = "^follow$", commanderOnly = false, callback = FollowTarget },
{ keywordRe = "^macro", commanderOnly = false, callback = MacroTarget },
}
local commanderChannelFrame = CreateFrame("Frame")
@@ -290,8 +282,14 @@ function shared.Commander.Init()
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, ", ")))
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
@@ -307,10 +305,13 @@ function shared.Commander.Init()
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
or (command.commanderOnly
and sender == Heimdall_Data.config.commander.commander)) then
if
enabled
and (
not command.commanderOnly
or (command.commanderOnly and sender == Heimdall_Data.config.commander.commander)
)
then
if msg:match(command.keywordRe) then
local messages = command.callback({ strsplit(",", msg) })
if Heimdall_Data.config.commander.debug then
@@ -321,7 +322,7 @@ function shared.Commander.Init()
local msg = {
channel = "C",
data = channelname,
message = message
message = message,
}
if Heimdall_Data.config.commander.debug then
print(string.format("[%s] Queuing message", ModuleName))