Skip to content
This repository was archived by the owner on May 13, 2026. It is now read-only.

Commit 7bd2bc8

Browse files
committed
Add missing libraries and move commands to ACE3
1 parent 5b11d82 commit 7bd2bc8

11 files changed

Lines changed: 1706 additions & 110 deletions

File tree

Core/MultiBot.lua

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,38 @@
11
MultiBot = CreateFrame("Frame", nil, UIParent)
22

3+
local aceConsole = LibStub and LibStub("AceConsole-3.0", true)
4+
if aceConsole then
5+
aceConsole:Embed(MultiBot)
6+
end
7+
8+
MultiBot._registeredCommands = MultiBot._registeredCommands or {}
9+
10+
local function normalizeAlias(alias)
11+
if type(alias) ~= "string" then return nil end
12+
local cleaned = alias:gsub("^/", "")
13+
if cleaned == "" then return nil end
14+
return string.upper(cleaned)
15+
end
16+
17+
function MultiBot.RegisterCommandAliases(name, handler, aliases)
18+
if type(handler) ~= "function" or type(aliases) ~= "table" then return end
19+
local commandName = tostring(name or "MULTIBOT")
20+
MultiBot._registeredCommands[commandName] = MultiBot._registeredCommands[commandName] or {}
21+
22+
for _, alias in ipairs(aliases) do
23+
local normalized = normalizeAlias(alias)
24+
if normalized and not MultiBot._registeredCommands[commandName][normalized] then
25+
if MultiBot.RegisterChatCommand then
26+
MultiBot:RegisterChatCommand(string.lower(normalized), handler)
27+
else
28+
_G["SLASH_" .. commandName .. tostring(_)] = "/" .. string.lower(normalized)
29+
SlashCmdList[commandName] = handler
30+
end
31+
MultiBot._registeredCommands[commandName][normalized] = true
32+
end
33+
end
34+
end
35+
336
-- GM core --
437
MultiBot.GM = MultiBot.GM or false
538

Core/MultiBotHandler.lua

Lines changed: 11 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -1505,21 +1505,7 @@ MultiBot:SetScript("OnEvent", function()
15051505
end
15061506
end)
15071507

1508-
SLASH_MULTIBOT1 = "/multibot"
1509-
SLASH_MULTIBOT2 = "/mbot"
1510-
SLASH_MULTIBOT3 = "/mb"
1511-
1512-
--[[SlashCmdList["MULTIBOT"] = function()
1513-
if(MultiBot.state) then
1514-
for key, value in pairs(MultiBot.frames) do value:Hide() end
1515-
MultiBot.state = false
1516-
else
1517-
for key, value in pairs(MultiBot.frames) do value:Show() end
1518-
MultiBot.state = true
1519-
end
1520-
end]]--
1521-
1522-
SlashCmdList["MULTIBOT"] = function()
1508+
local function ToggleMultiBotUI()
15231509
-- don't touch to Shaman/Hunter bars
15241510
local function affect(frmKey, frm)
15251511
return frmKey ~= "ShamanQuick" and frmKey ~= "HunterQuick"
@@ -1538,97 +1524,24 @@ SlashCmdList["MULTIBOT"] = function()
15381524
-- Persist by character
15391525
MultiBotSave["UIVisible"] = MultiBot.state and true or false
15401526
end
1527+
MultiBot.RegisterCommandAliases("MULTIBOT", ToggleMultiBotUI, { "multibot", "mbot", "mb" })
15411528

1542-
SLASH_MULTIBOTOPTIONS1 = "/mbopt"
1543-
SlashCmdList["MULTIBOTOPTIONS"] = function()
1529+
local function OpenMultiBotOptions()
15441530
if InterfaceOptionsFrame_OpenToCategory then
15451531
InterfaceOptionsFrame_OpenToCategory("MultiBot")
15461532
InterfaceOptionsFrame_OpenToCategory("MultiBot") -- double appel: comportement connu 3.3.5
15471533
end
15481534
end
1535+
MultiBot.RegisterCommandAliases("MULTIBOTOPTIONS", OpenMultiBotOptions, { "mbopt" })
15491536

1550-
--[[-- ==== TESTS MULTIBOT ====
1551-
1552-
-- /mbdump -> affiche les intervalles et le throttle actuels
1553-
SLASH_MBDUMP1 = "/mbdump"
1554-
SlashCmdList["MBDUMP"] = function()
1555-
local t = MultiBotDB and MultiBotDB.timers or {}
1556-
local rate = MultiBot.GetThrottleRate and MultiBot.GetThrottleRate() or 5
1557-
local burst = MultiBot.GetThrottleBurst and MultiBot.GetThrottleBurst() or 8
1558-
DEFAULT_CHAT_FRAME:AddMessage(string.format(
1559-
"[MultiBot] Timers: stats=%.2fs, talent=%.2fs, invite=%.2fs, sort=%.2fs | Throttle: rate=%d/s, burst=%d",
1560-
t.stats or -1, t.talent or -1, t.invite or -1, t.sort or -1, rate, burst
1561-
))
1562-
end
1563-
1564-
-- /mbset <stats> <talent> <invite> <sort> -> règle les 4 sliders par script
1565-
-- ex: /mbset 10 2 3 0.5
1566-
SLASH_MBSET1 = "/mbset"
1567-
SlashCmdList["MBSET"] = function(msg)
1568-
local a,b,c,d = string.match(msg or "", "([%d%.]+)%s+([%d%.]+)%s+([%d%.]+)%s+([%d%.]+)")
1569-
if a then
1570-
MultiBot.SetTimer("stats", tonumber(a))
1571-
MultiBot.SetTimer("talent", tonumber(b))
1572-
MultiBot.SetTimer("invite", tonumber(c))
1573-
MultiBot.SetTimer("sort", tonumber(d))
1574-
DEFAULT_CHAT_FRAME:AddMessage("[MultiBot] MBSET ok."); SlashCmdList["MBDUMP"]()
1575-
else
1576-
DEFAULT_CHAT_FRAME:AddMessage("|cffff5555Usage: /mbset <stats> <talent> <invite> <sort>|r")
1577-
end
1578-
end
1579-
1580-
-- /mbspam <n> -> enfile n messages SAY pour tester le throttle (par défaut 20)
1581-
-- ex: /mbspam 30
1582-
SLASH_MBSPAM1 = "/mbspam"
1583-
SlashCmdList["MBSPAM"] = function(msg)
1584-
local n = tonumber(msg) or 20
1585-
if n > 200 then n = 200 end
1586-
for i=1,n do
1587-
-- Préfixe reconnaissable pour le log throttle facultatif
1588-
SendChatMessage(string.format("[MB_TEST] #%d", i), "SAY")
1589-
end
1590-
DEFAULT_CHAT_FRAME:AddMessage(string.format("[MultiBot] Spam enfile %d messages (throttle actif).", n))
1591-
end
1592-
1593-
-- /mbautostats on|off -> active/désactive le ping stats auto (pratique pour mesurer l’intervalle)
1594-
SLASH_MBAUTOSTATS1 = "/mbautostats"
1595-
SlashCmdList["MBAUTOSTATS"] = function(msg)
1596-
local on = string.lower(tostring(msg or "")) == "on"
1597-
MultiBot.auto = MultiBot.auto or {}
1598-
MultiBot.auto.stats = on
1599-
DEFAULT_CHAT_FRAME:AddMessage("[MultiBot] Auto stats: "..(on and "ON" or "OFF"))
1600-
end
1601-
1602-
-- /mbreset -> remet les valeurs d'origine (timers + throttle)
1603-
SLASH_MBRESET1 = "/mbreset"
1604-
SlashCmdList["MBRESET"] = function()
1605-
MultiBot.SetTimer("stats", 45)
1606-
MultiBot.SetTimer("talent", 3)
1607-
MultiBot.SetTimer("invite", 5)
1608-
MultiBot.SetTimer("sort", 1)
1609-
if MultiBot.SetThrottleRate then MultiBot.SetThrottleRate(5) end
1610-
if MultiBot.SetThrottleBurst then MultiBot.SetThrottleBurst(8) end
1611-
DEFAULT_CHAT_FRAME:AddMessage("[MultiBot] Reset valeurs par défaut."); SlashCmdList["MBDUMP"]()
1612-
end
1613-
1614-
SLASH_MBCHECK1 = "/mbcheck"
1615-
SlashCmdList["MBCHECK"] = function()
1616-
local wrapped = (SendChatMessage ~= MultiBot._throttleOrig)
1617-
DEFAULT_CHAT_FRAME:AddMessage(string.format("[MultiBot] Throttle actif: %s | SendChatMessage=%s",
1618-
wrapped and "OUI" or "NON",
1619-
tostring(SendChatMessage)
1620-
))
1621-
end]]--
1622-
1623-
SLASH_MBFAKEGM1 = "/mbfakegm"
1624-
SlashCmdList["MBFAKEGM"] = function(msg)
1537+
local function FakeGMCommand(msg)
16251538
local n = tonumber(msg or "") or 0
16261539
MultiBot.GM_DetectFromSystem(("Account level: %d"):format(n))
16271540
DEFAULT_CHAT_FRAME:AddMessage(("GM now: %s (lvl=%d, threshold=%d)"):format(tostring(MultiBot.GM), n, MultiBot.GM_THRESHOLD))
16281541
end
1542+
MultiBot.RegisterCommandAliases("MBFAKEGM", FakeGMCommand, { "mbfakegm" })
16291543

1630-
SLASH_MBCLASS1 = "/mbclass"
1631-
SlashCmdList["MBCLASS"] = function(msg)
1544+
local function ClassCommand(msg)
16321545
local canon = MultiBot.NormalizeClass(msg)
16331546
if canon then
16341547
DEFAULT_CHAT_FRAME:AddMessage(("Input='%s' -> Canon='%s' | Display='%s'"):format(
@@ -1637,10 +1550,10 @@ SlashCmdList["MBCLASS"] = function(msg)
16371550
DEFAULT_CHAT_FRAME:AddMessage(("Input='%s' -> (no match)"):format(tostring(msg)))
16381551
end
16391552
end
1553+
MultiBot.RegisterCommandAliases("MBCLASS", ClassCommand, { "mbclass" })
16401554

16411555
-- /mbclasstest -> batterie de cas utiles (aliases + localisés FR si le client est frFR)
1642-
SLASH_MBCLASSTEST1 = "/mbclasstest"
1643-
SlashCmdList["MBCLASSTEST"] = function()
1556+
local function ClassTestCommand()
16441557
local samples = {
16451558
"dk","death knight","DeathKnight",
16461559
"lock","warlock",
@@ -1651,4 +1564,5 @@ SlashCmdList["MBCLASSTEST"] = function()
16511564
for _, s in ipairs(samples) do
16521565
DEFAULT_CHAT_FRAME:AddMessage(("[MB] '%s' -> %s"):format(s, tostring(MultiBot.toClass(s))))
16531566
end
1654-
end
1567+
end
1568+
MultiBot.RegisterCommandAliases("MBCLASSTEST", ClassTestCommand, { "mbclasstest" })

Core/MultiBotInit.lua

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7017,24 +7017,28 @@ do
70177017
end)
70187018
end
70197019

7020-
-- Créer/Afficher (ou cacher) le bouton minimap APRÈS chargement complet
7020+
-- Create/refresh the minimap button after SavedVariables are available.
70217021
do
7022-
local ev = CreateFrame("Frame")
7023-
ev:RegisterEvent("PLAYER_LOGIN")
7024-
ev:SetScript("OnEvent", function(self, event)
7025-
self:UnregisterEvent("PLAYER_LOGIN")
7026-
-- SV garanties ici ; appliquer l’état mémorisé proprement
7022+
local function bootstrapMinimapButton()
70277023
if MultiBot and MultiBot.Minimap_Refresh then
70287024
MultiBot.Minimap_Refresh()
70297025
elseif MultiBot and MultiBot.Minimap_Create then
7030-
-- Fallback hyper défensif si Refresh pas encore défini
70317026
if not (MultiBotSave and MultiBotSave.Minimap and MultiBotSave.Minimap.hide) then
70327027
MultiBot.Minimap_Create()
7033-
--else
7034-
-- hide=true => ne crée pas le bouton
70357028
end
70367029
end
7037-
end)
7030+
end
7031+
7032+
if IsLoggedIn and IsLoggedIn() then
7033+
bootstrapMinimapButton()
7034+
else
7035+
local ev = CreateFrame("Frame")
7036+
ev:RegisterEvent("PLAYER_LOGIN")
7037+
ev:SetScript("OnEvent", function(self)
7038+
self:UnregisterEvent("PLAYER_LOGIN")
7039+
bootstrapMinimapButton()
7040+
end)
7041+
end
70387042
end
70397043

70407044
-- FINISH --

0 commit comments

Comments
 (0)