-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAutoInvite.lua
More file actions
635 lines (576 loc) · 25.2 KB
/
Copy pathAutoInvite.lua
File metadata and controls
635 lines (576 loc) · 25.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
-- ============================================================
-- RT v2 — AutoInvite.lua
-- LFM builder + auto-invite par mot-clé (inspiré Tactica)
-- Compatible WoW 1.12 / TurtleWoW
-- ============================================================
RT_AI = RT_AI or {}
local AI_ACTIVE = false
local AI_KEYWORD = "inv"
local AI_MAX = 40
local AI_QUEUE = {} -- {name, time}
local AI_INVITED = {} -- {name = true}
local AI_ROLE_MAP = {} -- {name = "Tank"/"Heal"/"DPS"}
-- Réinvitations : joueurs pas encore dans le raid (hors-ligne, groupés...)
local AI_PENDING = {} -- { [name] = { tries, grouped, groupedMsgSent } }
local AI_RETRY_INTERVAL = 30 -- secondes entre deux tentatives
local AI_MAX_TRIES = 10 -- ~5 min de retries avant abandon
local AI_LastRetry = 0
-- Corrèle un message système "already in a group" avec la dernière
-- invite envoyée (RT_BTrim est local à rt.lua, donc invisible ici —
-- on trim nous-mêmes plutôt que de dépendre d'un global qui vaut nil).
local AI_LastInvite = { name = nil, time = 0 }
local function AI_Trim(s)
s = s or ""
s = string.gsub(s, "^%s+", "")
s = string.gsub(s, "%s+$", "")
return s
end
local function AI_Whisper(target, text)
local lang = GetDefaultLanguage and GetDefaultLanguage("player") or nil
pcall(SendChatMessage, "[RT] " .. text, "WHISPER", lang, target)
end
-- Le joueur est-il déjà dans NOTRE groupe/raid ?
function RT_AI.IsGroupedWithUs(name)
local n = GetNumRaidMembers and GetNumRaidMembers() or 0
for i = 1, n do
if GetRaidRosterInfo(i) == name then return true end
end
local np = GetNumPartyMembers and GetNumPartyMembers() or 0
for i = 1, np do
if UnitName("party" .. i) == name then return true end
end
return false
end
-- Envoie une invitation et l'enregistre pour retry éventuel
function RT_AI.DoInvite(name)
AI_PENDING[name] = AI_PENDING[name] or { tries = 0 }
AI_PENDING[name].tries = AI_PENDING[name].tries + 1
AI_LastInvite.name = name
AI_LastInvite.time = GetTime and GetTime() or 0
pcall(InviteUnit or InviteByName, name)
end
-- ── Démarre l'auto-invite ──────────────────────────────────
function RT_AI.Start(keyword, maxPlayers)
AI_KEYWORD = string.lower(AI_Trim(keyword or "inv"))
AI_MAX = tonumber(maxPlayers) or 40
AI_ACTIVE = true
AI_QUEUE = {}
AI_INVITED = {}
AI_PENDING = {}
RT_Print("|cff88CCFF[AutoInvite]|r Active. Keyword: |cffFFD700" .. AI_KEYWORD .. "|r — max " .. AI_MAX .. " players.")
local msg = "[RT] Whisper '" .. AI_KEYWORD .. "' to join the raid! (" .. AI_MAX .. " spots)"
if RT_DB and RT_DB.ai and RT_DB.ai.lfmChannel then
pcall(SendChatMessage, msg, RT_DB.ai.lfmChannel)
end
RT_AI.UpdateUI()
end
function RT_AI.Stop()
AI_ACTIVE = false
AI_PENDING = {}
RT_Print("|cff88CCFF[AutoInvite]|r Stopped. " .. table.getn(AI_QUEUE) .. " player(s) invited.")
RT_AI.UpdateUI()
end
function RT_AI.IsActive() return AI_ACTIVE end
function RT_AI.GetQueue() return AI_QUEUE end
function RT_AI.GetKeyword() return AI_KEYWORD end
function RT_AI.GetMax() return AI_MAX end
function RT_AI.GetPendingCount()
local n = 0
for _ in pairs(AI_PENDING) do n = n + 1 end
return n
end
-- ── Traitement d'un whisper entrant ───────────────────────
function RT_AI.OnWhisper(sender, message)
if not AI_ACTIVE then return end
if not sender or sender == "" then return end
local msg = string.lower(AI_Trim(message))
-- '+1' = "je suis libre maintenant, réinvite-moi" (joueur qui était groupé)
if msg ~= AI_KEYWORD and msg ~= "+1" then return end
-- Déjà invité ?
if AI_INVITED[sender] then
if RT_AI.IsGroupedWithUs(sender) then
AI_Whisper(sender, "You're already in the raid!")
return
end
-- Invité mais toujours pas dans le raid (était groupé / hors-ligne /
-- a décliné) : on retente.
if AI_PENDING[sender] then
AI_PENDING[sender].grouped = nil
AI_PENDING[sender].groupedMsgSent = nil
end
RT_AI.DoInvite(sender)
AI_Whisper(sender, "Invite sent again!")
RT_Print("|cff88CCFF[AI]|r " .. sender .. " re-invited.")
return
end
-- Raid plein ?
local nRaid = GetNumRaidMembers and GetNumRaidMembers() or 0
if nRaid >= AI_MAX then
AI_Whisper(sender, "Sorry, the raid is full (" .. AI_MAX .. "/" .. AI_MAX .. ")")
RT_Print("|cffFFAA00[AI]|r Raid full, " .. sender .. " declined.")
return
end
-- Invite
table.insert(AI_QUEUE, { name=sender, time=GetTime and GetTime() or 0 })
AI_INVITED[sender] = true
RT_AI.DoInvite(sender)
AI_Whisper(sender, "Invite sent! Welcome.")
RT_Print("|cff88CCFF[AI]|r " .. sender .. " invited (#" .. table.getn(AI_QUEUE) .. ")")
RT_AI.UpdateUI()
-- Ajoute au roster si pas présent
if RT_DB and RT_DB.roster and not RT_DB.roster[sender] then
RT_DB.roster[sender] = { role = "DPS", sr = 0 }
if RT_RosterDisplay then RT_RosterDisplay() end
end
end
-- ── Messages système : détecte "déjà groupé" / "introuvable" ──
-- Quand l'invite échoue parce que le joueur est déjà dans un groupe,
-- on le prévient par whisper : il répond '+1' (ou le mot-clé) quand il
-- est libre et on le réinvite.
local AI_SysFrame = CreateFrame("Frame", "RT_AISysFrame")
AI_SysFrame:RegisterEvent("CHAT_MSG_SYSTEM")
AI_SysFrame:SetScript("OnEvent", function()
if not AI_ACTIVE then return end
local m = arg1 or ""
-- Message "déjà dans un groupe" : le texte exact varie selon serveur/version,
-- donc on essaie plusieurs formes ET on corrèle avec la dernière invite
-- envoyée (nom+heure) si l'extraction du nom échoue.
local isGrouped = string.find(m, "already in a group", 1, true)
or string.find(m, "already in a raid", 1, true)
or string.find(m, "d.j. dans un groupe")
if isGrouped then
local _, _, who = string.find(m, "^(%S+) is already in a") -- ancré début de ligne
if not who then _, _, who = string.find(m, "(%S+) is already in a") end -- n'importe où
if not who then _, _, who = string.find(m, "(%S+) est d.j. dans un groupe") end
if not (who and AI_INVITED[who]) then
-- Nom absent OU pas le nôtre (ex: texte custom serveur qui capture un
-- mot générique) : on corrèle avec la dernière invite envoyée (<3s).
local now = GetTime and GetTime() or 0
if AI_LastInvite.name and (now - AI_LastInvite.time) < 3 and AI_INVITED[AI_LastInvite.name] then
who = AI_LastInvite.name
end
end
if who and AI_INVITED[who] then
local p = AI_PENDING[who] or { tries = 0 }
AI_PENDING[who] = p
p.grouped = true
if not p.groupedMsgSent then
p.groupedMsgSent = true
AI_Whisper(who, "You're currently in another group. Reply '+1' (or '"
.. AI_KEYWORD .. "') as soon as you're free and I'll invite you right away.")
RT_Print("|cffFFAA00[AI]|r " .. who .. " is already grouped — asked to reply '+1' when free.")
end
return
end
end
-- EN "Cannot find player 'X'." (hors-ligne) → le retry le rattrapera au login
local _, _, off = string.find(m, "find player '([^']+)'")
if off and AI_PENDING[off] then
AI_PENDING[off].offline = true
end
end)
-- ── Retry : réinvite toutes les 30 s (rattrape aussi les logins) ──
local AI_RetryFrame = CreateFrame("Frame", "RT_AIRetryFrame")
AI_RetryFrame:SetScript("OnUpdate", function()
if not AI_ACTIVE then return end
if not (RT_DB and RT_DB.ai and RT_DB.ai.retry30) then return end
local now = GetTime and GetTime() or 0
if (now - AI_LastRetry) < AI_RETRY_INTERVAL then return end
AI_LastRetry = now
for name, p in pairs(AI_PENDING) do
if RT_AI.IsGroupedWithUs(name) then
AI_PENDING[name] = nil -- il est arrivé : terminé
elseif p.grouped then
-- groupé ailleurs : on ne spamme pas, il doit répondre '+1'
elseif p.tries >= AI_MAX_TRIES then
AI_PENDING[name] = nil -- abandon après ~5 min
RT_Print("|cff888888[AI] " .. name .. " never joined — giving up.|r")
else
RT_AI.DoInvite(name) -- hors-ligne au moment T → invité au login
end
end
end)
-- ── Lien avec Roster/Groups : dès qu'un joueur qu'on a invité apparaît
-- vraiment dans le raid, on détecte sa classe (fiable, via GetRaidRosterInfo)
-- et, si l'option est activée, on le place dans le 1er slot libre du
-- preset de groupes actif. AI_PLACED évite de refaire le traitement à
-- chaque RAID_ROSTER_UPDATE (et de déplacer un joueur déjà repositionné
-- manuellement par le raid leader).
local AI_PLACED = {} -- { [name] = true }
local function AI_PlaceInGroup(name)
RT_DB = RT_DB or {}
if not RT_DB.v3grppresets then
local gs = {}
for g = 1, 8 do gs[g] = { names = {}, role = 1 } end
RT_DB.v3grppresets = { active = 1, presets = { [1] = { name = "Preset 1", groups = gs } } }
end
local pd = RT_DB.v3grppresets
local act = pd.active or 1
local preset = pd.presets[act]
if not preset then
local gs = {}
for g = 1, 8 do gs[g] = { names = {}, role = 1 } end
preset = { name = "Preset " .. act, groups = gs }
pd.presets[act] = preset
end
preset.groups = preset.groups or {}
for g = 1, 8 do
preset.groups[g] = preset.groups[g] or { names = {}, role = 1 }
preset.groups[g].names = preset.groups[g].names or {}
for s = 1, 5 do
if preset.groups[g].names[s] == name then
return false -- déjà placé quelque part, on ne bouge rien
end
end
end
for g = 1, 8 do
for s = 1, 5 do
local cur = preset.groups[g].names[s]
if not cur or cur == "" then
preset.groups[g].names[s] = name
if RT and RT.Store and RT.Store.Notify then RT.Store.Notify("groups") end
return true
end
end
end
return false -- plus aucune place libre
end
local AI_RosterFrame = CreateFrame("Frame", "RT_AIRosterFrame")
AI_RosterFrame:RegisterEvent("RAID_ROSTER_UPDATE")
AI_RosterFrame:SetScript("OnEvent", function()
local n = GetNumRaidMembers and GetNumRaidMembers() or 0
if n == 0 then return end
local bd = RT_AI.EnsureDB()
for i = 1, n do
local name, _, _, _, class = GetRaidRosterInfo(i)
if name and AI_INVITED[name] and not AI_PLACED[name] then
AI_PLACED[name] = true
RT_DB.roster = RT_DB.roster or {}
local entry = RT_DB.roster[name] or { role = "DPS", sr = 0 }
if class and class ~= "" and (not entry.class or entry.class == "") then
entry.class = class
end
RT_DB.roster[name] = entry
if RT3_AutofixRoster then RT3_AutofixRoster() end
if RT and RT.Store and RT.Store.Notify then RT.Store.Notify("roster") end
if bd.autoGroup then AI_PlaceInGroup(name) end
end
end
end)
-- ── Frame whisper listener ─────────────────────────────────
local AI_ListenFrame = CreateFrame("Frame", "RT_AIListenFrame", UIParent)
AI_ListenFrame:RegisterEvent("CHAT_MSG_WHISPER")
AI_ListenFrame:SetScript("OnEvent", function(self, evName, a1, a2)
local message = a1 or arg1 or ""
local sender = a2 or arg2 or ""
RT_AI.OnWhisper(sender, message)
end)
-- ── Announce LFM en boucle (intervalle configurable en UI) ──
local AI_LastAnnounce = 0
local AI_AnnounceFrame = CreateFrame("Frame")
AI_AnnounceFrame:SetScript("OnUpdate", function()
if not AI_ACTIVE then return end
if not (RT_DB and RT_DB.ai and RT_DB.ai.autoAnnounce) then return end
local now = GetTime and GetTime() or 0
local interval = (RT_DB.ai and tonumber(RT_DB.ai.announceInterval)) or 60
if interval < 5 then interval = 5 end -- floor anti-spam serveur
if (now - AI_LastAnnounce) < interval then return end
AI_LastAnnounce = now
local nRaid = GetNumRaidMembers and GetNumRaidMembers() or 0
local channel = (RT_DB.ai and RT_DB.ai.lfmChannel) or "SAY"
local msg = "[LFM] Raid " .. (RT_DB.ai and RT_DB.ai.lfmDesc or "")
.. " — " .. nRaid .. "/" .. AI_MAX
.. " — Whisper '" .. AI_KEYWORD .. "' to join"
pcall(SendChatMessage, msg, channel)
end)
-- ── Kick de la queue ────────────────────────────────────────
function RT_AI.RemoveFromQueue(name)
for i = table.getn(AI_QUEUE), 1, -1 do
if AI_QUEUE[i].name == name then
table.remove(AI_QUEUE, i)
AI_INVITED[name] = nil
break
end
end
RT_AI.UpdateUI()
end
-- ── Mise à jour UI ─────────────────────────────────────────
-- Hooks externes (ex: le module v3Invite) prévenus à chaque changement
-- d'état, en plus du rafraîchissement de l'ancien panneau v2 ci-dessous.
RT_AI.UIHooks = RT_AI.UIHooks or {}
function RT_AI.RegisterUIHook(fn)
if fn then table.insert(RT_AI.UIHooks, fn) end
end
function RT_AI.UpdateUI()
for i = 1, table.getn(RT_AI.UIHooks) do
pcall(RT_AI.UIHooks[i])
end
local statusLabel = getglobal("RT_AIStatusLabel")
if not statusLabel then return end
if AI_ACTIVE then
statusLabel:SetText("|cff44FF44AutoInvite: ON|r keyword: |cffFFD700" .. AI_KEYWORD
.. "|r " .. table.getn(AI_QUEUE) .. " invited")
else
statusLabel:SetText("|cffAAAAAA AutoInvite: OFF|r")
end
-- Refresh la liste
local listFrame = getglobal("RT_AIQueueContent")
if not listFrame then return end
for i = 1, 30 do
local row = getglobal("RT_AIRow" .. i)
if row then
if i <= table.getn(AI_QUEUE) then
local e = AI_QUEUE[i]
local nameLbl = getglobal("RT_AIRowName" .. i)
if nameLbl then nameLbl:SetText("|cffFFFFFF" .. e.name .. "|r") end
row:Show()
else
row:Hide()
end
end
end
end
-- ── Construit l'UI dans le panneau AutoInvite ──────────────
-- Défauts partagés : appelable depuis n'importe quel module (v2 ou v3)
-- avant que le panneau v2 n'ait jamais été construit.
function RT_AI.EnsureDB()
RT_DB = RT_DB or {}
RT_DB.ai = RT_DB.ai or {
keyword = "inv",
maxPlayers = 40,
lfmDesc = "Molten Core",
lfmChannel = "SAY",
autoAnnounce = false,
announceInterval = 60,
retry30 = false,
autoGroup = false,
}
if not RT_DB.ai.announceInterval then RT_DB.ai.announceInterval = 60 end
if RT_DB.ai.autoGroup == nil then RT_DB.ai.autoGroup = false end
return RT_DB.ai
end
function RT_BuildUIAutoInvite(parent)
local p = RT_CreatePanel and RT_CreatePanel("RT_Panel_Invite") or parent
RT_AI.EnsureDB()
local title = p:CreateFontString(nil, "OVERLAY", "GameFontNormal")
title:SetPoint("TOPLEFT", p, "TOPLEFT", 6, -4)
title:SetText("|cff88CCFFAuto-Invite|r — invites automatically on whisper keyword")
title:SetTextColor(0.3, 0.8, 1.0)
-- Keyword
local kwLabel = p:CreateFontString(nil, "OVERLAY", "GameFontDisable")
kwLabel:SetPoint("TOPLEFT", p, "TOPLEFT", 6, -26)
kwLabel:SetText("Keyword:")
local kwEdit = CreateFrame("EditBox", "RT_AIKeywordEdit", p, "InputBoxTemplate")
kwEdit:SetPoint("LEFT", kwLabel, "RIGHT", 6, 0)
kwEdit:SetWidth(80)
kwEdit:SetHeight(20)
kwEdit:SetAutoFocus(false)
kwEdit:SetText(RT_DB.ai.keyword or "inv")
kwEdit:SetScript("OnEscapePressed", function() kwEdit:ClearFocus() end)
kwEdit:SetScript("OnEnterPressed", function()
RT_DB.ai.keyword = AI_Trim(kwEdit:GetText())
kwEdit:ClearFocus()
end)
-- Max players
local maxLabel = p:CreateFontString(nil, "OVERLAY", "GameFontDisable")
maxLabel:SetPoint("LEFT", kwEdit, "RIGHT", 12, 0)
maxLabel:SetText("Max players:")
local maxEdit = CreateFrame("EditBox", "RT_AIMaxEdit", p, "InputBoxTemplate")
maxEdit:SetPoint("LEFT", maxLabel, "RIGHT", 6, 0)
maxEdit:SetWidth(42)
maxEdit:SetHeight(20)
maxEdit:SetAutoFocus(false)
maxEdit:SetText(tostring(RT_DB.ai.maxPlayers or 40))
maxEdit:SetScript("OnEscapePressed", function() maxEdit:ClearFocus() end)
maxEdit:SetScript("OnEnterPressed", function()
RT_DB.ai.maxPlayers = tonumber(maxEdit:GetText()) or 40
maxEdit:ClearFocus()
end)
-- Boutons Start / Stop
local startBtn = CreateFrame("Button", "RT_AIStartBtn", p, "UIPanelButtonTemplate")
startBtn:SetPoint("LEFT", maxEdit, "RIGHT", 12, 0)
startBtn:SetWidth(80)
startBtn:SetHeight(22)
startBtn:SetText("Start")
local sTex = startBtn:GetNormalTexture()
if sTex then sTex:SetVertexColor(0.1, 0.7, 0.2) end
startBtn:SetScript("OnClick", function()
local kw = AI_Trim(kwEdit:GetText())
local max = tonumber(maxEdit:GetText()) or 40
RT_DB.ai.keyword = kw
RT_DB.ai.maxPlayers = max
AI_KEYWORD = string.lower(kw)
AI_MAX = max
RT_AI.Start(kw, max)
end)
local stopBtn = CreateFrame("Button", "RT_AIStopBtn", p, "UIPanelButtonTemplate")
stopBtn:SetPoint("LEFT", startBtn, "RIGHT", 6, 0)
stopBtn:SetWidth(72)
stopBtn:SetHeight(22)
stopBtn:SetText("Stop")
local stTex = stopBtn:GetNormalTexture()
if stTex then stTex:SetVertexColor(0.8, 0.2, 0.1) end
stopBtn:SetScript("OnClick", function() RT_AI.Stop() end)
-- Toggle : réinvitation automatique toutes les 30 s
local retryBtn = CreateFrame("Button", "RT_AIRetryBtn", p, "UIPanelButtonTemplate")
retryBtn:SetPoint("LEFT", stopBtn, "RIGHT", 10, 0)
retryBtn:SetWidth(110)
retryBtn:SetHeight(22)
local function retryPaint()
local tex = retryBtn:GetNormalTexture()
if RT_DB.ai.retry30 then
retryBtn:SetText("Retry 30s: ON")
if tex then tex:SetVertexColor(0.1, 0.6, 0.2) end
else
retryBtn:SetText("Retry 30s: OFF")
if tex then tex:SetVertexColor(0.4, 0.4, 0.4) end
end
end
retryBtn:SetScript("OnClick", function()
RT_DB.ai.retry30 = not RT_DB.ai.retry30
retryPaint()
if RT_DB.ai.retry30 then
RT_Print("|cff88CCFF[AI]|r Retry ON: pending players are re-invited every 30s (also catches players logging in). Players grouped elsewhere get a whisper and must reply '+1'.")
end
end)
retryPaint()
-- Description LFM
local lfmLabel = p:CreateFontString(nil, "OVERLAY", "GameFontDisable")
lfmLabel:SetPoint("TOPLEFT", p, "TOPLEFT", 6, -52)
lfmLabel:SetText("LFM message:")
local lfmEdit = CreateFrame("EditBox", "RT_AILFMEdit", p, "InputBoxTemplate")
lfmEdit:SetPoint("LEFT", lfmLabel, "RIGHT", 6, 0)
lfmEdit:SetWidth(260)
lfmEdit:SetHeight(20)
lfmEdit:SetAutoFocus(false)
lfmEdit:SetText(RT_DB.ai.lfmDesc or "Molten Core")
lfmEdit:SetScript("OnEscapePressed", function() lfmEdit:ClearFocus() end)
lfmEdit:SetScript("OnEnterPressed", function()
RT_DB.ai.lfmDesc = lfmEdit:GetText()
lfmEdit:ClearFocus()
end)
-- Channel LFM
local chanLabel = p:CreateFontString(nil, "OVERLAY", "GameFontDisable")
chanLabel:SetPoint("LEFT", lfmEdit, "RIGHT", 8, 0)
chanLabel:SetText("Channel:")
local chanEdit = CreateFrame("EditBox", "RT_AIChanEdit", p, "InputBoxTemplate")
chanEdit:SetPoint("LEFT", chanLabel, "RIGHT", 6, 0)
chanEdit:SetWidth(60)
chanEdit:SetHeight(20)
chanEdit:SetAutoFocus(false)
chanEdit:SetText(RT_DB.ai.lfmChannel or "SAY")
chanEdit:SetScript("OnEscapePressed", function() chanEdit:ClearFocus() end)
chanEdit:SetScript("OnEnterPressed", function()
RT_DB.ai.lfmChannel = string.upper(AI_Trim(chanEdit:GetText()))
chanEdit:ClearFocus()
end)
-- Bouton annoncer manuellement
local announceBtn = CreateFrame("Button", nil, p, "UIPanelButtonTemplate")
announceBtn:SetPoint("LEFT", chanEdit, "RIGHT", 8, 0)
announceBtn:SetWidth(80)
announceBtn:SetHeight(20)
announceBtn:SetText("Announce")
announceBtn:SetScript("OnClick", function()
local desc = lfmEdit:GetText()
local channel = string.upper(AI_Trim(chanEdit:GetText()))
local nRaid = GetNumRaidMembers and GetNumRaidMembers() or 0
local kw = AI_Trim(kwEdit:GetText())
local msg = "[LFM] Raid " .. desc .. " — " .. nRaid .. "/" .. (tonumber(maxEdit:GetText()) or 40)
.. " — Whisper '" .. kw .. "' to join"
pcall(SendChatMessage, msg, channel)
end)
-- Auto-spam toggle + intervalle configurable (répète l'annonce LFM toutes les N secondes)
local spamLabel = p:CreateFontString(nil, "OVERLAY", "GameFontDisable")
spamLabel:SetPoint("TOPLEFT", p, "TOPLEFT", 6, -74)
spamLabel:SetText("Repeat every")
local intervalEdit = CreateFrame("EditBox", "RT_AIIntervalEdit", p, "InputBoxTemplate")
intervalEdit:SetPoint("LEFT", spamLabel, "RIGHT", 6, 0)
intervalEdit:SetWidth(40)
intervalEdit:SetHeight(20)
intervalEdit:SetAutoFocus(false)
intervalEdit:SetText(tostring(RT_DB.ai.announceInterval or 60))
intervalEdit:SetScript("OnEscapePressed", function() intervalEdit:ClearFocus() end)
intervalEdit:SetScript("OnEnterPressed", function()
local v = tonumber(intervalEdit:GetText()) or 60
if v < 5 then v = 5 end
RT_DB.ai.announceInterval = v
intervalEdit:SetText(tostring(v))
intervalEdit:ClearFocus()
end)
local secLabel = p:CreateFontString(nil, "OVERLAY", "GameFontDisable")
secLabel:SetPoint("LEFT", intervalEdit, "RIGHT", 4, 0)
secLabel:SetText("sec")
local spamBtn = CreateFrame("Button", "RT_AISpamBtn", p, "UIPanelButtonTemplate")
spamBtn:SetPoint("LEFT", secLabel, "RIGHT", 10, 0)
spamBtn:SetWidth(110)
spamBtn:SetHeight(20)
local function spamPaint()
local tex = spamBtn:GetNormalTexture()
if RT_DB.ai.autoAnnounce then
spamBtn:SetText("Auto-spam: ON")
if tex then tex:SetVertexColor(0.1, 0.6, 0.2) end
else
spamBtn:SetText("Auto-spam: OFF")
if tex then tex:SetVertexColor(0.4, 0.4, 0.4) end
end
end
spamBtn:SetScript("OnClick", function()
-- valide l'intervalle tapé avant d'activer
local v = tonumber(intervalEdit:GetText()) or 60
if v < 5 then v = 5 end
RT_DB.ai.announceInterval = v
intervalEdit:SetText(tostring(v))
RT_DB.ai.autoAnnounce = not RT_DB.ai.autoAnnounce
AI_LastAnnounce = 0 -- annonce immédiate au démarrage
spamPaint()
if RT_DB.ai.autoAnnounce then
RT_Print("|cff88CCFF[AI]|r Auto-spam ON: LFM message repeats every " .. v .. "s while AutoInvite is active.")
end
end)
spamPaint()
-- Status
local statusLabel = p:CreateFontString("RT_AIStatusLabel", "OVERLAY", "GameFontHighlightSmall")
statusLabel:SetPoint("TOPLEFT", p, "TOPLEFT", 6, -102)
statusLabel:SetWidth(720)
statusLabel:SetJustifyH("LEFT")
statusLabel:SetText("|cffAAAAAA AutoInvite: OFF|r")
-- Liste des invités
local queueTitle = p:CreateFontString(nil, "OVERLAY", "GameFontNormal")
queueTitle:SetPoint("TOPLEFT", p, "TOPLEFT", 6, -120)
queueTitle:SetText("|cffCCCCCCInvite queue|r")
local queueScroll = CreateFrame("ScrollFrame", "RT_AIQueueScroll", p, "UIPanelScrollFrameTemplate")
queueScroll:SetPoint("TOPLEFT", p, "TOPLEFT", 6, -136)
queueScroll:SetWidth(700)
queueScroll:SetHeight(280)
local queueContent = CreateFrame("Frame", "RT_AIQueueContent", queueScroll)
queueContent:SetWidth(680)
queueContent:SetHeight(900)
queueScroll:SetScrollChild(queueContent)
for i = 1, 30 do
local row = CreateFrame("Frame", "RT_AIRow" .. i, queueContent)
row:SetWidth(680)
row:SetHeight(18)
row:SetPoint("TOPLEFT", queueContent, "TOPLEFT", 0, -(i-1)*18)
row:Hide()
local num = row:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
num:SetPoint("LEFT", row, "LEFT", 2, 0)
num:SetWidth(24)
num:SetText(i .. ".")
num:SetTextColor(0.6, 0.6, 0.6)
local nameLbl = row:CreateFontString("RT_AIRowName" .. i, "OVERLAY", "GameFontNormalSmall")
nameLbl:SetPoint("LEFT", num, "RIGHT", 2, 0)
nameLbl:SetWidth(160)
nameLbl:SetJustifyH("LEFT")
local removeBtn = CreateFrame("Button", nil, row, "UIPanelButtonTemplate")
removeBtn:SetPoint("LEFT", nameLbl, "RIGHT", 4, 0)
removeBtn:SetWidth(60)
removeBtn:SetHeight(16)
removeBtn:SetText("Remove")
local idx = i
removeBtn:SetScript("OnClick", function()
if AI_QUEUE[idx] then
RT_AI.RemoveFromQueue(AI_QUEUE[idx].name)
end
end)
end
end