1
0
Fork 0

miscellaneous module

This commit is contained in:
pigmonkey 2011-05-30 14:38:32 -04:00
parent 3a2e046a41
commit ff77c954eb
4 changed files with 207 additions and 95 deletions

View file

@ -10,30 +10,6 @@ local options = {
name = "All The Little Things",
type = 'group',
args = {
rollTally = {
order = 30,
name = "Roll Tally",
desc = "Tallies rolls for 8s after a raid warning with 'roll' in the message. Can also activate with /atlt rt.",
type = "toggle",
get = function(info) return core.db.profile.rollTally end,
set = function(info, v) core.db.profile.rollTally = v core:OnEnable() end,
},
nixAFK = {
order = 30,
name = "Remove AFK Responses",
desc = "Removes AFK responses when whispering AFK players.",
type = "toggle",
get = function(info) return core.db.profile.nixAFK end,
set = function(info, v) core.db.profile.nixAFK = v core:OnEnable() end,
},
achieveFilter = {
order = 45,
name = "Achievement Filter",
desc = "Sets achievement filter to Incomplete automatically.",
type = "toggle",
get = function(info) return core.db.profile.achieveFilter end,
set = function(info, v) core.db.profile.achieveFilter = v core:OnEnable() end,
},
officerPhone = {
order = 60,
name = "Officer Phone Records",
@ -42,14 +18,6 @@ local options = {
get = function(info) return core.db.profile.officerPhone end,
set = function(info, v) core.db.profile.officerPhone = v core:OnEnable() end,
},
markMsgFilter = {
order = 70,
name = "Mark Message Filter",
desc = "Filters mark messages caused by the player.",
type = 'toggle',
get = function(info) return core.db.profile.markMsgFilter end,
set = function(info, v) core.db.profile.markMsgFilter = v core:OnEnable() end,
},
},
}
local defaults = {
@ -58,12 +26,8 @@ local defaults = {
x = 100,
y = 100,
},
alwaysDump = true,
isGay = false,
nixAFK = true,
consolidateThresh = 0,
officerPhone = true,
markMsgFilter = true,
halloween = 1,
guildXPMarks = { },
}
@ -81,36 +45,9 @@ function core:OnInitialize()
-- options.args.profile = LibStub("AceDBOptions-3.0"):GetOptionsTable(self.db)
LibStub("AceConfig-3.0"):RegisterOptionsTable("ATLT", options)
self.optionsFrame = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("ATLT", "All The Little Things")
ConsoleExec("cameradistancemaxfactor 5")
end
function core:OnEnable()
SetModifiedClick("TRADESEARCHADD", nil)
if self.db.profile.rollTally then
self:RegisterEvent("CHAT_MSG_RAID_WARNING")
self:RegisterEvent("CHAT_MSG_SYSTEM")
end
if self.db.profile.nixAFK then
ChatFrame_AddMessageEventFilter("CHAT_MSG_AFK", function(...) return self:NixAFK(...); end);
end
if self.db.profile.markMsgFilter then
ChatFrame_AddMessageEventFilter("CHAT_MSG_TARGETICONS", function(_,_,msg) if (msg:find("%["..UnitName("player").."%]")) then return true; end end);
end
if self.db.profile.autoWG then
self:RegisterEvent("BATTLEFIELD_MGR_ENTRY_INVITE")
end
if self.db.profile.eotsFlag and not self.eotsHook then
end
if self.db.profile.achieveFilter and not self.achieveHook then
self:RawHook("AchievementFrame_LoadUI", true)
self.achieveHook = true
end
-- if (self.db.profile.consolidateThresh>0) and (not self.consolidateHook) then
-- self:RawHook("UnitAura", true)
-- self.consolidateHook = true
-- end
if (self.db.profile.officerPhone) then
self:RegisterEvent("CHAT_MSG_OFFICER");
end
@ -130,7 +67,6 @@ function core:SlashProcess(msg)
if msg == "debug" then
self:BugInit()
elseif msg == "rolltally" or msg == "rt" then
self:CHAT_MSG_RAID_WARNING(nil, "roll")
elseif msg == "phone" then
-- prints missing phone numbers
self:FindMissingPhones();
@ -356,17 +292,6 @@ function core:SlashProcess(msg)
end
end
function core:CHAT_MSG_RAID_WARNING(_, message)
if self.db.profile.rollTally and string.find(message:lower(), "roll") then
if self.rollTimer then
-- Stop current roll
self:CancelTimer(self.rollTimer)
self:RollFinish()
end
self.rollTally = {}
self.rollTimer = self:ScheduleTimer("RollFinish", 10)
end
end
function core:UNIT_AURA(_, unit)
-- if we haven't set the initial value yet, set and quit
@ -535,24 +460,6 @@ function core:CheckPhone(index)
return nil, nil;
end
function core:FindMissingPhones()
local found = false;
for i=1,GetNumGuildMembers() do
local player, num = self:CheckPhone(i);
if (player and not num) then
if (not found) then
self:Print("Players without phone numbers:");
found = true;
end
self:Print(player);
end
end
if (not found) then
self:Print("All players have a phone number.");
end
end
function core:TargetUnit(name)
if name and GetNumPartyMembers() == 0 and GetNumRaidMembers() == 0 then
self:RegisterEvent("UNIT_TARGET", function(_, unit)

View file

@ -35,6 +35,7 @@ end
function mod:OnEnable()
self:RawHook("WorldStateAlwaysUpFrame_Update", true)
self:RegisterEvent("BATTLEFIELD_MGR_ENTRY_INVITE")
self:RegisterEvent("CHAT_MSG_BG_SYSTEM_ALLIANCE", "BattlegroundMessage")
self:RegisterEvent("CHAT_MSG_BG_SYSTEM_HORDE", "BattlegroundMessage")
end

204
modules/miscellaneous.lua Normal file
View file

@ -0,0 +1,204 @@
local core = LibStub("AceAddon-3.0"):GetAddon("AllTheLittleThings")
local mod = core:NewModule("Miscellaneous", "AceEvent-3.0", "AceConsole-3.0", "AceHook-3.0", "AceTimer-3.0")
local db = core.db.profile[mod:GetName()]
local defaults = {
rollTally = true,
nixAFK = true,
achieveFilter = true,
markMsgFilter = true,
officerPhone = true,
}
local options = {
rollTally = {
name = "Roll Tally",
desc = "Tallies rolls for 8s after a raid warning with 'roll' in the message. Can also activate with /atlt rt.",
type = "toggle",
},
nixAFK = {
name = "Remove AFK Responses",
desc = "Removes AFK responses when whispering AFK players.",
type = "toggle",
},
achieveFilter = {
name = "Achievement Filter",
desc = "Sets achievement filter to Incomplete automatically.",
type = "toggle",
},
markMsgFilter = {
name = "Mark Message Filter",
desc = "Filters mark messages caused by the player.",
type = 'toggle',
},
officerPhone = {
name = "Officer Phone Records",
desc = "Allows !phone <player>",
type = 'toggle',
},
}
function mod:OnInitialize()
core:RegisterOptions(options, defaults)
core:RegisterSlashCommand("RollTally", "rt", "rolltally")
core:RegisterSlashCommand("FindPhones", "phone")
core:RegisterSlashCommand("ActiveTally", "at", "activetally")
-- allow max camera zoom
ConsoleExec("cameradistancemaxfactor 5")
end
function mod:OnEnable()
-- allow split with tradeskill
SetModifiedClick("TRADESEARCHADD", nil)
-- roll tally
self:RegisterEvent("CHAT_MSG_RAID_WARNING")
self:RegisterEvent("CHAT_MSG_SYSTEM")
-- nix afk
ChatFrame_AddMessageEventFilter("CHAT_MSG_AFK", function(...) return self:NixAFK(...); end);
-- achieve filter
self:RawHook("AchievementFrame_LoadUI", true)
-- target icons
self:SecureHook("TargetUnit")
-- filter self targets
ChatFrame_AddMessageEventFilter("CHAT_MSG_TARGETICONS", function(_,_,msg) if (msg:find("%["..UnitName("player").."%]")) then return true; end end);
-- officer phone
self:RegisterEvent("CHAT_MSG_OFFICER");
end
-- Slash Commands --------------------------------------------------------------
function mod:RollTally()
self:CHAT_MSG_RAID_WARNING(nil, "roll")
end
function mod:FindPhones()
local found = false;
for i=1,GetNumGuildMembers() do
local player, num = self:CheckPhone(i);
if (player and not num) then
if (not found) then
self:Print("Players without phone numbers:");
found = true;
end
self:Print(player);
end
end
if (not found) then
self:Print("All players have a phone number.");
end
end
function mod:ActiveTally(mode)
local showTotal = mode=="t" or mode=="total"
local function printInfo(msg)
-- self:Print(msg)
SendChatMessage(msg, "guild")
end
local mains = {}
local alts = {} -- really a table of the mains as the key, alt totals as the value, but we'll merge later once we can confirm
local capped = {} -- table of mains who hit cap
for i=1,GetNumGuildMembers() do
local name, rank, _, _, _, _, note = GetGuildRosterInfo(i)
local xp, total = GetGuildRosterContribution(i)
local tbl = mains
if showTotal then
xp = total
end
if rank:find("Alt") then
name, tbl = note, alts
end
if rank ~= "Non-raider" or name == "Ariik" then
if not tbl[name] then
tbl[name] = 0
end
tbl[name] = tbl[name] + xp
if xp == 1575002 then
-- don't think there is a weekly cap
-- capped[name] = true
end
end
end
-- total and merge alts
local total = 0
for k,v in pairs(mains) do
mains[k] = mains[k] + (alts[k] or 0)
total = total + mains[k]
end
-- print using selection sort
printInfo("Top contributors for the week; alts included:")
while next(mains) ~= nil do
local max, maxVal = "-", -1
for k,v in pairs(mains) do
if v > maxVal then
max, maxVal = k, v
end
end
printInfo(format("%s%s - %d (%.1f%%)", (capped[max] and "*" or ""), max, maxVal, maxVal/total*100))
mains[max] = nil
end
end
-- Roll Tally ------------------------------------------------------------------
function core:CHAT_MSG_RAID_WARNING(_, message)
if self.db.profile.rollTally and string.find(message:lower(), "roll") then
if self.rollTimer then
-- Stop current roll
self:CancelTimer(self.rollTimer)
self:RollFinish()
end
self.rollTally = {}
self.rollTimer = self:ScheduleTimer("RollFinish", 10)
end
end
-- Officer Phone ---------------------------------------------------------------
function core:CHAT_MSG_OFFICER(_, msg)
local _,_,numA,numB,numC = msg:find("!phone %(?(%d+)%)?.(%d+).(%d+)");
local _,_,name = msg:find("!phone (%w+)");
if (not (numA and numB and numC) and not name) then
return;
end
local setting = GetGuildRosterShowOffline();
SetGuildRosterShowOffline(1);
for i=1,GetNumGuildMembers() do
local p, n = self:CheckPhone(i);
if ((name and p and p:lower():find(name:lower())) or
(numA and n and format("%s-%s-%s", numA, numB, numC)==n)) then
if (n) then
SendChatMessage(format("%s: %s", p, n), "officer");
else
SendChatMessage(format("No %s for %s.", (numA and "name") or "number", p), "officer");
end
end
end
SetGuildRosterShowOffline(setting);
end
function core:CheckPhone(index)
local name, rank, _, _, _, _, _, onote = GetGuildRosterInfo(index);
local a, b, c = onote:match("%(?(%d%d%d)%)?.(%d%d%d).(%d%d%d%d)");
if (not rank:find("Alt") and not rank:find("Non")) then
if (a) then
return name, format("%s-%s-%s", a, b, c);
end
return name, nil;
end
return nil, nil;
end

View file

@ -19,11 +19,11 @@ local mailQueue = {} -- used in /atlt pots
function mod:OnInitialize()
core:RegisterSlashCommand("AddPotions", "pots")
self:RegisterEvent("MAIL_SHOW", "MailQueueCheck");
self:RegisterEvent("MAIL_SUCCESS", "MailQueueCheck");
end
function mod:OnEnable()
self:RegisterEvent("MAIL_SHOW", "MailQueueCheck");
self:RegisterEvent("MAIL_SUCCESS", "MailQueueCheck");
end
function mod:AddPotions()