Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local frame = CreateFrame("Frame")
- local timer = frame:CreateAnimationGroup()
- timer.animation = timer:CreateAnimation()
- timer.animation:SetDuration(1)
- timer.animation:SetOrder(1)
- timer.frame = frame
- timer.testMode = true
- local didAction, lastName, lastAction
- timer:SetScript("OnFinished", function(self)
- didAction = false
- for i = 1, GetNumGuildMembers() do
- local name, _, rankIndex, level, _, _, _, _, _, _, classFileName = GetGuildRosterInfo(i)
- -- Make it consistent with values for SetGuildMemberRank() for sanity's sake.
- rankIndex = rankIndex + 1
- if rankIndex == 1 or rankIndex == 2 or rankIndex == 3 then -- Guild master, Officers, Intouchables
- return
- end
- if CanGuildPromote() then
- local targetRank
- if level >= 1 and level <= 79 and rankIndex ~= 7 then
- targetRank = 7
- elseif level >= 80 and level <= 84 and rankIndex ~= 6 then
- targetRank = 6
- elseif level >= 85 and level <= 89 and rankIndex ~= 5 then
- targetRank = 5
- elseif level == 90 and rankIndex ~= 4 then
- targetRank = 4
- end
- if self.testMode then
- print("PROMOTE", name, targetRank)
- else
- if lastAction == "PROMOTE" and lastName == name then
- -- Avoid infinite loops if the action is failing:
- return print("Action failed:", lastAction, lastName, targetRank)
- end
- didAction, lastAction, lastName = true, "PROMOTE", name
- SetGuildMemberRank(i, targetRank)
- break
- end
- end
- if not ignoreList[name] and CanGuildRemove() then
- local year, month, day = GetGuildRosterLastOnline(i)
- -- (year > 0 or month > 0 or day > 21)
- if year and (
- (rankIndex == 7
- and (day >= 1 and level == 1)
- or (day >= 2 and level == 5 and classFileName == "DEATHKNIGHT")
- or (day >= 3 and ((level > 1 and level <= 5) or (level > 55 and level <= 55 and classFileName == "DEATHKNIGHT")))
- or (day >= 14 and level > 5 and level <= 79)
- )
- or (rankIndex == 6 and day >= 21)
- or ((rankIndex == 4 or rankIndex == 5) and day >= 28)
- ) then
- if self.testMode then
- print("REMOVE", name)
- else
- if lastAction == "REMOVE" and lastName == name then
- -- Avoid infinite loops if the action is failing:
- return print("Action failed:", lastAction, lastName)
- end
- didAction, lastAction, lastName = true, "REMOVE", name
- GuildUninvite(name)
- break
- end
- end
- end
- end
- -- Start it again if we did something.
- if didAction then
- self:Play()
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement