Fix up the log messages a lil

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

View File

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