Untested, but something like this should work:
World of Warcraft\Interface\AddOns\GuildBlacklist\
GuildBlacklist.toc
Code:
## Interface: 40300
## Title: Guild Blacklist
## Notes: Keeps a list of players you don't want in your guild because they already left or were kicked.
## SavedVariables: GuildBlacklistDB
GuildBlacklist.lua
World of Warcraft\Interface\AddOns\GuildBlacklist\
GuildBlacklist.lua
Code:
------------------------------------------------------------------------
-- Local variables
------------------------------------------------------------------------
local blacklist, new, old
local notes, officerNotes = {}, {}
------------------------------------------------------------------------
-- Addon functions/logic
------------------------------------------------------------------------
local addon = CreateFrame("Frame")
addon:RegisterEvent("PLAYER_GUILD_UPDATE")
addon:RegisterEvent("PLAYER_LOGIN")
addon:SetScript("OnEvent", function(self, event, ...)
if event == "GUILD_ROSTER_UPDATE" then
if not new then
-- First run for this guild.
new = {}
else
new, old = old, new
wipe(new)
end
for i = 1, GetNumGuildMembers() do
local name, _, _, level, class, _, note, officerNote, online = GetGuildRosterInfo(i)
new[name] = string.format(FRIENDS_LEVEL_TEMPLATE, level, class)
notes[name] = note
officerNotes[name] = officerNote
end
for name, info in pairs(old) do
if not new[name] then
print(string.format("%s (%s) is now on the blacklist because they are no longer in the guild.", name, info))
blacklist[name] = info
end
end
for name, info in pairs(new) do
if blacklist[name] then
print(string.format("%s (%s) is on the blacklist!", name, info))
if notes[name] then
print(" Guild note:", notes[name])
end
if officerNotes[name] then
print(" Officer note:", officerNotes[name])
end
end
end
elseif event == "PLAYER_GUILD_UPDATE" or event == "PLAYER_LOGIN" then
local guild = IsInGuild() and GetGuildInfo("player")
if not guild then
self:UnregisterEvent("GUILD_ROSTER_UPDATE")
blacklist = nil
return
end
if not GuildBlacklistDB then
GuildBlacklistDB = {}
end
local realm = GetRealmName()
if not GuildBlacklistDB[realm] then
GuildBlacklistDB[realm] = {}
end
if not GuildBlacklistDB[realm][guild] then
GuildBlacklistDB[realm][guild] = {}
end
blacklist = GuildBlacklistDB[realm][guild]
new, old = nil, {}
for name, info in pairs(blacklist) do
old[name] = info
end
self:RegisterEvent("GUILD_ROSTER_UPDATE")
GuildRoster()
end
end)
------------------------------------------------------------------------
-- Slash command interface
------------------------------------------------------------------------
SLASH_GUILDBLACKLIST1 = "/guildblacklist"
SLASH_GUILDBLACKLIST2 = "/gbl"
SlashCmdList.GUILDBLACKLIST = function(input)
if not blacklist then
return print("|cffffcc00GuildBlacklist:|r", ERR_GUILD_PLAYER_NOT_IN_GUILD)
end
local cmd, arg = input:trim():lower():match("(%S+)%s*(.+*)")
if cmd == "add" then
local name = arg:gsub("%a", string.upper, 1)
if not blacklist[name] then
blacklist[name] = true
return print("|cffffcc00GuildBlacklist:|r", string.format("%s has been added to the blacklist.", name))
else
return print("|cffffcc00GuildBlacklist:|r", string.format("%s is already on the blacklist.", name))
end
elseif cmd == "remove" then
local name = arg:gsub("%a", string.upper, 1)
if blacklist[name] then
blacklist[name] = nil
return print("|cffffcc00GuildBlacklist:|r", string.format("%s is no longer blacklisted.", name))
else
return print("|cffffcc00GuildBlacklist:|r", string.format("%s was not found on the blacklist. Check your spelling and try again."))
end
elseif cmd == "list" then
local sorted = {}
for name in pairs(blacklist) do
sorted[#sorted+1] = name
end
table.sort(sorted)
if #sorted < 1 then
print("|cffffcc00GuildBlacklist:|r", "The blacklist is currently empty.")
else
print("|cffffcc00GuildBlacklist:|r", string.format("There are currently %d names on the blacklist:", #sorted))
for i = 1, #sorted do
print(string.format(" %s - %s", name, blacklist[name] or UNKNOWN))
end
end
else
print("|cffffcc00GuildBlacklist:|r", "The following commands are available:")
print(" - add <name> - Adds <name> to the blacklist.")
print(" - remove <name> - Removes <name> from the blacklist.")
print(" - list - Lists all names currently on the blacklist.")
end
end
Any time there's a guild change, it will add anyone who left to the blacklist, and report any guild members who are on the blacklist.
Type "/gbl" for a few options.