Thread Tools Display Modes
12-21-11, 10:50 AM   #1
Bastyra
A Kobold Labourer
Join Date: Dec 2011
Posts: 1
Whispering for Invite

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
  Reply With Quote
12-21-11, 12:00 PM   #2
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
A guild invite requires a hardware event. (ie, you could make the addon pop up a window for you to do the invite from)
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
12-21-11, 08:45 PM   #3
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Try this:

Lua Code:
  1. local ADDON_NAME, addonNS = ...
  2.  
  3. local settings, nameToInvite
  4.  
  5. local WhisperGuildInvite = CreateFrame("Frame")
  6. WhisperGuildInvite:SetScript("OnEvent", function(self, event, ...) return self[event] and self[event](self, ...) end)
  7. WhisperGuildInvite:RegisterEvent("ADDON_LOADED")
  8.  
  9. function WhisperGuildInvite:ADDON_LOADED(addon)
  10.     if addon ~= ADDON_NAME then
  11.         return
  12.     end
  13.  
  14.     if not WhisperGuildInvite_Persistent then
  15.         WhisperGuildInvite_Persistent = {
  16.             enabled = true
  17.             autoconvert = true
  18.             keyword = "invite"
  19.         }
  20.     end
  21.     settings = WhisperInvite_Persistent
  22.  
  23.     StaticPopupDialogs["CONFIRM_GUILD_AUTO_INVITE"] = {
  24.         text = "%s has requested a guild invitation.\nInvite?",
  25.         button1 = ACCEPT,
  26.         button2 = CANCEL,
  27.         hideOnEscape = 0,
  28.         timeout = 0,
  29.         whileDead = 1,
  30.         OnAccept = function(self)
  31.             if nameToInvite and settings and settings.enabled then
  32.                 GuildInvite(nameToInvite)
  33.                 nameToInvite = nil
  34.             end
  35.         end,
  36.         OnCancel = function(self)
  37.             -- You cancelled the dialog.
  38.             -- Send an automatic response here if you want.
  39.             nameToInvite = nil
  40.         end,
  41.     }
  42.  
  43.     self:UnregisterEvent("ADDON_LOADED")
  44.  
  45.     self:RegisterEvent("CHAT_MSG_WHISPER")
  46. end
  47.  
  48. function WhisperGuildInvite:CHAT_MSG_WHISPER(message, sender)
  49.     if message:lower() == settings.keyword then
  50.         if GetRealNumRaidMembers() == 0 and GetRealNumPartyMembers() == 0 then
  51.             nameToInvite = sender
  52.             StaticPopup_Show("CONFIRM_GUILD_AUTO_INVITE", sender)
  53.         else
  54.             -- You are in a group.
  55.             -- Send an automatic response here if you want.
  56.         end
  57.     end
  58. end
  59.  
  60. local slashCommands = {
  61.     ["enable"] = function()
  62.         settings.enabled = true
  63.         WhisperGuildInvite:RegisterEvent("CHAT_MSG_WHISPER")
  64.         DEFAULT_CHAT_FRAME:AddMessage("WhisperInvite enabled.")
  65.     end
  66.     ["disable"] = function()
  67.         settings.enabled = false
  68.         WhisperGuildInvite:UnregisterEvent("WhisperGuildInvite")
  69.         DEFAULT_CHAT_FRAME:AddMessage("WhisperInvite disabled.")
  70.     end
  71.     ["keyword"] = function(keyword)
  72.         settings.keyword = keyword:lower()
  73.         DEFAULT_CHAT_FRAME:AddMessage("WhisperGuildInvite keyword set to:", settings.keyword)
  74.     end
  75. }
  76.  
  77. SLASH_WHISPERGUILDINVITE1 = "/whisperguildinvite"
  78. SLASH_WHISPERGUILDINVITE2 = "/wgi"
  79. SlashCmdList["WHISPERGUILDINVITE"] = function(msg)
  80.     local cmd, arg = msg:lower():match("^(%a*)%s*(.*)$")
  81.     if cmd and slashCommands[cmd] then
  82.         slashCommands[cmd](arg)
  83.     else
  84.         DEFAULT_CHAT_FRAME:AddMessage("WhisperGuildInvite:")
  85.         DEFAULT_CHAT_FRAME:AddMessage("    /wgi [enable|disable]")
  86.         DEFAULT_CHAT_FRAME:AddMessage("    /wgi keyword <keyword>")
  87.     end
  88. end
  Reply With Quote
07-19-12, 12:41 PM   #4
Ruinit
A Deviate Faerie Dragon
Join Date: Aug 2009
Posts: 19
Originally Posted by Phanx View Post
Try this:

Lua Code:
  1. local ADDON_NAME, addonNS = ...
  2.  
  3. local settings, nameToInvite
  4.  
  5. local WhisperGuildInvite = CreateFrame("Frame")
  6. WhisperGuildInvite:SetScript("OnEvent", function(self, event, ...) return self[event] and self[event](self, ...) end)
  7. WhisperGuildInvite:RegisterEvent("ADDON_LOADED")
  8.  
  9. function WhisperGuildInvite:ADDON_LOADED(addon)
  10.     if addon ~= ADDON_NAME then
  11.         return
  12.     end
  13.  
  14.     if not WhisperGuildInvite_Persistent then
  15.         WhisperGuildInvite_Persistent = {
  16.             enabled = true
  17.             autoconvert = true
  18.             keyword = "invite"
  19.         }
  20.     end
  21.     settings = WhisperInvite_Persistent
  22.  
  23.     StaticPopupDialogs["CONFIRM_GUILD_AUTO_INVITE"] = {
  24.         text = "%s has requested a guild invitation.\nInvite?",
  25.         button1 = ACCEPT,
  26.         button2 = CANCEL,
  27.         hideOnEscape = 0,
  28.         timeout = 0,
  29.         whileDead = 1,
  30.         OnAccept = function(self)
  31.             if nameToInvite and settings and settings.enabled then
  32.                 GuildInvite(nameToInvite)
  33.                 nameToInvite = nil
  34.             end
  35.         end,
  36.         OnCancel = function(self)
  37.             -- You cancelled the dialog.
  38.             -- Send an automatic response here if you want.
  39.             nameToInvite = nil
  40.         end,
  41.     }
  42.  
  43.     self:UnregisterEvent("ADDON_LOADED")
  44.  
  45.     self:RegisterEvent("CHAT_MSG_WHISPER")
  46. end
  47.  
  48. function WhisperGuildInvite:CHAT_MSG_WHISPER(message, sender)
  49.     if message:lower() == settings.keyword then
  50.         if GetRealNumRaidMembers() == 0 and GetRealNumPartyMembers() == 0 then
  51.             nameToInvite = sender
  52.             StaticPopup_Show("CONFIRM_GUILD_AUTO_INVITE", sender)
  53.         else
  54.             -- You are in a group.
  55.             -- Send an automatic response here if you want.
  56.         end
  57.     end
  58. end
  59.  
  60. local slashCommands = {
  61.     ["enable"] = function()
  62.         settings.enabled = true
  63.         WhisperGuildInvite:RegisterEvent("CHAT_MSG_WHISPER")
  64.         DEFAULT_CHAT_FRAME:AddMessage("WhisperInvite enabled.")
  65.     end
  66.     ["disable"] = function()
  67.         settings.enabled = false
  68.         WhisperGuildInvite:UnregisterEvent("WhisperGuildInvite")
  69.         DEFAULT_CHAT_FRAME:AddMessage("WhisperInvite disabled.")
  70.     end
  71.     ["keyword"] = function(keyword)
  72.         settings.keyword = keyword:lower()
  73.         DEFAULT_CHAT_FRAME:AddMessage("WhisperGuildInvite keyword set to:", settings.keyword)
  74.     end
  75. }
  76.  
  77. SLASH_WHISPERGUILDINVITE1 = "/whisperguildinvite"
  78. SLASH_WHISPERGUILDINVITE2 = "/wgi"
  79. SlashCmdList["WHISPERGUILDINVITE"] = function(msg)
  80.     local cmd, arg = msg:lower():match("^(%a*)%s*(.*)$")
  81.     if cmd and slashCommands[cmd] then
  82.         slashCommands[cmd](arg)
  83.     else
  84.         DEFAULT_CHAT_FRAME:AddMessage("WhisperGuildInvite:")
  85.         DEFAULT_CHAT_FRAME:AddMessage("    /wgi [enable|disable]")
  86.         DEFAULT_CHAT_FRAME:AddMessage("    /wgi keyword <keyword>")
  87.     end
  88. end
Did this end up working? Looking to ginvite people who whisper me a keyword?
  Reply With Quote
07-19-12, 04:42 PM   #5
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
I have no idea. The person who requested it never made another post anywhere on the forums after starting this thread, and I never tested it, since I don't care at all about guild inviting, and use an addon that blocks any message in any channel that looks remotely related to guild recruitment. Guild recruitment spammers are worse than gold spammers... they're certainly far more numerous, anyway. If I wanted to be in a guild, I'd be in one, or I'd be actively looking for one. Until then, leave me the f*ck alone and quit spamming me about your free guild tabards and how your level 2 guild has 4372483423 members and plans to be the next top raiding guild.

Anyway, why don't you just try the code? If it does what you want, great. If not, describe what's wrong and/or post the error message you get from it and explain what you were doing when the error appeared.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
07-19-12, 05:01 PM   #6
Ruinit
A Deviate Faerie Dragon
Join Date: Aug 2009
Posts: 19
Originally Posted by Phanx View Post
I have no idea. The person who requested it never made another post anywhere on the forums after starting this thread, and I never tested it, since I don't care at all about guild inviting, and use an addon that blocks any message in any channel that looks remotely related to guild recruitment. Guild recruitment spammers are worse than gold spammers... they're certainly far more numerous, anyway. If I wanted to be in a guild, I'd be in one, or I'd be actively looking for one. Until then, leave me the f*ck alone and quit spamming me about your free guild tabards and how your level 2 guild has 4372483423 members and plans to be the next top raiding guild.

Anyway, why don't you just try the code? If it does what you want, great. If not, describe what's wrong and/or post the error message you get from it and explain what you were doing when the error appeared.
Hehe I understand, not looking for mass guild inviter, just looking to advertise once in a while in trade and let people decide if they want to join by whispering a keyword to be invited. I copied and pasted the above in notepad, saved it as a lua and called it a random invite name. Made a folder in addons and tried it. It didn't do anything. I don't know much about this. Was hoping someone could fix nuttyrecruit to work again. It use to do this.

Actually it invites to to a group, not to guild.
I have tried pieces of code from other addons but I made things worse. Just as this code stands if you whisper me I will send an invite to you to join my group. Any help would be great.

Last edited by Ruinit : 07-19-12 at 06:23 PM. Reason: more info
  Reply With Quote
07-19-12, 07:30 PM   #7
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
Here's a nifty site you can use to automatically package the addon for you.
http://addon.ziuo.net/

Just paste the code, and you'll be given a zip file that you can extract into your addons folder. Easier than explaining how to set it up, assuming that was the problem.
__________________
Grab your sword and fight the Horde!
  Reply With Quote
07-19-12, 07:40 PM   #8
Ruinit
A Deviate Faerie Dragon
Join Date: Aug 2009
Posts: 19
Originally Posted by Lombra View Post
Here's a nifty site you can use to automatically package the addon for you.
http://addon.ziuo.net/

Just paste the code, and you'll be given a zip file that you can extract into your addons folder. Easier than explaining how to set it up, assuming that was the problem.
TY but no I just can't get it to guild invite
  Reply With Quote
07-19-12, 08:00 PM   #9
Talyrius
An Onyxian Warder
 
Talyrius's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 363
GuildInvite("playerName") is now a protected function and requires a hardware event. It is no longer possible to automatically invite people to your guild.
  Reply With Quote
07-19-12, 08:59 PM   #10
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
^^ This change was made to combat the guild invite spamming addons out there.

What an addon can do instead now is that when someone whispers you the keyword, the addon can popup a button on screen for you to click to invite that person.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
07-20-12, 12:21 AM   #11
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by Talyrius View Post
GuildInvite("playerName") is now a protected function and requires a hardware event. It is no longer possible to automatically invite people to your guild.
Yes, that was the whole point of the code I posted.

Originally Posted by Ruinit View Post
Actually it invites to to a group, not to guild.
I have tried pieces of code from other addons but I made things worse. Just as this code stands if you whisper me I will send an invite to you to join my group. Any help would be great.
The only global functions called in the code I posted are GetRealNumRaidMembers and GetRealNumPartyMembers to find out if you're in a group, StaticPopup_Show to show the dialog you can click to invite, and GuildInvite to invite someone.

I am not in a guild, so I can't test it, I can't imagine how that code can possibly send a group invite... are you sure you didn't paste the wrong code in somewhere?
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
07-20-12, 01:01 PM   #12
Ruinit
A Deviate Faerie Dragon
Join Date: Aug 2009
Posts: 19
Originally Posted by Phanx View Post
Yes, that was the whole point of the code I posted.



The only global functions called in the code I posted are GetRealNumRaidMembers and GetRealNumPartyMembers to find out if you're in a group, StaticPopup_Show to show the dialog you can click to invite, and GuildInvite to invite someone.

I am not in a guild, so I can't test it, I can't imagine how that code can possibly send a group invite... are you sure you didn't paste the wrong code in somewhere?
I guess it was another addon I had installed doing the group invite because I disabled all addons I had and it stopped working. It appears the code doesn't work. Just to be clear I am not trying to spam people invites I am just trying to automate the guildinvite portion so that a person can whisper me a keyword and be invited to the guild. Nuttyrecruit addon use to do this and now doesn't and the author has quit wow. So he won't be updating it. If you could take a look at that maybe it's a simple fix. Thanks
  Reply With Quote
07-20-12, 06:33 PM   #13
Dridzt
A Pyroguard Emberseer
 
Dridzt's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2005
Posts: 1,360
You can give this one a try: gInviteMe (haven't tested it myself or looked at the code)

It seems to fit your specifications.
  Reply With Quote
07-21-12, 09:31 PM   #14
Talyrius
An Onyxian Warder
 
Talyrius's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 363
Originally Posted by Phanx View Post
Yes, that was the whole point of the code I posted. ...
I apologize. I usually read the whole thread before replying, but I neglected to do so in this instance.
  Reply With Quote
07-22-12, 08:02 AM   #15
Ruinit
A Deviate Faerie Dragon
Join Date: Aug 2009
Posts: 19
Originally Posted by Dridzt View Post
You can give this one a try: gInviteMe (haven't tested it myself or looked at the code)

It seems to fit your specifications.
tried it already but thanks. It doesn't work either.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Whispering for Invite


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off