-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCore.lua
More file actions
147 lines (125 loc) · 4.28 KB
/
Core.lua
File metadata and controls
147 lines (125 loc) · 4.28 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
local addonName, BBT = ...
BBT = BBT or _G.BigBotTracker or {}
_G.BigBotTracker = BBT
BBT.addonName = addonName or "BigBotTracker"
local frame = CreateFrame("Frame")
local function handleSlashCommand(message)
message = BBT.Util.Trim(message or ""):lower()
if message == "" or message == "show" or message == "open" then
BBT.UI.Open()
return
end
if message == "status" then
local candidates = BBT.Storage.GetAllCandidates()
BBT.Util.Print(string.format("%d tracked candidates. Sync: %s", #candidates, BBT.Sync.status or "Unknown"))
return
end
if message == "sync on" then
BBT.Storage.GetSettings().sync.firstRunNoticeShown = true
BBT.Sync.SetEnabled(true)
BBT.Util.Print("Sync enabled over hidden guild/group addon channels.")
return
end
if message == "sync off" then
BBT.Sync.SetEnabled(false)
BBT.Util.Print("Network sync is disabled.")
return
end
if message == "clear buffers" then
BBT.Storage.ClearRuntimeBuffers()
BBT.Util.Print("Runtime scan buffers cleared.")
return
end
if message == "export" then
BBT.Storage.GetSettings().lastDebugSummary = BBT.Storage.BuildDebugSummary()
BBT.Util.Print("Debug summary saved in BigBotTrackerDB.settings.lastDebugSummary.")
return
end
local channelName = message:match("^channel%s+(.+)$")
if channelName and channelName ~= "" then
BBT.Util.Print("Custom sync channels are not used. Sync runs through hidden guild/group addon channels.")
return
end
local monitorName, monitorState = message:match("^monitor%s+(%S+)%s+(%S+)$")
if
(monitorName == "public" or monitorName == "trade" or monitorName == "services")
and (monitorState == "on" or monitorState == "off")
then
BBT.Storage.GetSettings().monitor[monitorName] = monitorState == "on"
BBT.Util.Print(
string.format("%s monitoring %s.", monitorName, monitorState == "on" and "enabled" or "disabled")
)
return
end
if message == "debug on" then
BBT.Storage.GetSettings().debug = true
BBT.Util.Print("Debug enabled.")
return
end
if message == "debug off" then
BBT.Storage.GetSettings().debug = false
BBT.Util.Print("Debug disabled.")
return
end
BBT.Util.Print(
"Commands: /bbt, /bbt status, /bbt sync on|off, /bbt monitor public|trade|services on|off, /bbt export, /bbt clear buffers, /bbt debug on|off"
)
end
local function initializeSlashCommands()
SLASH_BIGBOTTRACKER1 = "/bbt"
SLASH_BIGBOTTRACKER2 = "/bigbottracker"
SlashCmdList.BIGBOTTRACKER = handleSlashCommand
end
function BigBotTracker_OnAddonCompartmentClick()
if BBT.UI and BBT.UI.Toggle then
BBT.UI.Toggle()
end
end
local function onAddonLoaded(loadedName)
if loadedName ~= addonName then
return
end
BBT.Storage.Initialize()
BBT.Sync.Initialize()
BBT.UI.Create()
initializeSlashCommands()
frame:RegisterEvent("PLAYER_LOGIN")
frame:RegisterEvent("CHAT_MSG_CHANNEL")
frame:RegisterEvent("CHAT_MSG_ADDON")
frame:SetScript("OnUpdate", function(_, elapsed)
if BBT.Sync and BBT.Sync.OnUpdate then
BBT.Sync.OnUpdate()
end
if BBT.UI and BBT.UI.OnUpdate then
BBT.UI.OnUpdate(elapsed)
end
end)
end
local function onPlayerLogin()
if BBT.Sync and BBT.Sync.Start then
BBT.Sync.Start()
end
end
frame:SetScript("OnEvent", function(_, event, ...)
if event == "ADDON_LOADED" then
onAddonLoaded(...)
elseif event == "PLAYER_LOGIN" then
onPlayerLogin()
elseif event == "CHAT_MSG_CHANNEL" then
local text, sender, _, channelName, _, _, zoneChannelID, channelIndex, channelBaseName, _, lineID, guid = ...
BBT.ChatScanner.HandleChannelMessage(
text,
sender,
channelName,
zoneChannelID,
channelIndex,
channelBaseName,
lineID,
guid
)
elseif event == "CHAT_MSG_ADDON" then
local prefix, message, channel, sender = ...
BBT.Sync.HandleAddonMessage(prefix, message, channel, sender)
end
end)
frame:RegisterEvent("ADDON_LOADED")