vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | --[[ |
2 | InviteOMatic is a BG Group inviter |
||
3 | |||
4 | @author Gof |
||
5 | @version 29-03-06 |
||
6 | ]]-- |
||
7 | |||
8 | ---------------------------------------------------------------------- |
||
9 | -- Saved variable |
||
10 | ---------------------------------------------------------------------- |
||
11 | |||
12 | InviteOMaticOptions = {}; |
||
13 | |||
14 | ---------------------------------------------------------------------- |
||
15 | -- Strings used in this mod |
||
16 | ---------------------------------------------------------------------- |
||
17 | |||
18 | local IOM_VERSION = "v1.16"; |
||
19 | local IOM_IOM = "[InviteOMatic]"; |
||
20 | local IOM_LOADED = IOM_IOM.." "..IOM_VERSION.." Loaded!"; |
||
21 | |||
22 | local IOM_FIRST_INVITE_SPAM_DEFAULT = IOM_IOM.." Please leave your groups, i have the raid group, (Or at least Promote me so i can help invite =)"; |
||
23 | |||
24 | local IOM_ERROR_AIG_DEFAULT = IOM_IOM.." Since you appear to already be grouped you could not be auto-invited to the raid. If you want to join the raid, please leave your group and send me a whisper with the word: invite"; |
||
25 | |||
26 | local IOM_INVITE_REG_EXP = "[iI][nN][vV][iI][tT][eE]"; -- Regular expression for magic word. |
||
27 | |||
28 | ---------------------------------------------------------------------- |
||
29 | -- Local variables used to capture state |
||
30 | ---------------------------------------------------------------------- |
||
31 | local IOM_WHOIS = false; -- Are we doing a /who lookup? |
||
32 | local IOM_NAME_BY_WHO = "----"; -- The name we are currently looking up over /Who |
||
33 | local IOM_NAME_BY_WHO_INVITER = "----"; -- The name of the person starting the lookup over /who |
||
34 | local IOM_BG_ACTIVE = false; -- Are we active in a BG, or just handling group outside BG |
||
35 | local IOM_BG_ACTIVE_INDEX = -1; -- The index of the active BG |
||
36 | local IOM_INVITE_WAIT = 1; -- Time to back off before sending invites again, (in seconds) |
||
37 | -- local IOM_FIRST_SCHED_TIME = 2; -- Time to wait from joining BG, to sending the first invite |
||
38 | local IOM_LAST_INVITE = 0; -- Time since last invite cycle, to prevent spamming of invites |
||
39 | local IOM_INVITE_FIRST = true; -- Is this the first invite cycle in this BG? |
||
40 | local IOM_READY = false; |
||
41 | |||
42 | local IOM_AIG = {}; |
||
43 | local IOM_AIG_ERROR = {}; |
||
44 | local IOM_DECLINE = {}; |
||
45 | local IOM_IGNORE = {}; |
||
46 | |||
47 | local IOM_GROUPBUG = {}; |
||
48 | |||
49 | local IOM_PURGE_TIMER = 0; |
||
50 | local IOM_INVITE_TIMER = 0; |
||
51 | local IOM_UPDATE_PURGE_TIMER = false; |
||
52 | local IOM_UPDATE_INVITE_TIMER = false; |
||
53 | |||
54 | ---------------------------------------------------------------------- |
||
55 | -- This function is called when the mod is first loaded. |
||
56 | ---------------------------------------------------------------------- |
||
57 | |||
58 | function InviteOMatic_OnLoad() |
||
59 | this:RegisterEvent("VARIABLES_LOADED"); -- Saved variables loaded |
||
60 | this:RegisterEvent("UPDATE_BATTLEFIELD_STATUS"); -- Register event that fires when BG status changes |
||
61 | this:RegisterEvent("CHAT_MSG_WHISPER"); -- Register event that fires when player receives a whisper |
||
62 | end |
||
63 | |||
64 | ---------------------------------------------------------------------- |
||
65 | -- Called when an event occurs (That we have registered to hear) |
||
66 | -- |
||
67 | -- @param event The event that occured |
||
68 | ---------------------------------------------------------------------- |
||
69 | function InviteOMatic_OnEvent() |
||
70 | |||
71 | if( event == "VARIABLES_LOADED" ) then |
||
72 | InviteOMatic_VariablesLoaded(); |
||
73 | |||
74 | elseif( event == "CHAT_MSG_WHISPER" ) then |
||
75 | InviteOMatic_WhisperEvent(arg1, arg2); |
||
76 | |||
77 | elseif( event == "UPDATE_BATTLEFIELD_STATUS" ) then |
||
78 | InviteOMatic_BGEvent(); |
||
79 | |||
80 | elseif( event == "WHO_LIST_UPDATE" ) then |
||
81 | InviteOMatic_WhoEvent(); |
||
82 | |||
83 | elseif( event == "CHAT_MSG_SYSTEM" ) then |
||
84 | InviteOMatic_ChannelSystem(arg1); |
||
85 | |||
86 | end |
||
87 | end |
||
88 | |||
89 | function InviteOMatic_VariablesLoaded() |
||
90 | if( InviteOMaticOptions == nil ) then |
||
91 | InviteOMaticOptions = {}; |
||
92 | end |
||
93 | |||
94 | if( type(InviteOMaticOptions) ~= "table" ) then |
||
95 | InviteOMaticOptions = {}; |
||
96 | end |
||
97 | |||
98 | if( InviteOMaticOptions["autoInvite"] == nil ) then |
||
99 | InviteOMaticOptions["autoInvite"] = true; |
||
100 | InviteOMatic_KhaosSetKey("InviteOMatic", "InviteAutoInvite", "checked", InviteOMaticOptions["autoInvite"]); |
||
101 | end |
||
102 | |||
103 | if( InviteOMaticOptions["whisperInvite"] == nil ) then |
||
104 | InviteOMaticOptions["whisperInvite"] = true; |
||
105 | InviteOMatic_KhaosSetKey("InviteOMatic", "InviteWhisperInvite", "checked", InviteOMaticOptions["whisperInvite"]); |
||
106 | end |
||
107 | |||
108 | if( InviteOMaticOptions["autoPurge"] == nil ) then |
||
109 | InviteOMaticOptions["autoPurge"] = true; |
||
110 | InviteOMatic_KhaosSetKey("InviteOMatic", "InviteAutoPurge", "checked", InviteOMaticOptions["autoPurge"]); |
||
111 | end |
||
112 | |||
113 | if( InviteOMaticOptions["debug"] == nil ) then |
||
114 | InviteOMaticOptions["debug"] = false; |
||
115 | InviteOMatic_KhaosSetKey("InviteOMatic", "InviteDebug", "checked", InviteOMaticOptions["debug"]); |
||
116 | end |
||
117 | |||
118 | if( InviteOMaticOptions["ignoreList"] == nil ) then |
||
119 | InviteOMaticOptions["ignoreList"] = {}; |
||
120 | end |
||
121 | |||
122 | if( InviteOMaticOptions["aigttl"] == nil ) then |
||
123 | InviteOMaticOptions["aigttl"] = 10; |
||
124 | InviteOMatic_KhaosSetKey("InviteOMatic", "InviteAIGRetry", "slider", InviteOMaticOptions["aigttl"]); |
||
125 | end |
||
126 | |||
127 | if( InviteOMaticOptions["declinettl"] == nil ) then |
||
128 | InviteOMaticOptions["declinettl"] = 1; |
||
129 | InviteOMatic_KhaosSetKey("InviteOMatic", "InviteDeclineRetry", "slider", InviteOMaticOptions["declinettl"]); |
||
130 | end |
||
131 | |||
132 | if( InviteOMaticOptions["ignorettl"] == nil ) then |
||
133 | InviteOMaticOptions["ignorettl"] = 1; |
||
134 | InviteOMatic_KhaosSetKey("InviteOMatic", "InviteIgnoreRetry", "slider", InviteOMaticOptions["ignorettl"]); |
||
135 | end |
||
136 | |||
137 | if( InviteOMaticOptions["sendInviteSpam"] == nil ) then |
||
138 | InviteOMaticOptions["sendInviteSpam"] = true; |
||
139 | InviteOMatic_KhaosSetKey("InviteOMatic", "InviteSendSpam", "checked", InviteOMaticOptions["sendInviteSpam"]); |
||
140 | end |
||
141 | |||
142 | if( InviteOMaticOptions["sendAIGSpam"] == nil ) then |
||
143 | InviteOMaticOptions["sendAIGSpam"] = true; |
||
144 | InviteOMatic_KhaosSetKey("InviteOMatic", "InviteSendAIGSpam", "checked", InviteOMaticOptions["sendAIGSpam"]); |
||
145 | end |
||
146 | |||
147 | if( InviteOMaticOptions["inviteDelay"] == nil ) then |
||
148 | InviteOMaticOptions["inviteDelay"] = 10; |
||
149 | InviteOMatic_KhaosSetKey("InviteOMatic", "InviteDelay", "slider", InviteOMaticOptions["inviteDelay"]); |
||
150 | end |
||
151 | |||
152 | if( InviteOMaticOptions["purgeDelay"] == nil ) then |
||
153 | InviteOMaticOptions["purgeDelay"] = 10; |
||
154 | InviteOMatic_KhaosSetKey("InviteOMatic", "PurgeDelay", "slider", InviteOMaticOptions["purgeDelay"]); |
||
155 | end |
||
156 | |||
157 | if( InviteOMaticOptions["inviteMsg"] == nil ) then |
||
158 | InviteOMaticOptions["inviteMsg"] = IOM_FIRST_INVITE_SPAM_DEFAULT; |
||
159 | InviteOMatic_KhaosSetKey("InviteOMatic", "InviteSpamMsg", "value", InviteOMaticOptions["inviteMsg"]); |
||
160 | end |
||
161 | |||
162 | if( InviteOMaticOptions["aigMsg"] == nil ) then |
||
163 | InviteOMaticOptions["aigMsg"] = IOM_ERROR_AIG_DEFAULT; |
||
164 | InviteOMatic_KhaosSetKey("InviteOMatic", "InviteAIGSpamMsg", "value", InviteOMaticOptions["aigMsg"]); |
||
165 | end |
||
166 | |||
167 | if( InviteOMaticOptions["magicWord"] == nil ) then |
||
168 | InviteOMaticOptions["magicWord"] = IOM_INVITE_REG_EXP; |
||
169 | InviteOMatic_KhaosSetKey("InviteOMatic", "InviteMagicWord", "value", InviteOMaticOptions["magicWord"]); |
||
170 | end |
||
171 | |||
172 | InviteOMatic.log(IOM_LOADED); |
||
173 | SlashCmdList["IOM"] = InviteOMatic_SlashHandler; |
||
174 | SLASH_IOM1 = "/iom"; |
||
175 | |||
176 | IOM_READY = true; |
||
177 | |||
178 | InviteOMatic_RegisterKhaos(); |
||
179 | |||
180 | end |
||
181 | |||
182 | ---------------------------------------------------------------------- |
||
183 | -- Slash command handler |
||
184 | ---------------------------------------------------------------------- |
||
185 | function InviteOMatic_SlashHandler(msg) |
||
186 | if( not IOM_READY ) then |
||
187 | return; |
||
188 | end |
||
189 | |||
190 | if( InviteOMatic_IsDisabled() ) then |
||
191 | return; |
||
192 | end |
||
193 | |||
194 | local oldmsg = msg; |
||
195 | msg = string.lower(msg); |
||
196 | |||
197 | InviteOMatic.debug("Slashcommand: ("..msg..")"); |
||
198 | |||
199 | _, _, option, value = string.find(msg, "(%w*)%s*(%w*)"); |
||
200 | |||
201 | InviteOMatic.debug("Option: ("..option.."), Value: ("..value..")"); |
||
202 | |||
203 | if( option == "autoinvite" ) then |
||
204 | if( value == "on" ) then |
||
205 | InviteOMaticOptions["autoInvite"] = true; |
||
206 | elseif( value == "off" ) then |
||
207 | InviteOMaticOptions["autoInvite"] = false; |
||
208 | else |
||
209 | InviteOMaticOptions["autoInvite"] = not InviteOMaticOptions["autoInvite"]; |
||
210 | end |
||
211 | InviteOMatic.log("Auto invite set to: "..tostring(InviteOMaticOptions["autoInvite"])); |
||
212 | InviteOMatic_KhaosSetKey("InviteOMatic", "InviteAutoInvite", "checked", InviteOMaticOptions["autoInvite"]); |
||
213 | if( IOM_BG_ACTIVE ) then |
||
214 | IOM_UPDATE_INVITE_TIMER = InviteOMaticOptions["autoInvite"]; |
||
215 | end |
||
216 | |||
217 | elseif( option == "whisperinvite" ) then |
||
218 | if( value == "on" ) then |
||
219 | InviteOMaticOptions["whisperInvite"] = true; |
||
220 | elseif( value == "off" ) then |
||
221 | InviteOMaticOptions["whisperInvite"] = false; |
||
222 | else |
||
223 | InviteOMaticOptions["whisperInvite"] = not InviteOMaticOptions["whisperInvite"]; |
||
224 | end |
||
225 | InviteOMatic.log("Whisper invite set to: "..tostring(InviteOMaticOptions["whisperInvite"])); |
||
226 | InviteOMatic_KhaosSetKey("InviteOMatic", "InviteWhisperInvite", "checked", InviteOMaticOptions["whisperInvite"]); |
||
227 | |||
228 | elseif( option == "autopurge" ) then |
||
229 | if( value == "on" ) then |
||
230 | InviteOMaticOptions["autoPurge"] = true; |
||
231 | elseif( value == "off" ) then |
||
232 | InviteOMaticOptions["autoPurge"] = false; |
||
233 | else |
||
234 | InviteOMaticOptions["autoPurge"] = not InviteOMaticOptions["autoPurge"]; |
||
235 | end |
||
236 | InviteOMatic.log("Auto purge set to: "..tostring(InviteOMaticOptions["autoPurge"])); |
||
237 | InviteOMatic_KhaosSetKey("InviteOMatic", "InviteAutoPurge", "checked", InviteOMaticOptions["autoPurge"]); |
||
238 | if( IOM_BG_ACTIVE ) then |
||
239 | IOM_UPDATE_PURGE_TIMER = InviteOMaticOptions["autoPurge"]; |
||
240 | end |
||
241 | |||
242 | elseif( option == "spam" ) then |
||
243 | if( value == "on" ) then |
||
244 | InviteOMaticOptions["sendInviteSpam"] = true; |
||
245 | elseif( value == "off") then |
||
246 | InviteOMaticOptions["sendInviteSpam"] = false; |
||
247 | else |
||
248 | InviteOMaticOptions["sendInviteSpam"] = not InviteOMaticOptions["sendInviteSpam"]; |
||
249 | end |
||
250 | InviteOMatic.log("Invite spam set to: "..tostring(InviteOMaticOptions["sendInviteSpam"])); |
||
251 | InviteOMatic_KhaosSetKey("InviteOMatic", "InviteSendSpam", "checked", InviteOMaticOptions["sendInviteSpam"]); |
||
252 | |||
253 | elseif( option == "debug" ) then |
||
254 | if( value == "on" ) then |
||
255 | InviteOMaticOptions["debug"] = true; |
||
256 | elseif( value == "off") then |
||
257 | InviteOMaticOptions["debug"] = false; |
||
258 | else |
||
259 | InviteOMaticOptions["debug"] = not InviteOMaticOptions["debug"]; |
||
260 | end |
||
261 | InviteOMatic.log("Debug messages set to: "..tostring(InviteOMaticOptions["debug"])); |
||
262 | InviteOMatic_KhaosSetKey("InviteOMatic", "InviteDebug", "checked", InviteOMaticOptions["debug"]); |
||
263 | |||
264 | elseif( option == "ignore" ) then |
||
265 | if( value ~= nil ) then |
||
266 | local lowerName = string.lower(value); |
||
267 | InviteOMaticOptions["ignoreList"][lowerName] = lowerName; |
||
268 | else |
||
269 | InviteOMatic.log("You need to specify a playername you wish to add to the ignore-list, /iom ignore playername"); |
||
270 | end |
||
271 | InviteOMatic.log(value.." added to ignore list"); |
||
272 | |||
273 | elseif( option == "removeignore" ) then |
||
274 | if( value ~= nil ) then |
||
275 | local lowerName = string.lower(value); |
||
276 | InviteOMaticOptions["ignoreList"][lowerName] = nil; |
||
277 | else |
||
278 | InviteOMatic.log("You need to specify a playername you wish to remove from the ignore-list, /iom ignore playername"); |
||
279 | end |
||
280 | InviteOMatic.log(value.." removed from ignore list"); |
||
281 | |||
282 | elseif( option == "spammsg" ) then |
||
283 | if( value == "default" ) then |
||
284 | InviteOMaticOptions["inviteMsg"] = IOM_FIRST_INVITE_SPAM_DEFAULT; |
||
285 | InviteOMatic.log("First spam msg set to default: "..InviteOMaticOptions["inviteMsg"]); |
||
286 | InviteOMatic_KhaosSetKey("InviteOMatic", "InviteSpamMsg", "value", InviteOMaticOptions["inviteMsg"]); |
||
287 | return; |
||
288 | end |
||
289 | |||
290 | sS, sE = string.find(msg, "\".*\""); |
||
291 | |||
292 | if( not sS ) then |
||
293 | InviteOMatic.log("You need to specify a new message ex. /iom spammsg \"newmsg\""); |
||
294 | return; |
||
295 | end |
||
296 | |||
297 | newmsg = string.sub(oldmsg, sS+1, sE-1); |
||
298 | InviteOMatic.debug("New message is: ("..newmsg..")"); |
||
299 | InviteOMaticOptions["inviteMsg"] = newmsg; |
||
300 | InviteOMatic.log("First spam msg set to: "..InviteOMaticOptions["inviteMsg"]); |
||
301 | InviteOMatic_KhaosSetKey("InviteOMatic", "InviteSpamMsg", "value", InviteOMaticOptions["inviteMsg"]); |
||
302 | |||
303 | elseif( option == "aigmsg" ) then |
||
304 | if( value == "default" ) then |
||
305 | InviteOMaticOptions["aigMsg"] = IOM_ERROR_AIG_DEFAULT; |
||
306 | InviteOMatic.log("AIG spam msg set to default: "..InviteOMaticOptions["aigMsg"]); |
||
307 | InviteOMatic_KhaosSetKey("InviteOMatic", "InviteAIGSpamMsg", "value", InviteOMaticOptions["aigMsg"]); |
||
308 | return; |
||
309 | end |
||
310 | |||
311 | sS, sE = string.find(msg, "\".*\""); |
||
312 | |||
313 | if( not sS ) then |
||
314 | InviteOMatic.log("You need to specify a new message ex. /iom aigmsg \"newmsg\""); |
||
315 | return; |
||
316 | end |
||
317 | |||
318 | newmsg = string.sub(oldmsg, sS+1, sE-1); |
||
319 | InviteOMatic.debug("New message is: ("..newmsg..")"); |
||
320 | InviteOMaticOptions["aigMsg"] = newmsg; |
||
321 | InviteOMatic.log("AIG spam msg set to: "..InviteOMaticOptions["aigMsg"]); |
||
322 | InviteOMatic_KhaosSetKey("InviteOMatic", "InviteAIGSpamMsg", "value", InviteOMaticOptions["aigMsg"]); |
||
323 | |||
324 | elseif( option == "magicword" ) then |
||
325 | if( value == "default" ) then |
||
326 | InviteOMaticOptions["magicWord"] = IOM_INVITE_REG_EXP; |
||
327 | InviteOMatic.log("Magic word set to default: "..InviteOMaticOptions["magicWord"]); |
||
328 | InviteOMatic_KhaosSetKey("InviteOMatic", "InviteMagicWord", "value", InviteOMaticOptions["magicWord"]); |
||
329 | return; |
||
330 | end |
||
331 | |||
332 | sS, sE = string.find(msg, "\".*\""); |
||
333 | |||
334 | if( not sS ) then |
||
335 | InviteOMatic.log("You need to specify a new magic word ex. /iom aigmsg \"[iI][nN][vV]\""); |
||
336 | return; |
||
337 | end |
||
338 | |||
339 | newmsg = string.sub(oldmsg, sS+1, sE-1); |
||
340 | InviteOMatic.debug("New magic word is: ("..newmsg..")"); |
||
341 | InviteOMaticOptions["magicWord"] = newmsg; |
||
342 | InviteOMatic.log("Magic word set to: "..InviteOMaticOptions["magicWord"]); |
||
343 | InviteOMatic_KhaosSetKey("InviteOMatic", "InviteMagicWord", "value", InviteOMaticOptions["magicWord"]); |
||
344 | |||
345 | elseif( option == "resetaiglist" ) then |
||
346 | InviteOMatic_ResetAIG(); |
||
347 | InviteOMatic.log("Already in group list reset"); |
||
348 | |||
349 | elseif( option == "promote" ) then |
||
350 | InviteOMatic_PromoteAll(); |
||
351 | |||
352 | elseif( option == "demote" ) then |
||
353 | InviteOMatic_DemoteAll(); |
||
354 | |||
355 | elseif( option == "aigttl" ) then |
||
356 | if( value ) then |
||
357 | local num = tonumber(value); |
||
358 | if( num ) then |
||
359 | if( num >= 0 and num <= 20 ) then |
||
360 | InviteOMaticOptions["aigttl"] = num; |
||
361 | InviteOMatic.log("Already in group retries set to: "..InviteOMaticOptions["aigttl"]); |
||
362 | InviteOMatic_KhaosSetKey("InviteOMatic", "InviteAIGRetry", "slider", InviteOMaticOptions["aigttl"]); |
||
363 | else |
||
364 | InviteOMatic.log("Number must be between 0 and 20"); |
||
365 | end |
||
366 | end |
||
367 | end |
||
368 | elseif( option == "ignorettl" ) then |
||
369 | if( value ) then |
||
370 | local num = tonumber(value); |
||
371 | if( num ) then |
||
372 | if( num >= 0 and num <= 10 ) then |
||
373 | InviteOMaticOptions["ignorettl"] = num; |
||
374 | InviteOMatic.log("Ignore retries set to: "..InviteOMaticOptions["ignorettl"]); |
||
375 | InviteOMatic_KhaosSetKey("InviteOMatic", "InviteIgnoreRetry", "slider", InviteOMaticOptions["ignorettl"]); |
||
376 | else |
||
377 | InviteOMatic.log("Number must be between 0 and 10"); |
||
378 | end |
||
379 | end |
||
380 | end |
||
381 | |||
382 | elseif( option == "declinettl" ) then |
||
383 | if( value ) then |
||
384 | local num = tonumber(value); |
||
385 | if( num ) then |
||
386 | if( num >= 0 and num <= 10 ) then |
||
387 | InviteOMaticOptions["declinettl"] = num; |
||
388 | InviteOMatic.log("Decline retries set to: "..InviteOMaticOptions["declinettl"]); |
||
389 | InviteOMatic_KhaosSetKey("InviteOMatic", "InviteDeclineRetry", "slider", InviteOMaticOptions["declinettl"]); |
||
390 | else |
||
391 | InviteOMatic.log("Number must be between 0 and 10"); |
||
392 | end |
||
393 | end |
||
394 | end |
||
395 | |||
396 | else |
||
397 | InviteOMatic.log("Unknown option: "..option); |
||
398 | InviteOMatic.log("Usage: /iom option value"); |
||
399 | InviteOMatic.log("Options:"); |
||
400 | InviteOMatic.log(" autoinvite on|off -- Turns autoinvite on/off"); |
||
401 | InviteOMatic.log(" autopurge on|off -- Turns autopurge on/off"); |
||
402 | InviteOMatic.log(" whisperinvite on|off -- Turns whisperinvite on/off"); |
||
403 | InviteOMatic.log(" debug on|off -- Turns debug messages on/off"); |
||
404 | InviteOMatic.log(" spam on|off -- Turns the invite spam on/off"); |
||
405 | InviteOMatic.log(" spammsg default|\"newmsg\" -- Sets invite msg to newmsg"); |
||
406 | InviteOMatic.log(" aigmsg default|\"newmsg\" -- Sets AIG msg to newmsg"); |
||
407 | InviteOMatic.log(" magicword default|\"word\" -- Sets the magic invite word (REGEXP)"); |
||
408 | InviteOMatic.log(" resetaiglist -- Resets the already in group list"); |
||
409 | InviteOMatic.log(" ignore playername -- Puts the player on the ignorelist (Will not be invited)"); |
||
410 | InviteOMatic.log(" removeignore playername -- Puts the player on the ignorelist (Will not be invited)"); |
||
411 | InviteOMatic.log(" promote -- Promotes all members of the raidgroup"); |
||
412 | InviteOMatic.log(" demote -- Demotes all members of the raidgroup"); |
||
413 | InviteOMatic.log(" aigttl num -- Set number of already in group retries to num"); |
||
414 | InviteOMatic.log(" ignorettl num -- Set number of ignore retries to num"); |
||
415 | InviteOMatic.log(" declinettl num -- Set number of decline retries to num"); |
||
416 | end |
||
417 | |||
418 | end |
||
419 | |||
420 | function InviteOMatic_KhaosSetKey(set, key, type, value) |
||
421 | if(Khaos) then |
||
422 | if(Khaos.getSetKey(set,key)) then |
||
423 | Khaos.setSetKeyParameter(set, key, type, value); |
||
424 | end |
||
425 | end |
||
426 | end |
||
427 | |||
428 | ---------------------------------------------------------------------- |
||
429 | -- Should this person be invited? (Do checks) |
||
430 | ---------------------------------------------------------------------- |
||
431 | function InviteOMatic_ShouldInvite(name) |
||
432 | if( not IOM_READY ) then |
||
433 | return; |
||
434 | end |
||
435 | if( InviteOMatic_IsDisabled() ) then |
||
436 | return; |
||
437 | end |
||
438 | |||
439 | if( name ~= nil ) then |
||
440 | local lowerName = string.lower(name); |
||
441 | |||
442 | if( InviteOMaticOptions["ignoreList"][lowerName] ~= nil ) then |
||
443 | -- This player is ignored, so dont invite |
||
444 | InviteOMatic.debug("Player "..charname.." is on ignore list, so will not get invited"); |
||
445 | return false; |
||
446 | end |
||
447 | |||
448 | -- Do checks on this specefic name (Will only reject, not accept) |
||
449 | |||
450 | if( IOM_AIG[name] and IOM_AIG[name] >= InviteOMaticOptions["aigttl"] ) then |
||
451 | |||
452 | if( not IOM_AIG_ERROR[name] ) then |
||
453 | IOM_AIG_ERROR[name] = true; |
||
454 | if( InviteOMaticOptions["sendAIGSpam"] ) then |
||
455 | SendChatMessage(InviteOMaticOptions["aigMsg"], "WHISPER",this.language,name); |
||
456 | end |
||
457 | end |
||
458 | |||
459 | return false; |
||
460 | |||
461 | end |
||
462 | if( IOM_DECLINE[name] and IOM_DECLINE[name] >= InviteOMaticOptions["declinettl"] ) then |
||
463 | return false; |
||
464 | end |
||
465 | |||
466 | if( IOM_IGNORE[name] and IOM_IGNORE[name] >= InviteOMaticOptions["ignorettl"] ) then |
||
467 | return false; |
||
468 | end |
||
469 | end |
||
470 | |||
471 | --Do general checks( Accept and reject ) |
||
472 | |||
473 | -- If raid officer or leader then ok |
||
474 | if( IsRaidLeader() or IsRaidOfficer() or IsPartyLeader() ) then |
||
475 | return true; |
||
476 | elseif( IOM_BG_ACTIVE and ((GetNumPartyMembers() > 0) or (GetNumRaidMembers() > 0)) ) then |
||
477 | --We are in a BG, but not able to invite |
||
478 | return false; |
||
479 | end |
||
480 | |||
481 | return true; |
||
482 | end |
||
483 | |||
484 | ---------------------------------------------------------------------- |
||
485 | -- Invite the player with the given name, if its ok |
||
486 | ---------------------------------------------------------------------- |
||
487 | function InviteOMatic_InvitePlayer(name) |
||
488 | if( InviteOMatic_IsDisabled() ) then |
||
489 | return; |
||
490 | end |
||
491 | |||
492 | if( name == nil ) then |
||
493 | return; |
||
494 | end |
||
495 | |||
496 | local lowerName = string.lower(name); |
||
497 | |||
498 | if( InviteOMaticOptions["ignoreList"][lowerName] ~= nil ) then |
||
499 | -- This player is ignored, so dont invite |
||
500 | InviteOMatic.debug("Player "..lowerName.." is on ignore list, so will not get invited"); |
||
501 | return; |
||
502 | end |
||
503 | |||
504 | InviteOMatic.debug("Checking invite: ("..name..")"); |
||
505 | |||
506 | local ok = InviteOMatic_ShouldInvite(name); |
||
507 | |||
508 | if( ok ) then |
||
509 | InviteOMatic.debug("("..name..") checked ok, inviting"); |
||
510 | |||
511 | if( IOM_GROUPBUG[name] ~= nil ) then |
||
512 | InviteOMatic.debug("Group bug2 maybee found. Uninviting first..."); |
||
513 | |||
514 | UninviteByName(name); |
||
515 | end |
||
516 | |||
517 | InviteByName(name); |
||
518 | |||
519 | IOM_GROUPBUG[name] = true; |
||
520 | |||
521 | else |
||
522 | InviteOMatic.debug("("..name..") failed check!"); |
||
523 | end |
||
524 | end |
||
525 | |||
526 | ---------------------------------------------------------------------- |
||
527 | -- Convert to Raid |
||
528 | ---------------------------------------------------------------------- |
||
529 | function InviteOMatic_MakeRaid() |
||
530 | if( InviteOMatic_IsDisabled() ) then |
||
531 | return; |
||
532 | end |
||
533 | |||
534 | local raidMembers = GetNumRaidMembers(); |
||
535 | local isLeader = IsPartyLeader(); |
||
536 | |||
537 | if( (raidMembers == 0) and isLeader ) then |
||
538 | |||
539 | InviteOMatic.debug("Converting to raid..."); |
||
540 | |||
541 | ConvertToRaid(); |
||
542 | end |
||
543 | end |
||
544 | |||
545 | ---------------------------------------------------------------------- |
||
546 | -- Function to handle enter world event |
||
547 | ---------------------------------------------------------------------- |
||
548 | function InviteOMatic_BGEvent() |
||
549 | InviteOMatic.debug("Battlefield status changed..."); |
||
550 | |||
551 | NUMBER_OF_BATTLEFIELDS = 3; |
||
552 | |||
553 | if( not IOM_BG_ACTIVE ) then |
||
554 | for i=1,NUMBER_OF_BATTLEFIELDS do |
||
555 | status, mapName, instanceID = GetBattlefieldStatus(i); |
||
556 | |||
557 | InviteOMatic.debug("Status: "..status..", MapName: "..mapName..", InstanceID: "..instanceID); |
||
558 | |||
559 | if( status == "active" ) then |
||
560 | |||
561 | InviteOMatic_EnteredBG(i); |
||
562 | |||
563 | end |
||
564 | end |
||
565 | else |
||
566 | status, mapName, instanceID = GetBattlefieldStatus(IOM_BG_ACTIVE_INDEX); |
||
567 | if( status ~= "active" ) then |
||
568 | -- You have left BG |
||
569 | InviteOMatic_LeftBG(IOM_BG_ACTIVE_INDEX); |
||
570 | end |
||
571 | end |
||
572 | end |
||
573 | |||
574 | ---------------------------------------------------------------------- |
||
575 | -- Function to handle whisper events |
||
576 | ---------------------------------------------------------------------- |
||
577 | function InviteOMatic_WhisperEvent(text, name) |
||
578 | if( InviteOMatic_IsDisabled() ) then |
||
579 | return; |
||
580 | end |
||
581 | |||
582 | InviteOMatic.debug("Tell recieved..."); |
||
583 | |||
584 | --If whisper invites isnt enabled, just return |
||
585 | if( not InviteOMaticOptions["whisperInvite"] ) then |
||
586 | return; |
||
587 | end |
||
588 | |||
589 | --Check if tell contains the magic word invite |
||
590 | |||
591 | sStart, sEnd = string.find(text, InviteOMaticOptions["magicWord"], 1); |
||
592 | if( sStart ~= nil ) then |
||
593 | |||
594 | --Check if the word just after invite is a player |
||
595 | sStart2, sEnd2 = string.find(text, "%s[^%s%?%.!]+", sEnd); |
||
596 | |||
597 | if( sStart2 ~= nil ) then |
||
598 | local foundName = string.lower( string.sub(text, sStart2+1, sEnd2) ); |
||
599 | |||
600 | if( foundName == "me" or foundName == "please" or foundName == "plz" or foundName == "plez" or foundName == "pleaz") then |
||
601 | IOM_AIG[name] = nil; |
||
602 | IOM_AIG_ERROR[name] = nil; |
||
603 | IOM_IGNORE[name] = nil; |
||
604 | IOM_DECLINE[name] = nil; |
||
605 | InviteOMatic.invite(name); |
||
606 | else |
||
607 | InviteOMatic.debug(name.." wants you to invite ("..foundName..")"); |
||
608 | |||
609 | IOM_WHOIS = true; |
||
610 | |||
611 | this:RegisterEvent("WHO_LIST_UPDATE"); |
||
612 | FriendsFrame:UnregisterEvent("WHO_LIST_UPDATE"); |
||
613 | SetWhoToUI(1); |
||
614 | |||
615 | -- Do lookup via Who command. |
||
616 | IOM_NAME_BY_WHO = string.lower(foundName); |
||
617 | IOM_NAME_BY_WHO_INVITER = name; |
||
618 | |||
619 | SendWho("n-\""..foundName.."\""); |
||
620 | end |
||
621 | else |
||
622 | IOM_AIG[name] = nil; |
||
623 | IOM_AIG_ERROR[name] = nil; |
||
624 | IOM_IGNORE[name] = nil; |
||
625 | IOM_DECLINE[name] = nil; |
||
626 | InviteOMatic.invite(name); |
||
627 | end |
||
628 | end |
||
629 | end |
||
630 | |||
631 | ---------------------------------------------------------------------- |
||
632 | -- Function to handle who events |
||
633 | ---------------------------------------------------------------------- |
||
634 | function InviteOMatic_WhoEvent() |
||
635 | |||
636 | if( IOM_WHOIS ) then |
||
637 | InviteOMatic.debug("WHO_LIST_UPDATED - ("..IOM_NAME_BY_WHO..")"); |
||
638 | |||
639 | local invited = false; |
||
640 | |||
641 | -- We saw our who, so reset everything back |
||
642 | |||
643 | SetWhoToUI(0); |
||
644 | FriendsFrame:RegisterEvent("WHO_LIST_UPDATE"); |
||
645 | this:UnregisterEvent("WHO_LIST_UPDATE"); |
||
646 | IOM_WHOIS = false; |
||
647 | |||
648 | -- Now process the who list |
||
649 | local length = GetNumWhoResults(); |
||
650 | |||
651 | for i=1,length do |
||
652 | charname, guildname, level, race, class, zone, unknown = GetWhoInfo(i); |
||
653 | |||
654 | InviteOMatic.debug("Found: "..charname); |
||
655 | |||
656 | charname = string.lower(charname); |
||
657 | |||
658 | if( charname == IOM_NAME_BY_WHO ) then |
||
659 | if( InviteOMaticOptions["ignoreList"][charname] ~= nil ) then |
||
660 | -- This player is ignored, so dont invite |
||
661 | InviteOMatic.log("Player "..charname.." is on ignore list, so will not get invited"); |
||
662 | return; |
||
663 | end |
||
664 | |||
665 | IOM_AIG[IOM_NAME_BY_WHO] = nil; |
||
666 | IOM_AIG_ERROR[IOM_NAME_BY_WHO] = nil; |
||
667 | IOM_IGNORE[IOM_NAME_BY_WHO] = nil; |
||
668 | IOM_DECLINE[IOM_NAME_BY_WHO] = nil; |
||
669 | InviteOMatic.invite(IOM_NAME_BY_WHO); |
||
670 | invited = true; |
||
671 | end |
||
672 | end |
||
673 | |||
674 | if( not invited ) then |
||
675 | if( InviteOMaticOptions["ignoreList"][IOM_NAME_BY_WHO_INVITER] ~= nil ) then |
||
676 | -- This player is ignored, so dont invite |
||
677 | InviteOMatic.log("Player "..charname.." is on ignore list, so will not get invited"); |
||
678 | return; |
||
679 | end |
||
680 | |||
681 | IOM_AIG[IOM_NAME_BY_WHO_INVITER] = nil; |
||
682 | IOM_AIG_ERROR[IOM_NAME_BY_WHO_INVITER] = nil; |
||
683 | IOM_IGNORE[IOM_NAME_BY_WHO_INVITER] = nil; |
||
684 | IOM_DECLINE[IOM_NAME_BY_WHO_INVITER] = nil; |
||
685 | |||
686 | InviteByName(IOM_NAME_BY_WHO_INVITER); |
||
687 | end |
||
688 | |||
689 | -- Done processing, reset IOM_NAME_BY_WHO, IOM_NAME_BY_WHO_INVITER |
||
690 | IOM_NAME_BY_WHO = "----"; |
||
691 | IOM_NAME_BY_WHO_INVITER = "----"; |
||
692 | end |
||
693 | end |
||
694 | |||
695 | ---------------------------------------------------------------------- |
||
696 | -- Called when InviteOMatic detects that you have entered a BG |
||
697 | -- |
||
698 | -- Sets up the events we want to listen for while in BG, and starts invite script |
||
699 | ---------------------------------------------------------------------- |
||
700 | function InviteOMatic_EnteredBG(index) |
||
701 | IOM_BG_ACTIVE_INDEX = index; |
||
702 | IOM_BG_ACTIVE = true; |
||
703 | |||
704 | status, mapName, instanceID = GetBattlefieldStatus(index); |
||
705 | |||
706 | local runtime = GetBattlefieldInstanceRunTime(); |
||
707 | |||
708 | InviteOMatic.debug("You entered "..mapName.." Runtime: "..runtime); |
||
709 | |||
710 | if( InviteOMaticOptions["autoInvite"] ) then |
||
711 | IOM_UPDATE_INVITE_TIMER = true; |
||
712 | end |
||
713 | |||
714 | if( InviteOMaticOptions["autoPurge"] ) then |
||
715 | IOM_UPDATE_PURGE_TIMER = true; |
||
716 | end |
||
717 | |||
718 | this:RegisterEvent("CHAT_MSG_SYSTEM"); |
||
719 | end |
||
720 | |||
721 | ---------------------------------------------------------------------- |
||
722 | -- This function purges players that are offline or has left the BG |
||
723 | ---------------------------------------------------------------------- |
||
724 | function InviteOMatic_DoPurge() |
||
725 | if( InviteOMatic_IsDisabled() ) then |
||
726 | return; |
||
727 | end |
||
728 | |||
729 | if( not InviteOMaticOptions["autoPurge"] ) then |
||
730 | return; |
||
731 | end |
||
732 | |||
733 | for i=1,GetNumRaidMembers() do |
||
734 | --do som check for each member determing if he is online, if he isnt, purge him |
||
735 | end |
||
736 | end |
||
737 | |||
738 | ---------------------------------------------------------------------- |
||
739 | -- Promotes all memebers of a raid group |
||
740 | ---------------------------------------------------------------------- |
||
741 | function InviteOMatic_PromoteAll() |
||
742 | if( InviteOMatic_IsDisabled() ) then |
||
743 | return; |
||
744 | end |
||
745 | |||
746 | for i=1,GetNumRaidMembers() do |
||
747 | local name = GetRaidRosterInfo(i); |
||
748 | |||
749 | if( IsRaidLeader() ) then |
||
750 | PromoteToAssistant(name); |
||
751 | end |
||
752 | |||
753 | end |
||
754 | end |
||
755 | |||
756 | ---------------------------------------------------------------------- |
||
757 | -- Demotes all memebers of a raid group |
||
758 | ---------------------------------------------------------------------- |
||
759 | function InviteOMatic_DemoteAll() |
||
760 | if( InviteOMatic_IsDisabled() ) then |
||
761 | return; |
||
762 | end |
||
763 | |||
764 | for i=1,GetNumRaidMembers() do |
||
765 | local name = GetRaidRosterInfo(i); |
||
766 | |||
767 | if( IsRaidLeader() ) then |
||
768 | DemoteAssistant(name); |
||
769 | end |
||
770 | |||
771 | end |
||
772 | end |
||
773 | |||
774 | ---------------------------------------------------------------------- |
||
775 | -- Disbands the raid group uninviting every member |
||
776 | ---------------------------------------------------------------------- |
||
777 | function InviteOMatic_DisbandRaidGroup() |
||
778 | if( InviteOMatic_IsDisabled() ) then |
||
779 | return; |
||
780 | end |
||
781 | |||
782 | for i=1,GetNumRaidMembers() do |
||
783 | --Remove player from raid |
||
784 | local name = GetRaidRosterInfo(i); |
||
785 | |||
786 | if( IsRaidLeader() or IsRaidOfficer() or IsPartyLeader() ) then |
||
787 | UninviteByName(name); |
||
788 | end |
||
789 | |||
790 | end |
||
791 | |||
792 | for i=1,GetNumPartyMembers() do |
||
793 | --Remove player from group |
||
794 | end |
||
795 | end |
||
796 | |||
797 | ---------------------------------------------------------------------- |
||
798 | -- This function tries to invite everyone that is not already in our group |
||
799 | ---------------------------------------------------------------------- |
||
800 | function InviteOMatic_SendInvites() |
||
801 | if( InviteOMatic_IsDisabled() ) then |
||
802 | return; |
||
803 | end |
||
804 | |||
805 | if( not InviteOMaticOptions["autoInvite"] ) then |
||
806 | return; |
||
807 | end |
||
808 | |||
809 | local bfCount = GetNumBattlefieldPositions(); |
||
810 | |||
811 | if( bfCount == 0 ) then |
||
812 | return; |
||
813 | end |
||
814 | |||
815 | InviteOMatic.debug("Sending invites - InviteOMatic_SendInvites()"); |
||
816 | |||
817 | if( not IOM_BG_ACTIVE ) then |
||
818 | InviteOMatic.debug("Not in a BG"); |
||
819 | return; |
||
820 | end |
||
821 | |||
822 | local now = GetTime(); |
||
823 | |||
824 | local delta = now - IOM_LAST_INVITE; |
||
825 | |||
826 | if( delta < IOM_INVITE_WAIT ) then |
||
827 | InviteOMatic.debug("Wait a little longer...("..delta..")"); |
||
828 | return; |
||
829 | end |
||
830 | |||
831 | if( not InviteOMatic_ShouldInvite(nil) ) then |
||
832 | -- We got a negative from ShouldInvite, so we stop here |
||
833 | return; |
||
834 | end |
||
835 | |||
836 | if( IOM_INVITE_FIRST ) then |
||
837 | IOM_INVITE_FIRST = false; |
||
838 | |||
839 | if( InviteOMaticOptions["sendInviteSpam"] ) then |
||
840 | SendChatMessage(InviteOMaticOptions["inviteMsg"], "SAY"); |
||
841 | end |
||
842 | end |
||
843 | |||
844 | -- Convert to raid if any members is in party |
||
845 | InviteOMatic_MakeRaid(); |
||
846 | |||
847 | local count = GetNumBattlefieldPositions(); -- Number of players not in our raid |
||
848 | |||
849 | if( (count > 4) and (GetNumRaidMembers() == 0) ) then |
||
850 | -- Not a raid yet so only invite 4 people |
||
851 | count = 5 - GetNumPartyMembers(); |
||
852 | end |
||
853 | |||
854 | for i=1,count do |
||
855 | posX, posY, name = GetBattlefieldPosition(i); |
||
856 | |||
857 | InviteOMatic.invite(name); |
||
858 | end |
||
859 | |||
860 | IOM_LAST_INVITE = GetTime(); |
||
861 | |||
862 | end |
||
863 | |||
864 | ---------------------------------------------------------------------- |
||
865 | -- Function to handle system messages |
||
866 | ---------------------------------------------------------------------- |
||
867 | function InviteOMatic_ChannelSystem(arg1) |
||
868 | if( InviteOMatic_IsDisabled() ) then |
||
869 | return; |
||
870 | end |
||
871 | |||
872 | local name = ""; |
||
873 | |||
874 | if( string.find(arg1, "has joined the battle") ) then |
||
875 | sS, sE = string.find(arg1, "%["); |
||
876 | sS2, sE2 = string.find(arg1, "%]"); |
||
877 | name = string.sub(arg1,sS+1,sS2-1); |
||
878 | InviteOMatic_PlayerJoinedBattle(name); |
||
879 | |||
880 | elseif( string.find(arg1, "has left the battle") ) then |
||
881 | sS, sE = string.find(arg1, "[^%s%!%?]+"); |
||
882 | name = string.sub(arg1,sS,sE); |
||
883 | InviteOMatic_PlayerLeftBattle(name); |
||
884 | |||
885 | elseif( string.find(arg1, "declines your group invitation") ) then |
||
886 | sS, sE = string.find(arg1, "[^%s%!%?]+"); |
||
887 | name = string.sub(arg1,sS,sE); |
||
888 | InviteOMatic_PlayerDeclined(name); |
||
889 | |||
890 | elseif( string.find(arg1, "is ignoring you") ) then |
||
891 | sS, sE = string.find(arg1, "[^%s%!%?]+"); |
||
892 | name = string.sub(arg1,sS,sE); |
||
893 | InviteOMatic_PlayerIgnores(name); |
||
894 | |||
895 | elseif( string.find(arg1, "is already in a group") ) then |
||
896 | sS, sE = string.find(arg1, "[^%s%!%?]+"); |
||
897 | name = string.sub(arg1,sS,sE); |
||
898 | InviteOMatic_PlayerAlreadyGrouped(name); |
||
899 | |||
900 | elseif( string.find(arg1, "joins the party") ) then |
||
901 | sS, sE = string.find(arg1, "[^%s%!%?]+"); |
||
902 | name = string.sub(arg1,sS,sE); |
||
903 | InviteOMatic_PlayerJoinedGroup(name); |
||
904 | |||
905 | elseif( string.find(arg1, "has joined the raid group") ) then |
||
906 | sS, sE = string.find(arg1, "[^%s%!%?]+"); |
||
907 | name = string.sub(arg1,sS,sE); |
||
908 | InviteOMatic_PlayerJoinedGroup(name); |
||
909 | |||
910 | elseif( string.find(arg1, "You have invited") ) then |
||
911 | sS, sE = string.find(arg1, "You have invited"); |
||
912 | sS2, sE2 = string.find(arg1, "[^%s%!%?]+", sE+1); |
||
913 | name = string.sub(arg1,sS2,sE2); |
||
914 | InviteOMatic_PlayerInvitedEvent(name); |
||
915 | |||
916 | else |
||
917 | InviteOMatic.debug("Unhandled sysmsg: "..arg1); |
||
918 | |||
919 | end |
||
920 | |||
921 | end |
||
922 | |||
923 | ---------------------------------------------------------------------- |
||
924 | -- Remove this player from the groupbug table |
||
925 | ---------------------------------------------------------------------- |
||
926 | function InviteOMatic_PlayerInvitedEvent(name) |
||
927 | InviteOMatic.debug("You invited: ("..name..")"); |
||
928 | |||
929 | IOM_GROUPBUG[name] = nil; |
||
930 | end |
||
931 | |||
932 | ---------------------------------------------------------------------- |
||
933 | -- Resets AIG list |
||
934 | ---------------------------------------------------------------------- |
||
935 | function InviteOMatic_ResetAIG() |
||
936 | if( InviteOMatic_IsDisabled() ) then |
||
937 | return; |
||
938 | end |
||
939 | |||
940 | InviteOMatic.debug("Resetting AIG list..."); |
||
941 | IOM_AIG = {}; |
||
942 | IOM_AIG_ERROR = {}; |
||
943 | end |
||
944 | |||
945 | ---------------------------------------------------------------------- |
||
946 | -- Resets DECLINE list |
||
947 | ---------------------------------------------------------------------- |
||
948 | function InviteOMatic_ResetDecline() |
||
949 | if( InviteOMatic_IsDisabled() ) then |
||
950 | return; |
||
951 | end |
||
952 | |||
953 | InviteOMatic.debug("Resetting Decline list..."); |
||
954 | IOM_DECLINE = {}; |
||
955 | end |
||
956 | |||
957 | ---------------------------------------------------------------------- |
||
958 | -- Resets IGNORE list |
||
959 | ---------------------------------------------------------------------- |
||
960 | function InviteOMatic_ResetIgnore() |
||
961 | if( InviteOMatic_IsDisabled() ) then |
||
962 | return; |
||
963 | end |
||
964 | |||
965 | InviteOMatic.debug("Resetting Ignore list..."); |
||
966 | IOM_IGNORE = {}; |
||
967 | end |
||
968 | |||
969 | ---------------------------------------------------------------------- |
||
970 | -- Player Joined Group |
||
971 | ---------------------------------------------------------------------- |
||
972 | function InviteOMatic_PlayerJoinedGroup(name) |
||
973 | if( IOM_BG_ACTIVE ) then |
||
974 | InviteOMatic_MakeRaid(); |
||
975 | |||
976 | IOM_AIG[name] = nil; |
||
977 | IOM_AIG_ERROR[name] = nil; |
||
978 | IOM_IGNORE[name] = nil; |
||
979 | IOM_DECLINE[name] = nil; |
||
980 | |||
981 | end |
||
982 | end |
||
983 | |||
984 | ---------------------------------------------------------------------- |
||
985 | -- Player Joined Battle |
||
986 | ---------------------------------------------------------------------- |
||
987 | function InviteOMatic_PlayerJoinedBattle(name) |
||
988 | |||
989 | if( InviteOMaticOptions["autoInvite"] ) then |
||
990 | InviteOMatic.invite(name); |
||
991 | end |
||
992 | end |
||
993 | |||
994 | ---------------------------------------------------------------------- |
||
995 | -- Player Left Battle |
||
996 | ---------------------------------------------------------------------- |
||
997 | function InviteOMatic_PlayerLeftBattle(name) |
||
998 | -- If purge is enabled, then uninvite this player |
||
999 | |||
1000 | if( InviteOMaticOptions["autoPurge"] ) then |
||
1001 | if( IsRaidLeader() or IsRaidOfficer() or IsPartyLeader() ) then |
||
1002 | for i=1,GetNumRaidMembers() do |
||
1003 | --Remove player from raid |
||
1004 | local name2 = GetRaidRosterInfo(i); |
||
1005 | if( name == name2 ) then |
||
1006 | UninviteByName(name); |
||
1007 | return; |
||
1008 | end |
||
1009 | end |
||
1010 | if( GetNumRaidMembers() == 0 ) then |
||
1011 | UninviteByName(name); |
||
1012 | end |
||
1013 | end |
||
1014 | end |
||
1015 | end |
||
1016 | |||
1017 | ---------------------------------------------------------------------- |
||
1018 | -- Player Declined |
||
1019 | ---------------------------------------------------------------------- |
||
1020 | function InviteOMatic_PlayerDeclined(name) |
||
1021 | -- Player declined our group invite |
||
1022 | if( IOM_DECLINE[name] == nil ) then |
||
1023 | IOM_DECLINE[name] = 1; |
||
1024 | else |
||
1025 | IOM_DECLINE[name] = IOM_DECLINE[name] + 1; |
||
1026 | |||
1027 | if( IOM_DECLINE[name] > InviteOMaticOptions["declinettl"] ) then |
||
1028 | IOM_DECLINE[name] = InviteOMaticOptions["declinettl"]; |
||
1029 | end |
||
1030 | end |
||
1031 | |||
1032 | InviteOMatic.debug(name.." declined invitation "..(InviteOMaticOptions["declinettl"] - IOM_DECLINE[name]).." retries left"); |
||
1033 | |||
1034 | end |
||
1035 | |||
1036 | ---------------------------------------------------------------------- |
||
1037 | -- Player Ignores |
||
1038 | ---------------------------------------------------------------------- |
||
1039 | function InviteOMatic_PlayerIgnores(name) |
||
1040 | -- Player ignored you |
||
1041 | if( IOM_IGNORE[name] == nil ) then |
||
1042 | IOM_IGNORE[name] = 0; |
||
1043 | else |
||
1044 | IOM_IGNORE[name] = IOM_IGNORE[name] + 1; |
||
1045 | |||
1046 | if( IOM_IGNORE[name] > InviteOMaticOptions["ignorettl"] ) then |
||
1047 | IOM_IGNORE[name] = InviteOMaticOptions["ignorettl"]; |
||
1048 | end |
||
1049 | end |
||
1050 | |||
1051 | InviteOMatic.debug(name.." ingored you "..(InviteOMaticOptions["ignorettl"] - IOM_IGNORE[name]).." retries left"); |
||
1052 | |||
1053 | end |
||
1054 | |||
1055 | ---------------------------------------------------------------------- |
||
1056 | -- Player Already in group |
||
1057 | ---------------------------------------------------------------------- |
||
1058 | function InviteOMatic_PlayerAlreadyGrouped(name) |
||
1059 | -- Player is already grouped |
||
1060 | if( IOM_AIG[name] == nil ) then |
||
1061 | IOM_AIG[name] = 0; |
||
1062 | else |
||
1063 | IOM_AIG[name] = IOM_AIG[name] + 1; |
||
1064 | |||
1065 | if( IOM_AIG[name] > InviteOMaticOptions["aigttl"] ) then |
||
1066 | IOM_AIG[name] = InviteOMaticOptions["aigttl"]; |
||
1067 | end |
||
1068 | end |
||
1069 | |||
1070 | InviteOMatic.debug(name.." was already in group "..(InviteOMaticOptions["aigttl"] - IOM_AIG[name]).." retries left"); |
||
1071 | |||
1072 | end |
||
1073 | |||
1074 | ---------------------------------------------------------------------- |
||
1075 | -- Called when InviteOMatic detects that you have left a BG |
||
1076 | ---------------------------------------------------------------------- |
||
1077 | function InviteOMatic_LeftBG() |
||
1078 | IOM_BG_ACTIVE_INDEX = -1; |
||
1079 | IOM_BG_ACTIVE = false; |
||
1080 | IOM_LAST_INVITE = 0; |
||
1081 | IOM_INVITE_FIRST = true; |
||
1082 | |||
1083 | IOM_AIG = {}; |
||
1084 | IOM_AIG_ERROR = {}; |
||
1085 | IOM_DECLINE = {}; |
||
1086 | IOM_IGNORE = {}; |
||
1087 | |||
1088 | IOM_GROUPBUG = {}; |
||
1089 | |||
1090 | |||
1091 | InviteOMatic.debug("You left the BattleGround"); |
||
1092 | |||
1093 | IOM_UPDATE_PURGE_TIMER = false; |
||
1094 | IOM_UPDATE_INVITE_TIMER = false; |
||
1095 | |||
1096 | this:UnregisterEvent("CHAT_MSG_SYSTEM"); |
||
1097 | end |
||
1098 | |||
1099 | ---------------------------------------------------------------------- |
||
1100 | -- Called On_Update |
||
1101 | ---------------------------------------------------------------------- |
||
1102 | function InviteOMatic_OnUpdate(dt) |
||
1103 | if( InviteOMatic_IsDisabled() ) then |
||
1104 | return; |
||
1105 | end |
||
1106 | |||
1107 | if( dt == nil ) then |
||
1108 | return; |
||
1109 | end |
||
1110 | |||
1111 | if( not IOM_READY ) then |
||
1112 | return; |
||
1113 | end |
||
1114 | |||
1115 | if( IOM_UPDATE_INVITE_TIMER ) then |
||
1116 | IOM_INVITE_TIMER = IOM_INVITE_TIMER - dt; |
||
1117 | if( IOM_INVITE_TIMER <= 0 ) then |
||
1118 | InviteOMatic.debug("Invite Timer fired..."); |
||
1119 | IOM_INVITE_TIMER = InviteOMaticOptions.inviteDelay; |
||
1120 | if( InviteOMaticOptions.autoInvite ) then |
||
1121 | InviteOMatic_SendInvites(); |
||
1122 | end |
||
1123 | end |
||
1124 | end |
||
1125 | |||
1126 | if( IOM_UPDATE_PURGE_TIMER ) then |
||
1127 | IOM_PURGE_TIMER = IOM_PURGE_TIMER - dt; |
||
1128 | if( IOM_PURGE_TIMER <= 0 ) then |
||
1129 | InviteOMatic.debug("Purge Timer fired..."); |
||
1130 | IOM_PURGE_TIMER = InviteOMaticOptions.purgeDelay; |
||
1131 | if( InviteOMaticOptions.autoPurge ) then |
||
1132 | InviteOMatic_DoPurge(); |
||
1133 | end |
||
1134 | end |
||
1135 | end |
||
1136 | end |
||
1137 | |||
1138 | ---------------------------------------------------------------------- |
||
1139 | -- Logs the msg to the default chat frame |
||
1140 | -- |
||
1141 | -- @param msg The message to output |
||
1142 | ---------------------------------------------------------------------- |
||
1143 | function IOM_PrintMsg(msg) |
||
1144 | if( InviteOMatic_IsDisabled() ) then |
||
1145 | return; |
||
1146 | end |
||
1147 | |||
1148 | if (DEFAULT_CHAT_FRAME) then |
||
1149 | DEFAULT_CHAT_FRAME:AddMessage(msg); |
||
1150 | end |
||
1151 | end |
||
1152 | |||
1153 | ---------------------------------------------------------------------- |
||
1154 | -- Logs the debug msg to the default chat frame |
||
1155 | -- |
||
1156 | -- @param msg The message to output |
||
1157 | ---------------------------------------------------------------------- |
||
1158 | function IOM_PrintDebugMsg(msg) |
||
1159 | if( InviteOMaticOptions["debug"] ) then |
||
1160 | InviteOMatic.log("IOM Debug - "..msg); |
||
1161 | end |
||
1162 | end |
||
1163 | |||
1164 | ---------------------------------------------------------------------- |
||
1165 | -- Checks if addon has been disabled in Khaos, and disables addon accordingly :) |
||
1166 | ---------------------------------------------------------------------- |
||
1167 | function InviteOMatic_IsDisabled() |
||
1168 | if( Khaos ) then |
||
1169 | return false; |
||
1170 | -- return not Khaos.getSetEnabled("InviteOMatic"); |
||
1171 | else |
||
1172 | -- InviteOMatic.log("Khaos not detected, so cant check status"); |
||
1173 | return false; |
||
1174 | end |
||
1175 | end |
||
1176 | |||
1177 | |||
1178 | ---------------------------------------------------------------------- |
||
1179 | -- Register a Khaos config |
||
1180 | ---------------------------------------------------------------------- |
||
1181 | function InviteOMatic_RegisterKhaos() |
||
1182 | if( Khaos ) then |
||
1183 | Khaos.registerFolder( |
||
1184 | { |
||
1185 | id = "invite"; |
||
1186 | text = "Invite"; |
||
1187 | helptext = "Invite helpers"; |
||
1188 | difficulty = 1; |
||
1189 | } |
||
1190 | ); |
||
1191 | local optionSet = |
||
1192 | { |
||
1193 | id="InviteOMatic"; |
||
1194 | text="InviteOMatic"; |
||
1195 | helptext="Invite Helper, with a twist!"; |
||
1196 | difficulty=1; |
||
1197 | options = { |
||
1198 | { |
||
1199 | id="InviteHeader"; |
||
1200 | text="InviteOMatic Settings"; |
||
1201 | helptext="InviteOMatic"; |
||
1202 | type = K_HEADER; |
||
1203 | }; |
||
1204 | { |
||
1205 | id="InviteAutoInvite"; |
||
1206 | text="Auto Invite"; |
||
1207 | helptext="Automatically invites everyone in a BG instance."; |
||
1208 | type = K_TEXT; |
||
1209 | check = true; |
||
1210 | callback = InviteOMatic_InviteAutoInviteCheck; |
||
1211 | feedback = function(state) end; |
||
1212 | default = { |
||
1213 | checked = true; |
||
1214 | }; |
||
1215 | disabled = { |
||
1216 | checked = false; |
||
1217 | }; |
||
1218 | }; |
||
1219 | { |
||
1220 | id="InviteAutoPurge"; |
||
1221 | text="Auto Purge"; |
||
1222 | helptext="Automatically purges offline players, and players that leaves the BG."; |
||
1223 | type = K_TEXT; |
||
1224 | check = true; |
||
1225 | callback = InviteOMatic_InviteAutoPurgeCheck; |
||
1226 | feedback = function(state) end; |
||
1227 | default = { |
||
1228 | checked = true; |
||
1229 | }; |
||
1230 | disabled = { |
||
1231 | checked = false; |
||
1232 | }; |
||
1233 | }; |
||
1234 | { |
||
1235 | id="InviteWhisperInvite"; |
||
1236 | text="Whisper Invite"; |
||
1237 | helptext="Automatically invites people whispering you the magic word 'invite'"; |
||
1238 | type = K_TEXT; |
||
1239 | check = true; |
||
1240 | callback = InviteOMatic_InviteWhisperCheck; |
||
1241 | feedback = function(state) end; |
||
1242 | default = { |
||
1243 | checked = true; |
||
1244 | }; |
||
1245 | disabled = { |
||
1246 | checked = false; |
||
1247 | }; |
||
1248 | }; |
||
1249 | { |
||
1250 | id="InviteDelay"; |
||
1251 | key="InviteDelay"; |
||
1252 | value=true; |
||
1253 | text="Time between invites:"; |
||
1254 | helptext="This value represents the time InviteOMatic will wait between each invite cycle, the value is in seconds."; |
||
1255 | type = K_SLIDER; |
||
1256 | check = false; |
||
1257 | setup = { |
||
1258 | sliderMin = 1; |
||
1259 | sliderMax = 20; |
||
1260 | sliderLowText = "Fast"; |
||
1261 | sliderHighText = "Slow"; |
||
1262 | sliderStep = 1; |
||
1263 | sliderText = "Invite Cycle"; |
||
1264 | sliderDisplayfunc = function (state) return state.slider; end; |
||
1265 | }; |
||
1266 | callback = InviteOMatic_InviteCycleSliderCallback; |
||
1267 | feedback = function(state) end; |
||
1268 | default = { |
||
1269 | slider = 10; |
||
1270 | }; |
||
1271 | disabled = { |
||
1272 | slider = 10; |
||
1273 | }; |
||
1274 | }; |
||
1275 | { |
||
1276 | id="PurgeDelay"; |
||
1277 | key="PurgeDelay"; |
||
1278 | value=true; |
||
1279 | text="Time between purges:"; |
||
1280 | helptext="This value represents the time InviteOMatic will wait between each purge cycle, the value is in seconds."; |
||
1281 | type = K_SLIDER; |
||
1282 | check = false; |
||
1283 | setup = { |
||
1284 | sliderMin = 1; |
||
1285 | sliderMax = 20; |
||
1286 | sliderLowText = "Fast"; |
||
1287 | sliderHighText = "Slow"; |
||
1288 | sliderStep = 1; |
||
1289 | sliderText = "Purge Cycle"; |
||
1290 | sliderDisplayfunc = function (state) return state.slider; end; |
||
1291 | }; |
||
1292 | callback = InviteOMatic_PurgeCycleSliderCallback; |
||
1293 | feedback = function(state) end; |
||
1294 | default = { |
||
1295 | slider = 10; |
||
1296 | }; |
||
1297 | disabled = { |
||
1298 | slider = 10; |
||
1299 | }; |
||
1300 | }; |
||
1301 | { |
||
1302 | id="InviteRetryHeader"; |
||
1303 | text="InviteOMatic Retry Settings"; |
||
1304 | helptext="InviteOMatic"; |
||
1305 | type = K_HEADER; |
||
1306 | }; |
||
1307 | { |
||
1308 | id="InviteAIGRetry"; |
||
1309 | value=true; |
||
1310 | text="Already in group retries:"; |
||
1311 | helptext="Number of retries to invite people that are already in group."; |
||
1312 | type = K_SLIDER; |
||
1313 | check = false; |
||
1314 | setup = { |
||
1315 | sliderMin = 0; |
||
1316 | sliderMax = 20; |
||
1317 | sliderLowText = "None"; |
||
1318 | sliderHighText = "Many"; |
||
1319 | sliderStep = 1; |
||
1320 | sliderText = "Number of Retries"; |
||
1321 | sliderDisplayfunc = function (state) return state.slider; end; |
||
1322 | }; |
||
1323 | callback = InviteOMatic_InviteAIGRetry; |
||
1324 | feedback = function(state) end; |
||
1325 | default = { |
||
1326 | slider = 10; |
||
1327 | }; |
||
1328 | disabled = { |
||
1329 | slider = 10; |
||
1330 | }; |
||
1331 | }; |
||
1332 | { |
||
1333 | id="InviteDeclineRetry"; |
||
1334 | key="InviteDeclineRetry"; |
||
1335 | value=true; |
||
1336 | text="Decline retries:"; |
||
1337 | helptext="Number of retries to invite people that decline an invitation."; |
||
1338 | type = K_SLIDER; |
||
1339 | check = false; |
||
1340 | setup = { |
||
1341 | sliderMin = 0; |
||
1342 | sliderMax = 10; |
||
1343 | sliderLowText = "None"; |
||
1344 | sliderHighText = "Many"; |
||
1345 | sliderStep = 1; |
||
1346 | sliderText = "Number of Retries"; |
||
1347 | sliderDisplayfunc = function (state) return state.slider; end; |
||
1348 | }; |
||
1349 | callback = InviteOMatic_InviteDeclineRetry; |
||
1350 | feedback = function(state) end; |
||
1351 | default = { |
||
1352 | slider = 1; |
||
1353 | }; |
||
1354 | disabled = { |
||
1355 | slider = 1; |
||
1356 | }; |
||
1357 | }; |
||
1358 | { |
||
1359 | id="InviteIgnoreRetry"; |
||
1360 | key="InviteIgnoreRetry"; |
||
1361 | value=true; |
||
1362 | text="Ignore retries:"; |
||
1363 | helptext="Number of retries to invite people that are ignoring you."; |
||
1364 | type = K_SLIDER; |
||
1365 | check = false; |
||
1366 | setup = { |
||
1367 | sliderMin = 0; |
||
1368 | sliderMax = 10; |
||
1369 | sliderLowText = "None"; |
||
1370 | sliderHighText = "Many"; |
||
1371 | sliderStep = 1; |
||
1372 | sliderText = "Number of Retries"; |
||
1373 | sliderDisplayfunc = function (state) return state.slider; end; |
||
1374 | }; |
||
1375 | callback = InviteOMatic_InviteIgnoreRetry; |
||
1376 | feedback = function(state) end; |
||
1377 | default = { |
||
1378 | slider = 1; |
||
1379 | }; |
||
1380 | disabled = { |
||
1381 | slider = 1; |
||
1382 | }; |
||
1383 | }; |
||
1384 | { |
||
1385 | id="InviteMagicHeader"; |
||
1386 | text="InviteOMatic Magic Word"; |
||
1387 | helptext="InviteOMatic"; |
||
1388 | type = K_HEADER; |
||
1389 | }; |
||
1390 | { |
||
1391 | id="InviteMagicWord"; |
||
1392 | value={IOM_INVITE_REG_EXP}; |
||
1393 | text="Magic Word (REGEXP)"; |
||
1394 | helptext="A reqular expression for the magic invite word."; |
||
1395 | type = K_EDITBOX; |
||
1396 | callback = InivteOMatic_InviteMagicWord; |
||
1397 | feedback = function(state) end; |
||
1398 | |||
1399 | setup = { |
||
1400 | callOn = {"enter"}; |
||
1401 | multiLine = true; |
||
1402 | }; |
||
1403 | default = { |
||
1404 | value = IOM_INVITE_REG_EXP; |
||
1405 | }; |
||
1406 | disabled = { |
||
1407 | value = ""; |
||
1408 | }; |
||
1409 | }; |
||
1410 | { |
||
1411 | id="InviteMsgHeader"; |
||
1412 | text="InviteOMatic Messages"; |
||
1413 | helptext="InviteOMatic"; |
||
1414 | type = K_HEADER; |
||
1415 | }; |
||
1416 | { |
||
1417 | id="InviteSendSpam"; |
||
1418 | text="Send spam message at invite"; |
||
1419 | helptext="Should the addon send a spam message over SAY when doing first invite."; |
||
1420 | type = K_TEXT; |
||
1421 | check = true; |
||
1422 | callback = InviteOMatic_SendSpamOption; |
||
1423 | feedback = function(state) end; |
||
1424 | default = { |
||
1425 | checked = true; |
||
1426 | }; |
||
1427 | disabled = { |
||
1428 | checked = false; |
||
1429 | }; |
||
1430 | }; |
||
1431 | { |
||
1432 | id="InviteSpamMsg"; |
||
1433 | value={IOM_FIRST_INVITE_SPAM_DEFAULT}; |
||
1434 | text="Invite Spam Message"; |
||
1435 | helptext="Message to spam when doing first invite round."; |
||
1436 | type = K_EDITBOX; |
||
1437 | callback = InivteOMatic_InviteSpamMsg; |
||
1438 | feedback = function(state) end; |
||
1439 | |||
1440 | setup = { |
||
1441 | callOn = {"enter"}; |
||
1442 | multiLine = true; |
||
1443 | }; |
||
1444 | default = { |
||
1445 | value = IOM_FIRST_INVITE_SPAM_DEFAULT; |
||
1446 | }; |
||
1447 | disabled = { |
||
1448 | value = ""; |
||
1449 | }; |
||
1450 | }; |
||
1451 | { |
||
1452 | id="InviteSendAIGSpam"; |
||
1453 | text="Send AIG spam"; |
||
1454 | helptext="Should a message be sent to a player who has reached the max number of Already in group retries."; |
||
1455 | type = K_TEXT; |
||
1456 | check = true; |
||
1457 | callback = InviteOMatic_SendAIGSpamOption; |
||
1458 | feedback = function(state) end; |
||
1459 | default = { |
||
1460 | checked = true; |
||
1461 | }; |
||
1462 | disabled = { |
||
1463 | checked = false; |
||
1464 | }; |
||
1465 | }; |
||
1466 | { |
||
1467 | id="InviteAIGSpamMsg"; |
||
1468 | value={IOM_ERROR_AIG_DEFAULT}; |
||
1469 | text="AIG Spam Message"; |
||
1470 | helptext="Message to send to a player who reaches the maximum number of Already in group retries."; |
||
1471 | type = K_EDITBOX; |
||
1472 | callback = InivteOMatic_AIGSpamMsg; |
||
1473 | feedback = function(state) end; |
||
1474 | setup = { |
||
1475 | callOn = {"enter"}; |
||
1476 | multiLine = true; |
||
1477 | }; |
||
1478 | default = { |
||
1479 | value = IOM_ERROR_AIG_DEFAULT; |
||
1480 | }; |
||
1481 | disabled = { |
||
1482 | value = ""; |
||
1483 | }; |
||
1484 | }; |
||
1485 | { |
||
1486 | id="InviteDebug"; |
||
1487 | text="Show debug messages"; |
||
1488 | helptext="Disable/Enable showing of debug strings, messages. (Mostly used for development)"; |
||
1489 | type = K_TEXT; |
||
1490 | check = true; |
||
1491 | callback = InviteOMatic_InviteDebugCheck; |
||
1492 | feedback = function(state) end; |
||
1493 | default = { |
||
1494 | checked = false; |
||
1495 | }; |
||
1496 | disabled = { |
||
1497 | checked = false; |
||
1498 | }; |
||
1499 | }; |
||
1500 | { |
||
1501 | id="InviteClearHeader"; |
||
1502 | text="InviteOMatic Clear Lists"; |
||
1503 | helptext="InviteOMatic"; |
||
1504 | type = K_HEADER; |
||
1505 | }; |
||
1506 | { |
||
1507 | id="InviteResetAIG"; |
||
1508 | text="Reset Already in group"; |
||
1509 | helptext="Resets the list of players that are already in a group"; |
||
1510 | type = K_BUTTON; |
||
1511 | callback = InviteOMatic_ResetAIG; |
||
1512 | setup={buttonText="Reset AIG"}; |
||
1513 | }; |
||
1514 | { |
||
1515 | id="InviteResetDecline"; |
||
1516 | text="Reset Decline"; |
||
1517 | helptext="Resets the list of players that declined the invite"; |
||
1518 | type = K_BUTTON; |
||
1519 | callback = InviteOMatic_ResetDecline; |
||
1520 | setup={buttonText="Reset Declines"}; |
||
1521 | }; |
||
1522 | { |
||
1523 | id="InviteResetIgnore"; |
||
1524 | text="Reset Ignore"; |
||
1525 | helptext="Resets the list of players that ignored you"; |
||
1526 | type = K_BUTTON; |
||
1527 | callback = InviteOMatic_ResetIgnore; |
||
1528 | setup={buttonText="Reset Ignores"}; |
||
1529 | }; |
||
1530 | }; |
||
1531 | default = true; |
||
1532 | }; |
||
1533 | |||
1534 | Khaos.registerOptionSet( |
||
1535 | "invite", optionSet |
||
1536 | ); |
||
1537 | else |
||
1538 | InviteOMatic.debug("Khaos not found"); |
||
1539 | end |
||
1540 | end |
||
1541 | |||
1542 | function InviteOMatic_InviteAutoInviteCheck(state) |
||
1543 | if( state.checked ) then |
||
1544 | InviteOMatic.debug("Auto invite enabled"); |
||
1545 | InviteOMaticOptions["autoInvite"] = true; |
||
1546 | |||
1547 | if( IOM_BG_ACTIVE ) then |
||
1548 | IOM_UPDATE_INVITE_TIMER = true; |
||
1549 | end |
||
1550 | |||
1551 | else |
||
1552 | InviteOMatic.debug("Auto invite disabled"); |
||
1553 | InviteOMaticOptions["autoInvite"] = false; |
||
1554 | |||
1555 | IOM_UPDATE_INVITE_TIMER = false; |
||
1556 | end |
||
1557 | end |
||
1558 | |||
1559 | function InviteOMatic_InviteWhisperCheck(state) |
||
1560 | if( state.checked ) then |
||
1561 | InviteOMatic.debug("Whisper invite enabled"); |
||
1562 | InviteOMaticOptions["whisperInvite"] = true; |
||
1563 | |||
1564 | else |
||
1565 | InviteOMatic.debug("Whisper invite disabled"); |
||
1566 | InviteOMaticOptions["whisperInvite"] = false; |
||
1567 | end |
||
1568 | end |
||
1569 | |||
1570 | function InviteOMatic_InviteAutoPurgeCheck(state) |
||
1571 | if( state.checked ) then |
||
1572 | InviteOMatic.debug("Auto purge enabled"); |
||
1573 | InviteOMaticOptions["autoPurge"] = true; |
||
1574 | |||
1575 | if( IOM_BG_ACTIVE ) then |
||
1576 | IOM_UPDATE_PURGE_TIMER = true; |
||
1577 | end |
||
1578 | |||
1579 | else |
||
1580 | InviteOMatic.debug("Auto purge disabled"); |
||
1581 | InviteOMaticOptions["autoPurge"] = false; |
||
1582 | |||
1583 | IOM_UPDATE_PURGE_TIMER = false; |
||
1584 | end |
||
1585 | end |
||
1586 | |||
1587 | function InviteOMatic_InviteIgnoreRetry(state) |
||
1588 | InviteOMatic.debug("Ignore retries set to: "..state.slider); |
||
1589 | InviteOMaticOptions["ignorettl"] = state.slider; |
||
1590 | |||
1591 | -- Update old TTL values, if one is bigger |
||
1592 | |||
1593 | end |
||
1594 | |||
1595 | function InviteOMatic_InviteDeclineRetry(state) |
||
1596 | InviteOMatic.debug("Decline retries set to: "..state.slider); |
||
1597 | InviteOMaticOptions["declinettl"] = state.slider; |
||
1598 | |||
1599 | -- Update old TTL values, if one is bigger |
||
1600 | |||
1601 | end |
||
1602 | |||
1603 | function InviteOMatic_InviteAIGRetry(state) |
||
1604 | InviteOMatic.debug("Already in group retries set to: "..state.slider); |
||
1605 | InviteOMaticOptions["aigttl"] = state.slider; |
||
1606 | |||
1607 | -- Update old TTL values, if one is bigger |
||
1608 | |||
1609 | end |
||
1610 | |||
1611 | function InviteOMatic_SendAIGSpamOption(state) |
||
1612 | if( state.checked ) then |
||
1613 | InviteOMatic.debug("Sending spam message when max aig retries is reached."); |
||
1614 | InviteOMatic.sendAIGSpam = true; |
||
1615 | else |
||
1616 | InviteOMatic.debug("Not sending spam message when max aig retries is reached."); |
||
1617 | InviteOMatic.sendAIGSpam = false; |
||
1618 | end |
||
1619 | end |
||
1620 | |||
1621 | function InviteOMatic_SendSpamOption(state) |
||
1622 | if( state.checked ) then |
||
1623 | InviteOMatic.debug("Sending spam message at first invite"); |
||
1624 | InviteOMaticOptions["sendInviteSpam"] = true; |
||
1625 | else |
||
1626 | InviteOMatic.debug("Not sending spam message at first invite"); |
||
1627 | InviteOMaticOptions["sendInviteSpam"] = false; |
||
1628 | end |
||
1629 | end |
||
1630 | |||
1631 | function InviteOMatic_InviteDebugCheck(state) |
||
1632 | if( state.checked ) then |
||
1633 | InviteOMatic.debug("Debug output enabled."); |
||
1634 | InviteOMaticOptions["debug"] = true; |
||
1635 | else |
||
1636 | InviteOMatic.debug("Debug output disabled."); |
||
1637 | InviteOMaticOptions["debug"] = false; |
||
1638 | end |
||
1639 | end |
||
1640 | |||
1641 | function InviteOMatic_PurgeCycleSliderCallback(state) |
||
1642 | InviteOMatic.debug("Purge Cycle set to: "..state.slider.." seconds"); |
||
1643 | InviteOMaticOptions["purgeDelay"] = state.slider; |
||
1644 | |||
1645 | IOM_PURGE_TIMER = InviteOMaticOptions["purgeDelay"]; |
||
1646 | end; |
||
1647 | |||
1648 | function InviteOMatic_InviteCycleSliderCallback(state) |
||
1649 | InviteOMatic.debug("Invite Cycle set to: "..state.slider.." seconds"); |
||
1650 | InviteOMaticOptions["inviteDelay"] = state.slider; |
||
1651 | |||
1652 | IOM_INVITE_TIMER = InviteOMaticOptions["inviteDelay"]; |
||
1653 | |||
1654 | end; |
||
1655 | |||
1656 | function InivteOMatic_InviteMagicWord(state) |
||
1657 | InviteOMaticOptions["magicWord"] = state.value; |
||
1658 | InviteOMatic.debug("Magic word regexp set to: "..InviteOMaticOptions["magicWord"]); |
||
1659 | end; |
||
1660 | |||
1661 | function InivteOMatic_InviteSpamMsg(state) |
||
1662 | InviteOMaticOptions["inviteMsg"] = state.value; |
||
1663 | InviteOMatic.debug("First spam message set to: "..InviteOMaticOptions["inviteMsg"]); |
||
1664 | end; |
||
1665 | |||
1666 | function InivteOMatic_AIGSpamMsg(state) |
||
1667 | InviteOMaticOptions["aigMsg"] = state.value; |
||
1668 | InviteOMatic.debug("AIG spam message set to: "..InviteOMaticOptions["aigMsg"]); |
||
1669 | end; |
||
1670 | |||
1671 | InviteOMatic = { |
||
1672 | log = IOM_PrintMsg, |
||
1673 | debug = IOM_PrintDebugMsg, |
||
1674 | invite = InviteOMatic_InvitePlayer, |
||
1675 | sendInvites = InviteOMatic_SendInvites, |
||
1676 | disbandGroup = InviteOMatic_DisbandRaidGroup, |
||
1677 | } |