# HG changeset patch # User John@Doomsday # Date 1335534086 14400 # Node ID 0cd1d46e7b6664aaeecfc753fb3055750fbeeb5d # Parent 19fd02bff87043392f7917fe1d9c5d9041ad68db Admin detection from a string of the format "BSKADMIN: admin1, admin2, ..." in the guild info box diff -r 19fd02bff870 -r 0cd1d46e7b66 Admin.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Admin.lua Fri Apr 27 09:41:26 2012 -0400 @@ -0,0 +1,60 @@ +local bsk=bsk +local _G=_G +local table=table +local pairs=pairs +local setmetatable=setmetatable +local ipairs=ipairs +local string=string +local sformat=string.format +local strsplit=strsplit +local tostring=tostring +local type=type +local unpack=unpack +local getn=getn +setfenv(1,bsk) + +adminList = {} + +local function GuildRosterUpdate() + local guildInfoText = _G.GetGuildInfoText() + local newAdminList = {} + for line in guildInfoText:gmatch("[^\r\n]+") do + local l,r = line:match("(.*):(.*)") -- could use wow strsplit had I known about it before writing this + l = string.trim(l or "") + r = string.trim(r or "") + if l == "BSKADMIN" then -- found a juicy line. may contain multiple, comma delimited + local admins = {strsplit(", ",r)} + for _,a in pairs(admins) do + a = string.trim(a or "") + if a ~= "" then + newAdminList[a] = true + end + end + end + end + + if _G.next(adminList) ~= nil then -- had old admins. don't want to spam on initial load + -- diff new vs old + for a in pairs(adminList) do + if not newAdminList[a] then + print("Admin removed:", a) + end + end + for a in pairs(newAdminList) do + if not adminList[a] then + print("Admin added:",a) + end + end + end + adminList = newAdminList +end + +function InitializeAdmin() + if not event then + _G.error("BSK: Improper order of initialization") + end + event:RegisterEvent("GUILD_ROSTER_UPDATE",GuildRosterUpdate) + _G.GuildRoster() -- will eventually force the event to fire +end + + diff -r 19fd02bff870 -r 0cd1d46e7b66 Core.lua --- a/Core.lua Fri Apr 27 08:26:17 2012 -0400 +++ b/Core.lua Fri Apr 27 09:41:26 2012 -0400 @@ -68,6 +68,7 @@ bsk:OnInitializeSetStaticData() InitializeComm() InitializeLooting() + InitializeAdmin() end function OnEnable() diff -r 19fd02bff870 -r 0cd1d46e7b66 Looting.lua --- a/Looting.lua Fri Apr 27 08:26:17 2012 -0400 +++ b/Looting.lua Fri Apr 27 09:41:26 2012 -0400 @@ -11,6 +11,7 @@ local getn=getn local event = LibStub("AceEvent-3.0") +bsk.event = event setfenv(1,bsk) diff -r 19fd02bff870 -r 0cd1d46e7b66 breuesk.toc --- a/breuesk.toc Fri Apr 27 08:26:17 2012 -0400 +++ b/breuesk.toc Fri Apr 27 09:41:26 2012 -0400 @@ -35,4 +35,4 @@ Comm.lua State.lua Looting.lua - +Admin.lua