Code:
local
on = 1
local
whispCommand = "www"
local
aName, aTable = ...
local
pName = aName..": "
function
aTable:OnEvent(event, ...)
local
msg, name = ...
if
event == "CHAT_MSG_WHISPER"then
aTable.ginv(msg, name)
end
end
function
aTable.ginv(msg, name)
if
msg == whispCommand then
GuildInvite(name)
else
return
end
end
local
f = CreateFrame("Frame")
f:RegisterEvent(
"CHAT_MSG_WHISPER")
f:SetScript(
"OnEvent", aTable.OnEvent)
--Local # variables
local
levelStart = 85
local
levelEnd = 85
local
levelProgress = 1
local
levelIncrement = 5
local
lstGathered = 0
local
numWhos = 0
local
declineCount = 0
local
lastClass, lastRace = 1, 1
--Local table variable(s)
local
Inviteable = { ['CHARNAME'] = {} }
local
classes = { "Priest", "Warrior", "Warlock", "Druid", "Rogue", "Mage", "Hunter", "Paladin", "Shaman", "Death Knight" }
local
racesA = { "Gnome", "Human", "Night Elf", "Draenei", "Dwarf", "Worgen" }
local
racesH = { "Undead", "Orc", "Troll", "Blood Elf", "Tauren", "Goblin" }
--Default Settings, if we don't have them saved this is what gets put in.
DefaultSettings = {
[
"msg"] = "Hello. Would you like to join my guild? If you decline, you will not get this message again.",
[
"msgPlayer"] = false,
[
"verbose"] = true,
[
"autostart"] = true,
}
--This is called after a who search is COMPLETED.
function
frame:WHO_LIST_UPDATE()
numWhos = GetNumWhoResults()
or 0
for
i=1, numWhos do
name, guild, level, race, class, zone, group = GetWhoInfo(i);
if (guild=="") then
local AlreadyInvited = false
local pattern = "[0-9\| :]";
if( string.find( name, pattern ) ~= nil ) then--this happens sometimes when in BG
AlreadyInvited =
true--so we'll exclude that name
end
for v in pairs(Inviteable.CHARNAME) do
if (name:lower()==Inviteable.CHARNAME[v]:lower()) then
AlreadyInvited =
true
end
end
for v in pairs(Invited.CHARNAME) do
if (name:lower()==Ni_Invited.CHARNAME[v]:lower()) then
AlreadyInvited =
true
end
end
if (level==1) then
AlreadyInvited =
true
end
if (AlreadyInvited==false) then
table.insert(Inviteable.CHARNAME,name)
lstGathered = lstGathered
or 0
lstGathered = lstGathered + 1
end
end
end
if
(forceShort == false) then
if
(longSearch == true) then
if (uberLongSearch == true) then
lastRace = lastRace + 1;
if (racesH[lastRace] == nil) then
uberLongSearch =
false;
lastClass = lastClass + 1;
if (classes[lastClass] == nil) then
longSearch =
false;
levelStart = levelStart + levelIncrement;
end
end
else
if (numWhos >= 49) then
lastRace = 1;
uberLongSearch =
true;
return
end
lastClass = lastClass + 1;
if (classes[lastClass] == nil) then
longSearch =
false;
levelStart = levelStart + levelIncrement;
end
end
else
if (numWhos >= 49) then
lastClass = 1;
longSearch =
true;
return
else
longSearch =
false;
levelStart = levelStart + levelIncrement;
end
end
else
levelStart = levelStart + levelIncrement;
end
if
(levelStart>=levelEnd) then
StopSearch()
end
end
--This function stops all searching, resets some variables.
function
StopSearch()
searching =
false
FriendsFrame:RegisterEvent(
"WHO_LIST_UPDATE");
SetWhoToUI(0)
Message(
"Stopped")
print (
"Gathered " .. table.getn(Inviteable.CHARNAME) .. " characters.")
frame:UnregisterEvent
"WHO_LIST_UPDATE"
levelStart = 85
lastClass = 1
lastRace = 1
longSearch =
false
uberLongSearch =
false
forceShort =
false
if (Ni_Settings.autostart == true) then
SlashCmdList.GINV(
"startinvite")
end
end