Code format
This commit is contained in:
@@ -13,27 +13,27 @@ function shared.AgentTracker.Init()
|
||||
if Heimdall_Data.config.agentTracker.debug then
|
||||
print(string.format("[%s] Channel roster update received", ModuleName))
|
||||
end
|
||||
if not Heimdall_Data.config.agentTracker.enabled then
|
||||
if not Heimdall_Data.config.agentTracker.enabled then
|
||||
if Heimdall_Data.config.agentTracker.debug then
|
||||
print(string.format("[%s] Module disabled, ignoring roster update", ModuleName))
|
||||
end
|
||||
return
|
||||
return
|
||||
end
|
||||
local name = GetChannelDisplayInfo(index)
|
||||
if Heimdall_Data.config.agentTracker.debug then
|
||||
print(string.format("[%s] Processing channel update: %s (index: %d)", ModuleName, name or "nil", index))
|
||||
if Heimdall_Data.config.agentTracker.debug then
|
||||
print(string.format("[%s] Processing channel update: %s (index: %d)", ModuleName, name or "nil", index))
|
||||
end
|
||||
if name ~= Heimdall_Data.config.agentTracker.masterChannel then
|
||||
if name ~= Heimdall_Data.config.agentTracker.masterChannel then
|
||||
if Heimdall_Data.config.agentTracker.debug then
|
||||
print(string.format("[%s] Ignoring non-master channel: %s", ModuleName, name or "nil"))
|
||||
end
|
||||
return
|
||||
return
|
||||
end
|
||||
local count = select(5, GetChannelDisplayInfo(index))
|
||||
if Heimdall_Data.config.agentTracker.debug then
|
||||
print(string.format("[%s] Processing %d members in channel", ModuleName, count))
|
||||
end
|
||||
|
||||
|
||||
local newAgents = 0
|
||||
for i = 1, count do
|
||||
local name = GetChannelRosterInfo(index, i)
|
||||
@@ -44,11 +44,12 @@ function shared.AgentTracker.Init()
|
||||
newAgents = newAgents + 1
|
||||
end
|
||||
if Heimdall_Data.config.agentTracker.debug then
|
||||
print(string.format("[%s] %s agent: %s", ModuleName, isNewAgent and "Added new" or "Updated existing", name))
|
||||
print(string.format("[%s] %s agent: %s", ModuleName, isNewAgent and "Added new" or "Updated existing",
|
||||
name))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if Heimdall_Data.config.agentTracker.debug then
|
||||
print(string.format("[%s] Roster update complete - Added %d new agents", ModuleName, newAgents))
|
||||
end
|
||||
@@ -57,36 +58,37 @@ function shared.AgentTracker.Init()
|
||||
local agentTrackerChannelSniffer = CreateFrame("Frame")
|
||||
agentTrackerChannelSniffer:RegisterEvent("CHAT_MSG_CHANNEL")
|
||||
agentTrackerChannelSniffer:SetScript("OnEvent", function(self, event, msg, sender, ...)
|
||||
-- if Heimdall_Data.config.agentTracker.debug then
|
||||
-- print(string.format("[%s] Channel message received from: %s", ModuleName, sender))
|
||||
-- end
|
||||
if not Heimdall_Data.config.agentTracker.enabled then
|
||||
-- if Heimdall_Data.config.agentTracker.debug then
|
||||
-- print(string.format("[%s] Module disabled, ignoring channel message", ModuleName))
|
||||
-- end
|
||||
return
|
||||
-- if Heimdall_Data.config.agentTracker.debug then
|
||||
-- print(string.format("[%s] Channel message received from: %s", ModuleName, sender))
|
||||
-- end
|
||||
if not Heimdall_Data.config.agentTracker.enabled then
|
||||
-- if Heimdall_Data.config.agentTracker.debug then
|
||||
-- print(string.format("[%s] Module disabled, ignoring channel message", ModuleName))
|
||||
-- end
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
local channelId = select(6, ...)
|
||||
local _, channelname = GetChannelName(channelId)
|
||||
if channelname ~= Heimdall_Data.config.agentTracker.masterChannel then
|
||||
-- if Heimdall_Data.config.agentTracker.debug then
|
||||
-- print(string.format("[%s] Ignoring message from non-master channel: %s", ModuleName, channelname))
|
||||
-- end
|
||||
return
|
||||
if channelname ~= Heimdall_Data.config.agentTracker.masterChannel then
|
||||
-- if Heimdall_Data.config.agentTracker.debug then
|
||||
-- print(string.format("[%s] Ignoring message from non-master channel: %s", ModuleName, channelname))
|
||||
-- end
|
||||
return
|
||||
end
|
||||
if Heimdall_Data.config.agentTracker.debug then
|
||||
print(string.format("[%s] Processing message from master channel: %s", ModuleName, sender))
|
||||
shared.dumpTable(Heimdall_Data.config.agentTracker)
|
||||
end
|
||||
|
||||
|
||||
|
||||
sender = string.match(sender, "^[^-]+")
|
||||
local isNewAgent = not Heimdall_Data.config.agents[sender]
|
||||
Heimdall_Data.config.agents[sender] = date("%Y-%m-%dT%H:%M:%S")
|
||||
|
||||
|
||||
if Heimdall_Data.config.agentTracker.debug then
|
||||
print(string.format("[%s] %s agent from message: %s", ModuleName, isNewAgent and "Added new" or "Updated existing", sender))
|
||||
print(string.format("[%s] %s agent from message: %s", ModuleName,
|
||||
isNewAgent and "Added new" or "Updated existing", sender))
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user