So the problem, I don't want to be an auto guild inviter that just spams everyone all the time. I find it distasteful and annoying, so my solution is to use TBA to announce and alter a party whisper invite mod to do the invite as soon as they decide to ask for an invite.
I chose TBA as a good choice because it catalogues all the people whispered and will not whisper for another 2 weeks(if they're still un-guilded).
The addon I've chosen to modify is WhisperInviter because its very simple and i figured I could single out the command pretty easily to change in order to get it to do a guild invite instead of party/raid invite. I've was successful in one aspect of the modification, removing the group size/leadership requirements, but the ultimate goal was still not met.
my current script looks like:
Code:
local addonName, WhisperGuildInvite = ...;
WhisperGuildInvite.name = addonName;
WhisperGuildInvite.version = GetAddOnMetadata(addonName, "Version");
function WhisperInvite:GuildInvite(name)
if not self.settings.enabled then
return false, "disabled";
end
-- 0 when no one else is in the same party
local partyMemberCount = GetRealNumPartyMembers();
-- 0 when not in a raid
local raidMemberCount = GetRealNumRaidMembers();
if raidMemberCount == 0 then
-- Not in raid
if partyMemberCount == 0 then
-- Solo
GuildInviteUnit(name);
return true;
end
end;
end;
--[[ Event Management ]]
function WhisperGuildInvite:RegisterEvents(eventList)
for event, handler in pairs(eventList) do
self.eventFrame:RegisterEvent(event);
end
end;
function WhisperGuildInvite:UnregisterEvents(eventList)
for event, handler in pairs(eventList) do
self.eventFrame:UnregisterEvent(event);
end
end;
--[[ Frame Event Handling ]]
WhisperGuildInvite.events = {
["VARIABLES_LOADED"] =
function (self)
if not WhisperGuildInvite_Persistent then
WhisperGuildInvite_Persistent =
{
enabled = true;
autoconvert = true;
keyword = "invite";
};
end;
self.settings = WhisperInvite_Persistent;
end;
["PLAYER_LOGIN"] =
function (self)
end;
["PLAYER_REGEN_DISABLED"] =
function (self)
end;
["PLAYER_REGEN_ENABLED"] =
function (self)
end;
["CHAT_MSG_WHISPER"] =
function (self, message, sender)
if string.lower(message) == self.settings.keyword then
local success, reason = self:GuildInvite(sender);
if not success then
SendChatMessage("Invite Error: "..reason, "WHISPER", nil, sender);
end;
end
end;
["CHAT_MSG_SYSTEM"] =
function (self, message, sender)
local sender = string.match(message, self.errAlreadyInGroup);
if sender then
SendChatMessage("Invite Error: ".."already in group", "WHISPER", nil, sender);
end
end;
}
WhisperGuildInvite.OnEvent = function (frame, event, ...)
local self = WhisperGuildInvite; -- Static Method
if self.events[event] then
self.events[event](self, ...);
else
self:Message("WhisperInvite Error: Unknown Event");
end;
end;
--[[ Slash Commands]]
WhisperGuildInvite.slashCommands = {
["enable"] =
function (self)
self.settings.enabled = true;
self:Message("WhisperInvite enabled");
end;
["disable"] =
function (self)
self.settings.enabled = false;
self:Message("WhisperInvite disabled");
end;
["keyword"] =
function (self, keyword)
self.settings.keyword = string.lower(keyword);
self:Message("WhisperGuildInvite keyword set to "..self.settings.keyword);
end;
};
WhisperGuildInvite.OnSlashCommand = function (msg)
local self = WhisperGuildInvite; -- Static Method
local cmd, arg = string.match(msg, "^(%a*)%s*(.*)$");
if cmd then
cmd = string.lower(cmd);
if self.slashCommands[cmd] then
self.slashCommands[cmd](self, arg);
else
self:Message("WhisperGuildInvite:")
self:Message("/whisperguildinvite enable|disable");
self:Message("/whisperguildinvite keyword <keyword>");
end;
end;
end;
-- [[ Misc ]]
function WhisperInvite:Message(msg)
DEFAULT_CHAT_FRAME:AddMessage(msg);
end;
-- [[ Load Event Handling ]]
function WhisperInvite:Load()
-- Slash command
SlashCmdList["WHISPERGUILDINVITE"] = self.OnSlashCommand;
SLASH_WHISPERGUILDINVITE1 = "/whisperguildinvite";
-- Events
self.eventFrame = CreateFrame("Frame", nil, UIParent);
self.eventFrame:SetScript("OnEvent", self.OnEvent);
self:RegisterEvents(self.events);
end;
WhisperGuildInvite.errAlreadyInGroup = string.gsub(ERR_ALREADY_IN_GROUP_S, "%%s", "(%%a*)");
WhisperGuildInvite:Load();
Basically I got rid of the LUA errors at the expense of nothing happening at all. Not sure where to look for fixes.
I apologize in advance, this is the first bit of coding that I've ever attempted so its definatly a crude way to modify i'm sure.
Thanks again,
Chris