vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 AutoInviteOptions = {};
2 local Realm;
3 local Player;
4 local version = "0.5";
5 local default_invite = "invite";
6  
7 function AutoInvite_OnLoad()
8 this:RegisterEvent("CHAT_MSG_WHISPER");
9 this:RegisterEvent("PLAYER_ENTERING_WORLD");
10  
11 SlashCmdList["AutoInvite"] = AutoInvite_SlashHandler;
12 SLASH_AutoInvite1 = "/AutoInvite";
13 SLASH_AutoInvite2 = "/ai";
14  
15 DEFAULT_CHAT_FRAME:AddMessage("AutoInvite (redux) v"..version.." loaded. Type /ai for usage.",0,0,1);
16 DEFAULT_CHAT_FRAME:AddMessage("Type \'/ai alist\' to auto invite everyone in the A-list",0,0,1);
17 DEFAULT_CHAT_FRAME:AddMessage("Type \'/ai blist\' to auto invite everyone in the B-list",0,0,1);
18 end
19  
20 function AutoInvite_InitializeSetup()
21 Player = UnitName("player");
22 Realm = GetRealmName();
23 if AutoInviteOptions == nil then AutoInviteOptions = {} end;
24 if(AutoInviteOptions[Realm] == nil) then AutoInviteOptions[Realm] = {} end;
25 if(AutoInviteOptions[Realm][Player] == nil) then AutoInviteOptions[Realm][Player] = {} end;
26 if(AutoInviteOptions[Realm][Player]["Invite"] == nil) then AutoInviteOptions[Realm][Player]["Invite"] = default_invite end;
27 if(AutoInviteOptions[Realm][Player]["Status"] == nil) then AutoInviteOptions[Realm][Player]["Status"] = "On" end;
28 if(AutoInviteOptions[Realm][Player]["Type"] == nil) then AutoInviteOptions[Realm][Player]["Type"] = "Party" end;
29 end
30  
31 function AutoInvite_OnEvent(event)
32 if(event == "PLAYER_ENTERING_WORLD") then
33 AutoInvite_InitializeSetup();
34 elseif(event == "CHAT_MSG_WHISPER") then
35 if(AutoInviteOptions[Realm][Player]["Status"] == "On") then
36 local what = arg1;
37 local who = arg2;
38 local invite = AutoInvite_CheckMessage(what);
39 if(invite) then AutoInvite_Invite(who) end;
40 end
41 end
42 end
43  
44 function InviteAList()
45 for j = 1, 50 do
46 if (AList[j]) then
47 numgroup = GetNumRaidMembers();
48 if(numgroup == 0) then --Not currently in a raid
49 numparty = GetNumPartyMembers();
50 if(numparty == 0) then InviteByName(AList[j]) --Nobody in the party? Start a new one!
51 elseif(numparty < 4) then
52 if(IsPartyLeader()) then InviteByName(AList[j]) --4 or less party members? Invite if you can.
53 else return DEFAULT_CHAT_FRAME:AddMessage("Can't invite "..AList[j].." right now, you're not the party leader.") end;
54 elseif(GetNumPartyMembers() == 4)then --if you've got a 5-man party (GetNumPartyMembers excludes yourself) convert to raid.
55 if(IsPartyLeader()) then
56 DEFAULT_CHAT_FRAME:AddMessage("Raid mode enabled: Converting your group to a raid.")
57 ConvertToRaid();
58 InviteByName(AList[j]);
59 else
60 DEFAULT_CHAT_FRAME:AddMessage("Can't invite "..AList[j].." right now, you're not the party leader.");
61 end
62 end
63 elseif((IsRaidLeader() or IsRaidOfficer()) and numgroup < 40) then InviteByName(AList[j])
64 else
65 if(numgroup > 39) then return DEFAULT_CHAT_FRAME:AddMessage("Can't invite "..AList[j].." right now, raid is full.");
66 else return DEFAULT_CHAT_FRAME:AddMessage("Can't invite "..AList[j].." right now, you're not the raid leader.") end;
67 end
68 end
69 end
70 end
71  
72 function InviteBList()
73 for j = 1, 39 do
74 if (BList[j]) then
75 numgroup = GetNumRaidMembers();
76 if(numgroup == 0) then --Not currently in a raid
77 numparty = GetNumPartyMembers();
78 if(numparty == 0) then InviteByName(BList[j]) --Nobody in the party? Start a new one!
79 elseif(numparty < 4) then
80 if(IsPartyLeader()) then InviteByName(BList[j]) --4 or less party members? Invite if you can.
81 else return DEFAULT_CHAT_FRAME:AddMessage("Can't invite "..BList[j].." right now, you're not the party leader.") end;
82 elseif(GetNumPartyMembers() == 4)then --if you've got a 5-man party (GetNumPartyMembers excludes yourself) convert to raid.
83 if(IsPartyLeader()) then
84 DEFAULT_CHAT_FRAME:AddMessage("Raid mode enabled: Converting your group to a raid.")
85 ConvertToRaid();
86 InviteByName(BList[j]);
87 else
88 DEFAULT_CHAT_FRAME:AddMessage("Can't invite "..BList[j].." right now, you're not the party leader.");
89 end
90 end
91 elseif((IsRaidLeader() or IsRaidOfficer()) and numgroup < 40) then InviteByName(BList[j])
92 else
93 if(numgroup > 39) then return DEFAULT_CHAT_FRAME:AddMessage("Can't invite "..BList[j].." right now, raid is full.");
94 else return DEFAULT_CHAT_FRAME:AddMessage("Can't invite "..BList[j].." right now, you're not the raid leader.") end;
95 end
96 end
97 end
98 end
99  
100 function AutoInvite_SlashHandler(msg)
101 if(msg ~= "") then msg = string.lower(msg) end;
102 if(msg == "" or msg == "status") then
103 DEFAULT_CHAT_FRAME:AddMessage("AutoInvite status: |c00ffff00"..AutoInviteOptions[Realm][Player]["Status"].."|r (change with /ai on | off)");
104 DEFAULT_CHAT_FRAME:AddMessage("AutoInvite keyword: |c00ffff00"..AutoInviteOptions[Realm][Player]["Invite"].."|r (change with /ai text)");
105 DEFAULT_CHAT_FRAME:AddMessage("AutoInvite party type: |c00ffff00"..AutoInviteOptions[Realm][Player]["Type"].."|r (change with /ai party | raid)");
106 elseif(msg == "on") then
107 AutoInviteOptions[Realm][Player]["Status"] = "On";
108 DEFAULT_CHAT_FRAME:AddMessage("AutoInvite: Now issuing automatic invites on keyword[s]: |c00ffff00"..AutoInviteOptions[Realm][Player]["Invite"].."|r");
109 elseif(msg == "off") then
110 AutoInviteOptions[Realm][Player]["Status"] = "Off";
111 DEFAULT_CHAT_FRAME:AddMessage("AutoInvite: No longer issuing automatic invites." ,1,1,1);
112 elseif(msg == "party") then
113 AutoInviteOptions[Realm][Player]["Type"] = "Party";
114 DEFAULT_CHAT_FRAME:AddMessage("AutoInvite: Invite checking for 5-man party only." ,1,1,1);
115 elseif(msg == "alist") then
116 DEFAULT_CHAT_FRAME:AddMessage("AutoInvite: Starting Invites of Priority List." ,1,1,1);
117 InviteAList();
118 elseif(msg == "blist") then
119 DEFAULT_CHAT_FRAME:AddMessage("AutoInvite: Starting Invites of Secondary List." ,1,1,1);
120 InviteBList();
121 elseif(msg == "raid") then
122 AutoInviteOptions[Realm][Player]["Type"] = "Raid";
123 DEFAULT_CHAT_FRAME:AddMessage("AutoInvite: Invite checking for 40-man raid groups." ,1,1,1);
124 else
125 AutoInviteOptions[Realm][Player]["Invite"] = msg;
126 DEFAULT_CHAT_FRAME:AddMessage("AutoInvite: changed automatic invite keyword[s] to: |c00ffff00"..AutoInviteOptions[Realm][Player]["Invite"].."|r");
127 end
128 end
129  
130 function AutoInvite_CheckMessage(what)
131 return string.find(string.lower(what), AutoInviteOptions[Realm][Player]["Invite"], 1, true);
132 end
133  
134 function AutoInvite_Invite(who)
135 local numgroup;
136 local gtype = AutoInviteOptions[Realm][Player]["Type"];
137 if(gtype == "Party") then
138 numgroup = GetNumPartyMembers();
139 if((IsPartyLeader() and numgroup < 4) or (numgroup == 0)) then InviteByName(who)
140 else
141 if(numgroup >= 4) then return DEFAULT_CHAT_FRAME:AddMessage("Can't invite "..who.." right now, party is full.");
142 else return DEFAULT_CHAT_FRAME:AddMessage("Can't invite "..who.." right now, you're not the party leader.") end;
143 end
144 elseif(gtype == "Raid") then
145 numgroup = GetNumRaidMembers();
146 if(numgroup == 0) then --Not currently in a raid
147 numparty = GetNumPartyMembers();
148 if(numparty == 0) then InviteByName(who) --Nobody in the party? Start a new one!
149 elseif(numparty < 4) then
150 if(IsPartyLeader()) then InviteByName(who) --4 or less party members? Invite if you can.
151 else return DEFAULT_CHAT_FRAME:AddMessage("Can't invite "..who.." right now, you're not the party leader.") end;
152 elseif(GetNumPartyMembers() == 4)then --if you've got a 5-man party (GetNumPartyMembers excludes yourself) convert to raid.
153 if(IsPartyLeader()) then
154 DEFAULT_CHAT_FRAME:AddMessage("Raid mode enabled: Converting your group to a raid.")
155 ConvertToRaid();
156 InviteByName(who);
157 else
158 DEFAULT_CHAT_FRAME:AddMessage("Can't invite "..who.." right now, you're not the party leader.");
159 end
160 end
161 elseif((IsRaidLeader() or IsRaidOfficer()) and numgroup < 40) then InviteByName(who)
162 else
163 if(numgroup > 39) then return DEFAULT_CHAT_FRAME:AddMessage("Can't invite "..who.." right now, raid is full.");
164 else return DEFAULT_CHAT_FRAME:AddMessage("Can't invite "..who.." right now, you're not the raid leader.") end;
165 end
166 end
167 end