-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAutoUninviteOffline.lua
More file actions
45 lines (38 loc) · 1.15 KB
/
AutoUninviteOffline.lua
File metadata and controls
45 lines (38 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
local frame = CreateFrame("Frame")
local addonEnabled = false
local checkInterval = 5 -- Seconds between checks
local lastCheck = GetTime()
-- Event registration
frame:RegisterEvent("GROUP_ROSTER_UPDATE")
frame:RegisterEvent("PLAYER_FLAGS_CHANGED")
frame:RegisterEvent("PARTY_MEMBERS_CHANGED")
-- OnUpdate handler
frame:SetScript("OnUpdate", function(self)
if not addonEnabled then return end
local now = GetTime()
if (now - lastCheck) >= checkInterval then
CheckOfflineMembers()
lastCheck = now
end
end)
function CheckOfflineMembers()
local inParty = GetNumPartyMembers() > 0
if not (inParty or IsPartyLeader() == 1) then return end
for i = 1, GetNumPartyMembers() do
local unit = "party" .. i
if UnitExists(unit) then
local name = UnitName(unit)
local online = UnitIsConnected(unit)
if not online then
UninviteByName(name)
print(name .. " uninvited (offline).")
end
end
end
end
-- Slash command
SLASH_AUTOUNINVITE1 = "/auo"
SlashCmdList["AUTOUNINVITE"] = function()
addonEnabled = not addonEnabled
print("Auto Uninvite Offline: " .. (addonEnabled and "Enabled" or "Disabled"))
end