38 Commits

Author SHA1 Message Date
7eee3a13a6 Add Russian localization who (kto) for our russian friends 2025-05-25 11:09:43 +02:00
263cf8e2e4 Add chatSniffer localization and configuration UI 2025-05-25 10:58:08 +02:00
ccbf0f8dc2 Add chatSniffer configuration and integrate into Heimdall initialization 2025-05-25 10:54:01 +02:00
63027c2dcf Update module initialization messages to use consistent format 2025-05-25 10:51:41 +02:00
d46c874604 Add timestamp logging to ChatSniffer events 2025-05-25 10:48:11 +02:00
fd4f707b6c Add ChatSniffer module and update saved variables 2025-05-25 10:47:58 +02:00
1168876dcc Fix FriendsFrame_OnEvent to pass additional parameters so it actually works naturally 2025-05-25 10:45:17 +02:00
bdf5afe436 Comment out debug print statements in Messenger module and fix queue loading 2025-05-25 10:41:02 +02:00
85ff907f05 Reset whoQueryIdx to 1 when no WHO query is found 2025-05-25 10:39:45 +02:00
7ae9db030b Remove redundant event registration for ADDON_LOADED in Heimdall.lua 2025-05-25 10:34:48 +02:00
edf8a12865 Refactor message queuing to use NetworkMessenger and Messenger based on configuration 2025-05-21 01:42:41 +02:00
d081eedd47 Fix debug print statement to include message count 2025-05-20 20:45:42 +02:00
8532db5a25 Rename dumpTable to dump and make it work with any values 2025-05-20 20:40:25 +02:00
26e783ee2e Update subproject commit reference in Meta 2025-05-20 20:20:59 +02:00
4bd237abef Hook friends list show to NOT show while we're waiting for who results 2025-05-20 20:19:41 +02:00
0ab14de0e2 CCP 2025-05-20 20:04:41 +02:00
a25b6a20d5 Release 3.12.0 2025-05-20 20:02:47 +02:00
e85c14ea45 Update StinkyTracker to use ReactiveValue for accessing ignored and stinkies lists 2025-05-18 16:05:12 +02:00
a564178ca2 Fix dumpTable function to ensure keys and values are converted to strings before printing 2025-05-18 16:05:03 +02:00
b4a4011b18 Refactor NetworkMessenger initialization to use ReactiveValue for queue management 2025-05-18 16:00:39 +02:00
3f3d252104 Update subproject commit reference in Meta 2025-05-18 15:54:48 +02:00
287be2a31c Move data definitions into their separate modules 2025-05-18 15:54:38 +02:00
3ef0e4c935 Refactor Heimdall messenger module to improve structure and utilize ReactiveValue for queue management 2025-05-18 15:54:11 +02:00
ce92e8e12c Refactor Commander and StinkyTracker modules for improved clarity and consistency in type annotations 2025-05-18 12:48:26 +02:00
03597d1b5e Update subproject commit reference in Meta 2025-05-18 12:45:11 +02:00
36ad9783e5 Move all config definitions to their respective modules 2025-05-18 12:43:55 +02:00
565db30125 Refactor multiple Heimdall modules to use class-based structure for improved organization and clarity 2025-05-18 12:31:26 +02:00
017cbf01f8 Refactor Heimdall modules to use class-based structure for improved organization and clarity 2025-05-18 12:28:25 +02:00
b16cf762ac Refactor Heimdall modules to improve structure and clarity, including AchievementSniffer, BonkDetector, Bully, Commander, and Config. 2025-05-18 12:27:00 +02:00
0057ac3a5c Refactor CombatAlerter, Commander, Inviter, Macroer, Sniffer modules for improved structure and clarity 2025-05-18 12:12:57 +02:00
0edf0561d8 Refactor DeathReporter, CombatAlerter, Commander, Configurator, and AgentTracker modules 2025-05-18 11:48:50 +02:00
1129d787b5 Refactor BonkDetector and Bully modules for improved structure and clarity 2025-05-18 11:43:40 +02:00
8a24496801 Add scratch.lua to .gitignore 2025-05-18 11:37:05 +02:00
6cb918c13c Refactor Heimdall module fields for improved organization and clarity 2025-05-18 11:36:40 +02:00
e3eefadb75 Refactor AgentTracker and related modules to improve agent management and logging 2025-05-18 11:16:13 +02:00
eab562b36d Enhance dumpTable function to include optional message parameter for improved logging 2025-05-18 11:15:52 +02:00
20a7c0eead Refactor StinkyTracker to improve tracking and ignore functionality 2025-05-18 10:51:33 +02:00
f70c5adfcf Add debug logging for stinky changes and simplify stinky handling 2025-05-18 10:31:36 +02:00
33 changed files with 6582 additions and 6126 deletions

1
.gitignore vendored
View File

@@ -0,0 +1 @@
scratch.lua

View File

@@ -1,5 +1,5 @@
globals = { "CykaPersistentData", "CreateFrame", "GetItemInfo", "aura_env" } globals = { "CykaPersistentData", "CreateFrame", "GetItemInfo", "aura_env" }
unused_args = false unused_args = false
max_line_length = 150 max_line_length = 500
exclude_files = { "Meta/" } exclude_files = { "Meta/" }
global = false global = false

View File

@@ -2,7 +2,7 @@ local addonname, shared = ...
---@cast shared HeimdallShared ---@cast shared HeimdallShared
---@cast addonname string ---@cast addonname string
local VERSION = "3.11.0" local VERSION = "3.12.0"
shared.VERSION = VERSION shared.VERSION = VERSION
local function init() local function init()
@@ -18,7 +18,8 @@ local function init()
---@field classColors table<string, string> ---@field classColors table<string, string>
---@field messenger HeimdallMessengerData ---@field messenger HeimdallMessengerData
---@field who HeimdallWhoData ---@field who HeimdallWhoData
---@field stinkyTracker HeimdallStinkyTrackerData ---@field stinkyTracker StinkyTrackerData
---@field agentTracker AgentTrackerData
---@field networkNodes string[] ---@field networkNodes string[]
---@field network HeimdallNetworkData ---@field network HeimdallNetworkData
---@field networkMessenger HeimdallNetworkMessengerData ---@field networkMessenger HeimdallNetworkMessengerData
@@ -26,7 +27,7 @@ local function init()
---@field _L fun(key: string, locale: string): string ---@field _L fun(key: string, locale: string): string
---@field _Locale Localization ---@field _Locale Localization
---@field VERSION string ---@field VERSION string
---@field dumpTable fun(table: any, depth?: number): nil ---@field dump fun(table: any, msg?: string, depth?: number): nil
---@field utf8len fun(input: string): number ---@field utf8len fun(input: string): number
---@field padString fun(input: string, targetLength: number, left?: boolean): string ---@field padString fun(input: string, targetLength: number, left?: boolean): string
---@field GetOrDefault fun(table: table<any, any>, keys: string[], default: any): any ---@field GetOrDefault fun(table: table<any, any>, keys: string[], default: any): any
@@ -35,30 +36,31 @@ local function init()
---@field Memoize fun(f: function): function ---@field Memoize fun(f: function): function
---@field GetLocaleForChannel fun(channel: string): string ---@field GetLocaleForChannel fun(channel: string): string
---@field WhoQueryService WhoQueryService ---@field WhoQueryService WhoQueryService
---@field Whoer InitTable|{ShouldNotifyForZone: fun(zone: string): boolean} ---@field AchievementSniffer AchievementSniffer
---@field Messenger InitTable ---@field AgentTracker AgentTracker
---@field Spotter InitTable ---@field BonkDetector BonkDetector
---@field DeathReporter InitTable ---@field Bully Bully
---@field Inviter InitTable ---@field CombatAlerter CombatAlerter
---@field Dueler InitTable ---@field Commander Commander
---@field Bully InitTable ---@field Config Config
---@field AgentTracker InitTable ---@field Configurator Configurator
---@field Emoter InitTable ---@field DeathReporter DeathReporter
---@field Echoer InitTable ---@field Dueler Dueler
---@field Macroer InitTable ---@field Echoer Echoer
---@field Commander InitTable ---@field Emoter Emoter
---@field StinkyTracker InitTable ---@field Inviter Inviter
---@field CombatAlerter InitTable ---@field Macroer Macroer
---@field Config InitTable ---@field Messenger Messenger
---@field Sniffer InitTable ---@field MinimapTagger MinimapTagger
---@field MinimapTagger InitTable ---@field Network Network
---@field BonkDetector InitTable ---@field NetworkMessenger NetworkMessenger
---@field Noter InitTable ---@field Noter Noter
---@field Network InitTable ---@field Sniffer Sniffer
---@field NetworkMessenger InitTable ---@field Spotter Spotter
---@field StinkyCache InitTable ---@field StinkyCache StinkyCache
---@field Configurator InitTable ---@field StinkyTracker StinkyTracker
---@field AchievementSniffer InitTable ---@field Whoer Whoer
---@field ChatSniffer ChatSniffer
--- Config --- --- Config ---
---@class HeimdallConfig ---@class HeimdallConfig
@@ -68,7 +70,6 @@ local function init()
---@field deathReporter HeimdallDeathReporterConfig ---@field deathReporter HeimdallDeathReporterConfig
---@field inviter HeimdallInviterConfig ---@field inviter HeimdallInviterConfig
---@field dueler HeimdallDuelerConfig ---@field dueler HeimdallDuelerConfig
---@field bully HeimdallBullyConfig
---@field agentTracker HeimdallAgentTrackerConfig ---@field agentTracker HeimdallAgentTrackerConfig
---@field emoter HeimdallEmoterConfig ---@field emoter HeimdallEmoterConfig
---@field echoer HeimdallEchoerConfig ---@field echoer HeimdallEchoerConfig
@@ -77,13 +78,13 @@ local function init()
---@field stinkyTracker HeimdallStinkyTrackerConfig ---@field stinkyTracker HeimdallStinkyTrackerConfig
---@field combatAlerter HeimdallCombatAlerterConfig ---@field combatAlerter HeimdallCombatAlerterConfig
---@field sniffer HeimdallSnifferConfig ---@field sniffer HeimdallSnifferConfig
---@field bonkDetector HeimdallBonkDetectorConfig
---@field noter HeimdallNoterConfig ---@field noter HeimdallNoterConfig
---@field network HeimdallNetworkConfig ---@field network HeimdallNetworkConfig
---@field networkMessenger HeimdallNetworkMessengerConfig ---@field networkMessenger HeimdallNetworkMessengerConfig
---@field configurator HeimdallConfiguratorConfig ---@field configurator HeimdallConfiguratorConfig
---@field stinkyCache HeimdallStinkyCacheConfig ---@field stinkyCache HeimdallStinkyCacheConfig
---@field achievementSniffer HeimdallAchievementSnifferConfig ---@field achievementSniffer HeimdallAchievementSnifferConfig
---@field chatSniffer HeimdallChatSnifferConfig
---@field whisperNotify table<string, string> ---@field whisperNotify table<string, string>
---@field addonPrefix string ---@field addonPrefix string
---@field stinkies table<string, boolean> ---@field stinkies table<string, boolean>
@@ -94,203 +95,6 @@ local function init()
---@field locale string ---@field locale string
---@field debug boolean ---@field debug boolean
---@class HeimdallSpotterConfig
---@field enabled boolean
---@field debug boolean
---@field everyone boolean
---@field hostile boolean
---@field alliance boolean
---@field stinky boolean
---@field channels string[]
---@field zoneOverride string?
---@field throttleTime number
---@class HeimdallWhoConfig
---@field enabled boolean
---@field debug boolean
---@field ignored table<string, boolean>
---@field channels string[]
---@field ttl number
---@field doWhisper boolean
---@field zoneNotifyFor table<string, boolean>
---@field queries string
---@class HeimdallMessengerConfig
---@field enabled boolean
---@field debug boolean
---@field interval number
---@class HeimdallDeathReporterConfig
---@field enabled boolean
---@field debug boolean
---@field throttle number
---@field doWhisper boolean
---@field channels string[]
---@field zoneOverride string?
---@field duelThrottle number
---@class HeimdallInviterConfig
---@field enabled boolean
---@field debug boolean
---@field channels string[]
---@field keyword string
---@field allAssist boolean
---@field agentsAssist boolean
---@field throttle number
---@field kickOffline boolean
---@field cleanupInterval number
---@field afkThreshold number
---@field listeningChannel table<string, boolean>
---@class HeimdallDuelerConfig
---@field enabled boolean
---@field debug boolean
---@field declineOther boolean
---@class HeimdallBullyConfig
---@field enabled boolean
---@field debug boolean
---@class HeimdallAgentTrackerConfig
---@field enabled boolean
---@field debug boolean
---@field channels string[]
---@class HeimdallEmoterConfig
---@field enabled boolean
---@field debug boolean
---@field channels string[]
---@field prefix string
---@class HeimdallEchoerConfig
---@field enabled boolean
---@field debug boolean
---@field channels string[]
---@field prefix string
---@class HeimdallMacroerConfig
---@field enabled boolean
---@field debug boolean
---@field priority string[]
---@class HeimdallCommanderConfig
---@field enabled boolean
---@field debug boolean
---@field channels string[]
---@field commander string
---@field commands table<string, boolean>
---@class HeimdallStinkyTrackerConfig
---@field enabled boolean
---@field debug boolean
---@field channels string[]
---@class HeimdallCombatAlerterConfig
---@field enabled boolean
---@field debug boolean
---@field channels string[]
---@class HeimdallSnifferConfig
---@field enabled boolean
---@field debug boolean
---@field channels string[]
---@field throttle number
---@field zoneOverride string?
---@field stinky boolean
---@class HeimdallMinimapTaggerConfig
---@field enabled boolean
---@field debug boolean
---@field channels string[]
---@field throttle number
---@field scale number
---@field tagTTL number
---@field tagSound boolean
---@field tagSoundFile string
---@field tagSoundThrottle number
---@field tagTextureFile string
---@field alertTTL number
---@field alertSound boolean
---@field alertSoundFile string
---@field alertSoundThrottle number
---@field alertTextureFile string
---@field combatTTL number
---@field combatSound boolean
---@field combatSoundFile string
---@field combatSoundThrottle number
---@field combatTextureFile string
---@field helpTTL number
---@field helpSound boolean
---@field helpSoundFile string
---@field helpSoundThrottle number
---@field helpTextureFile string
---@class HeimdallBonkDetectorConfig
---@field enabled boolean
---@field debug boolean
---@field channels string[]
---@field throttle number
---@class HeimdallNoterConfig
---@field enabled boolean
---@field debug boolean
---@field channels string[]
---@field lastNotes number
---@class HeimdallNetworkConfig
---@field enabled boolean
---@field debug boolean
---@field members string[]
---@field updateInterval number
---@class HeimdallNetworkMessengerConfig
---@field enabled boolean
---@field debug boolean
---@field interval number
---@class HeimdallConfiguratorConfig
---@field enabled boolean
---@field debug boolean
---@class HeimdallStinkyCacheConfig
---@field enabled boolean
---@field debug boolean
---@field commander string
---@field ttl number
---@class HeimdallAchievementSnifferConfig
---@field enabled boolean
---@field debug boolean
-----@field texture string
-----@field offsetX number
-----@field offsetY number
---@field rescan boolean
---@field scanInterval number
-----@field iconScale number
--- Data ---
---@class HeimdallMessengerData
---@field queue table<string, Message>
---@field ticker Timer?
---@class HeimdallNetworkMessengerData
---@field queue table<string, Message>
---@field ticker Timer?
---@class HeimdallWhoData
---@field updateTicker number?
---@field whoTicker number?
---@field ignored table<string, boolean>
---@class HeimdallStinkyTrackerData
---@field stinkies ReactiveValue
---@class HeimdallNetworkData
---@field ticker number?
---@class HeimdallStinkyCacheData
---@field stinkies table<string, {value: number, timestamp: number}>
shared.GetOrDefault = function(table, keys, default) shared.GetOrDefault = function(table, keys, default)
local value = default local value = default
if not table then return value end if not table then return value end
@@ -310,16 +114,13 @@ local function init()
return value return value
end end
shared.messenger = {
queue = {},
}
shared.who = {
ignored = {},
}
--/run Heimdall_Data.config.who.queries="g-\"БеспредеЛ\"|ally" --/run Heimdall_Data.config.who.queries="g-\"БеспредеЛ\"|ally"
Heimdall_Data.config = { Heimdall_Data.config = {
debug = shared.GetOrDefault(Heimdall_Data, { "config", "debug" }, false), debug = shared.GetOrDefault(Heimdall_Data, { "config", "debug" }, false),
chatSniffer = {
enabled = shared.GetOrDefault(Heimdall_Data, { "config", "chatSniffer", "enabled" }, false),
debug = shared.GetOrDefault(Heimdall_Data, { "config", "chatSniffer", "debug" }, false),
},
spotter = { spotter = {
enabled = shared.GetOrDefault(Heimdall_Data, { "config", "spotter", "enabled" }, true), enabled = shared.GetOrDefault(Heimdall_Data, { "config", "spotter", "enabled" }, true),
debug = shared.GetOrDefault(Heimdall_Data, { "config", "spotter", "debug" }, false), debug = shared.GetOrDefault(Heimdall_Data, { "config", "spotter", "debug" }, false),
@@ -418,6 +219,7 @@ local function init()
enabled = shared.GetOrDefault(Heimdall_Data, { "config", "stinkyTracker", "enabled" }, false), enabled = shared.GetOrDefault(Heimdall_Data, { "config", "stinkyTracker", "enabled" }, false),
debug = shared.GetOrDefault(Heimdall_Data, { "config", "stinkyTracker", "debug" }, false), debug = shared.GetOrDefault(Heimdall_Data, { "config", "stinkyTracker", "debug" }, false),
channels = shared.GetOrDefault(Heimdall_Data, { "config", "stinkyTracker", "channels" }, { "Agent" }), channels = shared.GetOrDefault(Heimdall_Data, { "config", "stinkyTracker", "channels" }, { "Agent" }),
ignoredTimeout = shared.GetOrDefault(Heimdall_Data, { "config", "stinkyTracker", "ignoredTimeout" }, 600),
}, },
combatAlerter = { combatAlerter = {
enabled = shared.GetOrDefault(Heimdall_Data, { "config", "combatAlerter", "enabled" }, false), enabled = shared.GetOrDefault(Heimdall_Data, { "config", "combatAlerter", "enabled" }, false),
@@ -670,7 +472,7 @@ local function init()
shared.Memoize = function(f) shared.Memoize = function(f)
local mem = {} -- memoizing table local mem = {} -- memoizing table
setmetatable(mem, { __mode = "kv" }) -- make it weak setmetatable(mem, { __mode = "kv" }) -- make it weak
return function(x) -- new version of f, with memoizing return function(x) -- new version of 'f', with memoizing
if Heimdall_Data.config.debug then print(string.format("[Heimdall] Memoize %s", tostring(x))) end if Heimdall_Data.config.debug then print(string.format("[Heimdall] Memoize %s", tostring(x))) end
local r = mem[x] local r = mem[x]
if r == nil then -- no previous result? if r == nil then -- no previous result?
@@ -737,6 +539,7 @@ local function init()
shared.Configurator.Init() shared.Configurator.Init()
shared.StinkyCache.Init() shared.StinkyCache.Init()
shared.AchievementSniffer.Init() shared.AchievementSniffer.Init()
shared.ChatSniffer.Init()
print("Heimdall loaded!") print("Heimdall loaded!")
end end
@@ -745,3 +548,69 @@ loadedFrame:RegisterEvent("ADDON_LOADED")
loadedFrame:SetScript("OnEvent", function(self, event, addonName) loadedFrame:SetScript("OnEvent", function(self, event, addonName)
if addonName == addonname then init() end if addonName == addonname then init() end
end) end)
-- Create the import/export frame
local ccpFrame = CreateFrame("Frame", "CCPFrame", UIParent)
ccpFrame:SetSize(512 * 1.5, 512 * 1.5)
ccpFrame:SetPoint("CENTER")
ccpFrame:SetFrameStrata("HIGH")
ccpFrame:EnableMouse(true)
ccpFrame:SetMovable(true)
ccpFrame:SetResizable(false)
ccpFrame:SetBackdrop({
bgFile = "Interface/Tooltips/UI-Tooltip-Background",
edgeFile = "Interface/Tooltips/UI-Tooltip-Border",
tile = true,
tileSize = 4,
edgeSize = 4,
insets = {
left = 4,
right = 4,
top = 4,
bottom = 4,
},
})
ccpFrame:SetBackdropColor(0, 0, 0, 0.8)
ccpFrame:SetBackdropBorderColor(0.5, 0.5, 0.5, 1)
ccpFrame:SetMovable(true)
ccpFrame:EnableMouse(true)
ccpFrame:RegisterForDrag("LeftButton")
ccpFrame:SetScript("OnDragStart", function(self) self:StartMoving() end)
ccpFrame:SetScript("OnDragStop", function(self) self:StopMovingOrSizing() end)
ccpFrame:SetScript("OnShow", function(self) self:SetScale(1) end)
ccpFrame:Hide()
-- Create scroll frame
local scrollFrame = CreateFrame("ScrollFrame", "CCPFrameScrollFrame", ccpFrame, "UIPanelScrollFrameTemplate")
scrollFrame:SetPoint("TOPLEFT", ccpFrame, "TOPLEFT", 10, -10)
scrollFrame:SetPoint("BOTTOMRIGHT", ccpFrame, "BOTTOMRIGHT", -30, 10)
-- Create the text box
local ccpFrameTextBox = CreateFrame("EditBox", "CCPFrameTextBox", scrollFrame)
ccpFrameTextBox:SetSize(512 * 1.5 - 40, 512 * 1.5 - 20)
ccpFrameTextBox:SetPoint("TOPLEFT", scrollFrame, "TOPLEFT", 0, 0)
ccpFrameTextBox:SetFont("Fonts\\FRIZQT__.ttf", 12)
ccpFrameTextBox:SetTextColor(1, 1, 1, 1)
ccpFrameTextBox:SetTextInsets(10, 10, 10, 10)
ccpFrameTextBox:SetMultiLine(true)
ccpFrameTextBox:SetAutoFocus(true)
ccpFrameTextBox:SetMaxLetters(1000000)
ccpFrameTextBox:SetScript("OnEscapePressed", function(self) ccpFrame:Hide() end)
-- Set the scroll frame's scroll child
scrollFrame:SetScrollChild(ccpFrameTextBox)
CCP = function(window)
window = window or 1
local charFrame = _G["ChatFrame" .. window]
local maxLines = charFrame:GetNumMessages() or 0
local chat = {}
for i = 1, maxLines do
local currentMsg = charFrame:GetMessageInfo(i)
chat[#chat + 1] = currentMsg
end
ccpFrameTextBox:SetText(table.concat(chat, "\n"))
ccpFrame:Show()
ccpFrameTextBox:SetFocus()
end

View File

@@ -1,9 +1,9 @@
## Interface: 70300 ## Interface: 70300
## Title: Heimdall ## Title: Heimdall
## Version: 3.11.0 ## Version: 3.12.0
## Notes: Watches over areas and alerts when hostiles spotted ## Notes: Watches over areas and alerts when hostiles spotted
## Author: Cyka ## Author: Cyka
## SavedVariables: Heimdall_Data, Heimdall_Achievements ## SavedVariables: Heimdall_Data, Heimdall_Achievements, Heimdall_Chat
_L.lua _L.lua
Modules/CLEUParser.lua Modules/CLEUParser.lua
@@ -33,4 +33,5 @@ Modules/NetworkMessenger.lua
Modules/StinkyCache.lua Modules/StinkyCache.lua
Modules/Configurator.lua Modules/Configurator.lua
Modules/AchievementSniffer.lua Modules/AchievementSniffer.lua
Modules/ChatSniffer.lua
Heimdall.lua Heimdall.lua

2
Meta

Submodule Meta updated: e045572f60...eee043a846

View File

@@ -2,6 +2,16 @@ local _, shared = ...
---@cast shared HeimdallShared ---@cast shared HeimdallShared
local ModuleName = "AchievementSniffer" local ModuleName = "AchievementSniffer"
---@class HeimdallAchievementSnifferConfig
---@field enabled boolean
---@field debug boolean
-----@field texture string
-----@field offsetX number
-----@field offsetY number
---@field rescan boolean
---@field scanInterval number
-----@field iconScale number
-- local HeimdallRoot = "Interface\\AddOns\\Heimdall\\" -- local HeimdallRoot = "Interface\\AddOns\\Heimdall\\"
-- local TextureRoot = HeimdallRoot .. "Texture\\" -- local TextureRoot = HeimdallRoot .. "Texture\\"
@@ -74,9 +84,9 @@ local Achievements = {
12448, 12448,
} }
---@diagnostic disable-next-line: missing-fields ---@class AchievementSniffer
shared.AchievementSniffer = {} shared.AchievementSniffer = {
function shared.AchievementSniffer.Init() Init = function()
if Heimdall_Data.config.achievementSniffer.debug then if Heimdall_Data.config.achievementSniffer.debug then
print(string.format("[%s] Module initialized", ModuleName)) print(string.format("[%s] Module initialized", ModuleName))
end end
@@ -289,5 +299,6 @@ function shared.AchievementSniffer.Init()
end end
Tick() Tick()
print("[Heimdall] AchievementSniffer loaded") print(string.format("[%s] Module initialized", ModuleName))
end end,
}

View File

@@ -2,9 +2,52 @@ local _, shared = ...
---@cast shared HeimdallShared ---@cast shared HeimdallShared
local ModuleName = "AgentTracker" local ModuleName = "AgentTracker"
---@diagnostic disable-next-line: missing-fields ---@class AgentTrackerData
shared.AgentTracker = {} ---@field agents ReactiveValue<table<string, string>>
function shared.AgentTracker.Init()
---@class HeimdallAgentTrackerConfig
---@field enabled boolean
---@field debug boolean
---@field channels string[]
---@class AgentTracker
shared.AgentTracker = {
---@param name string
---@return boolean
Track = function(name)
if not name then return false end
local exists = shared.AgentTracker.IsAgent(name)
if exists then return false end
shared.agentTracker.agents[name] = date("%Y-%m-%dT%H:%M:%S")
-- Heimdall_Data.config.agents[name] = date("%Y-%m-%dT%H:%M:%S")
if Heimdall_Data.config.agentTracker.debug then
print(string.format("[%s] Tracking new agent: %s", ModuleName, name))
shared.dump(shared.agentTracker.agents)
end
return true
end,
---@param name string
---@return boolean
IsAgent = function(name)
if not name then return false end
return shared.agentTracker.agents[name] ~= nil
end,
---@param callback fun(agent: string)
OnChange = function(callback) shared.agentTracker.agents:onChange(callback) end,
---@param callback fun(agent: string)
ForEach = function(callback)
---@type table<string, string>
local agents = shared.agentTracker.agents:get()
for name, _ in pairs(agents) do
callback(name)
end
end,
---@return nil
Init = function()
shared.agentTracker = {
agents = ReactiveValue.new(Heimdall_Data.config.agents),
}
--/run Heimdall_Data.config.agents["Cyheuraeth"]=date("%Y-%m-%dT%H:%M:%S") --/run Heimdall_Data.config.agents["Cyheuraeth"]=date("%Y-%m-%dT%H:%M:%S")
---@type table<string, boolean> ---@type table<string, boolean>
local channelRosterFrame = CreateFrame("Frame") local channelRosterFrame = CreateFrame("Frame")
@@ -37,21 +80,7 @@ function shared.AgentTracker.Init()
local newAgents = 0 local newAgents = 0
for i = 1, count do for i = 1, count do
name = GetChannelRosterInfo(index, i) name = GetChannelRosterInfo(index, i)
if name then shared.AgentTracker.Track(name)
local isNewAgent = not Heimdall_Data.config.agents[name]
Heimdall_Data.config.agents[name] = date("%Y-%m-%dT%H:%M:%S")
if isNewAgent then 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
)
)
end
end
end end
if Heimdall_Data.config.agentTracker.debug then if Heimdall_Data.config.agentTracker.debug then
@@ -89,19 +118,17 @@ function shared.AgentTracker.Init()
end end
if Heimdall_Data.config.agentTracker.debug then if Heimdall_Data.config.agentTracker.debug then
print(string.format("[%s] Processing message from master channel: %s", ModuleName, sender)) print(string.format("[%s] Processing message from master channel: %s", ModuleName, sender))
shared.dumpTable(Heimdall_Data.config.agentTracker)
end end
sender = string.match(sender, "^[^-]+") sender = string.match(sender, "^[^-]+")
local isNewAgent = not Heimdall_Data.config.agents[sender] local new = shared.AgentTracker.Track(sender)
Heimdall_Data.config.agents[sender] = date("%Y-%m-%dT%H:%M:%S")
if Heimdall_Data.config.agentTracker.debug then if Heimdall_Data.config.agentTracker.debug then
print( print(
string.format( string.format(
"[%s] %s agent from message: %s", "[%s] %s agent from message: %s",
ModuleName, ModuleName,
isNewAgent and "Added new" or "Updated existing", new and "Added new" or "Updated existing",
sender sender
) )
) )
@@ -109,11 +136,9 @@ function shared.AgentTracker.Init()
end) end)
if Heimdall_Data.config.agentTracker.debug then if Heimdall_Data.config.agentTracker.debug then
local count = 0 print(string.format("[%s] Module initialized", ModuleName))
for _ in pairs(Heimdall_Data.config.agents) do shared.dump(shared.agentTracker.agents:get(), "Agents")
count = count + 1
end end
print(string.format("[%s] Module initialized - Tracking %d agents", ModuleName, count)) print(string.format("[%s] Module initialized", ModuleName))
end end,
print("[Heimdall] AgentTracker loaded") }
end

View File

@@ -2,9 +2,16 @@ local _, shared = ...
---@cast shared HeimdallShared ---@cast shared HeimdallShared
local ModuleName = "BonkDetector" local ModuleName = "BonkDetector"
---@diagnostic disable-next-line: missing-fields ---@class HeimdallBonkDetectorConfig
shared.BonkDetector = {} ---@field enabled boolean
function shared.BonkDetector.Init() ---@field debug boolean
---@field channels string[]
---@field throttle number
---@class BonkDetector
shared.BonkDetector = {
---@return nil
Init = function()
---@type table<string, number> ---@type table<string, number>
local lastReportTime = {} local lastReportTime = {}
@@ -124,11 +131,12 @@ function shared.BonkDetector.Init()
} }
if Heimdall_Data.config.bonkDetector.debug then if Heimdall_Data.config.bonkDetector.debug then
print(string.format("[%s] Queuing bonk detector message", ModuleName)) print(string.format("[%s] Queuing bonk detector message", ModuleName))
shared.dumpTable(message) shared.dump(message)
end end
table.insert(shared.messenger.queue, message) table.insert(shared.messenger.queue, message)
end end
end) end)
print("[Heimdall] BonkDetector loaded") print(string.format("[%s] Module initialized", ModuleName))
end end,
}

View File

@@ -2,9 +2,15 @@ local _, shared = ...
---@cast shared HeimdallShared ---@cast shared HeimdallShared
local ModuleName = "Bully" local ModuleName = "Bully"
---@diagnostic disable-next-line: missing-fields ---@class HeimdallBullyConfig
shared.Bully = {} ---@field enabled boolean
function shared.Bully.Init() ---@field debug boolean
---@class Bully
shared.Bully = {
---@return nil
Init = function()
if Heimdall_Data.config.bully.debug then print(string.format("[%s] Module initialized", ModuleName)) end if Heimdall_Data.config.bully.debug then print(string.format("[%s] Module initialized", ModuleName)) end
print("[Heimdall] Bully loaded") print(string.format("[%s] Module initialized", ModuleName))
end end,
}

49
Modules/ChatSniffer.lua Normal file
View File

@@ -0,0 +1,49 @@
local _, shared = ...
---@cast shared HeimdallShared
local ModuleName = "ChatSniffer"
---@class HeimdallChatSnifferConfig
---@field enabled boolean
---@field debug boolean
---@class ChatSniffer
shared.ChatSniffer = {
Init = function()
Heimdall_Chat = Heimdall_Chat or {}
local frame = CreateFrame("Frame")
frame:RegisterEvent("CHAT_MSG_SAY")
frame:RegisterEvent("CHAT_MSG_YELL")
frame:RegisterEvent("CHAT_MSG_CHANNEL")
frame:RegisterEvent("CHAT_MSG_WHISPER")
frame:RegisterEvent("CHAT_MSG_CHANNEL_JOIN")
frame:RegisterEvent("CHAT_MSG_CHANNEL_LEAVE")
frame:RegisterEvent("CHAT_MSG_EMOTE")
frame:RegisterEvent("CHAT_MSG_PARTY")
frame:RegisterEvent("CHAT_MSG_PARTY_LEADER")
frame:RegisterEvent("CHAT_MSG_RAID")
frame:RegisterEvent("CHAT_MSG_RAID_LEADER")
frame:RegisterEvent("CHAT_MSG_RAID_WARNING")
frame:RegisterEvent("CHAT_MSG_SYSTEM")
frame:RegisterEvent("CHAT_MSG_TEXT_EMOTE")
frame:RegisterEvent("CHAT_MSG_YELL")
frame:SetScript("OnEvent", function(self, event, msg, sender, language, channel)
if not Heimdall_Data.config.chatSniffer.enabled then return end
if not Heimdall_Data.config.chatSniffer.debug then
shared.dump(string.format("[%s] got message", { event, msg, sender, language, channel }))
end
local timestamp = date("%Y-%m-%d %H:%M:%S")
local log = string.format(
"%s|%s|%s|%s|%s|%s",
tostring(timestamp),
tostring(event),
tostring(sender),
tostring(msg),
tostring(language),
tostring(channel)
)
Heimdall_Chat[#Heimdall_Chat + 1] = log
end)
print(string.format("[%s] Module initialized", ModuleName))
end,
}

View File

@@ -2,9 +2,14 @@ local _, shared = ...
---@cast shared HeimdallShared ---@cast shared HeimdallShared
local ModuleName = "CombatAlerter" local ModuleName = "CombatAlerter"
---@diagnostic disable-next-line: missing-fields ---@class HeimdallCombatAlerterConfig
shared.CombatAlerter = {} ---@field enabled boolean
function shared.CombatAlerter.Init() ---@field debug boolean
---@field channels string[]
---@class CombatAlerter
shared.CombatAlerter = {
Init = function()
local alerted = {} local alerted = {}
local combatAlerterFrame = CreateFrame("Frame") local combatAlerterFrame = CreateFrame("Frame")
combatAlerterFrame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED") combatAlerterFrame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
@@ -53,7 +58,7 @@ function shared.CombatAlerter.Init()
print(string.format("[%s] Combat event source: %s", ModuleName, source)) print(string.format("[%s] Combat event source: %s", ModuleName, source))
end end
if shared.stinkyTracker.stinkies and shared.stinkyTracker.stinkies[source] then if shared.StinkyTracker.IsStinky(source) then
if Heimdall_Data.config.combatAlerter.debug then if Heimdall_Data.config.combatAlerter.debug then
print( print(
string.format( string.format(
@@ -106,7 +111,7 @@ function shared.CombatAlerter.Init()
} }
if Heimdall_Data.config.combatAlerter.debug then if Heimdall_Data.config.combatAlerter.debug then
print(string.format("[%s] Queuing alert message", ModuleName)) print(string.format("[%s] Queuing alert message", ModuleName))
shared.dumpTable(msg) shared.dump(msg)
end end
table.insert(shared.messenger.queue, msg) table.insert(shared.messenger.queue, msg)
end end
@@ -131,5 +136,6 @@ function shared.CombatAlerter.Init()
end) end)
if Heimdall_Data.config.combatAlerter.debug then print(string.format("[%s] Module initialized", ModuleName)) end if Heimdall_Data.config.combatAlerter.debug then print(string.format("[%s] Module initialized", ModuleName)) end
print("[Heimdall] CombatAlerter loaded") print(string.format("[%s] Module initialized", ModuleName))
end end,
}

View File

@@ -2,6 +2,13 @@ local _, shared = ...
---@cast shared HeimdallShared ---@cast shared HeimdallShared
local ModuleName = "Commander" local ModuleName = "Commander"
---@class HeimdallCommanderConfig
---@field enabled boolean
---@field debug boolean
---@field channels string[]
---@field commander string
---@field commands table<string, boolean>
local helpMessages = { local helpMessages = {
ru = { ru = {
"1) who - пишет вам никнеймы текущих врагов и локу.", "1) who - пишет вам никнеймы текущих врагов и локу.",
@@ -31,9 +38,9 @@ local helpMessages = {
}, },
} }
---@diagnostic disable-next-line: missing-fields ---@class Commander
shared.Commander = {} shared.Commander = {
function shared.Commander.Init() Init = function()
---@param text string ---@param text string
---@param size number ---@param size number
---@return string[] ---@return string[]
@@ -103,6 +110,32 @@ function shared.Commander.Init()
end end
return ret return ret
end end
-- This is really ugly, duplicating methods like this
-- But I have no better idea
-- We would have to drag reference channel all the way here
-- And then in here do some kind of deciding based on the fucking channel locale
-- That's also a nasty solution... I guess adding "kto" is better
---@param arr table<string, Player>
---@return string[]
local function WhoRu(arr)
local ret = {}
for _, player in pairs(arr) do
if shared.Whoer.ShouldNotifyForZone(player.zone) then
shared.dump(player)
ret[#ret + 1] = string.format(
"%s/%s (%s) %s",
player.name,
shared._L(player.class, "ru"),
shared._L(player.zone, "ru"),
player.stinky and "(!!!!)" or ""
)
end
end
if Heimdall_Data.config.commander.debug then
print(string.format("[%s] Command result: %s", ModuleName, strjoin(", ", unpack(ret))))
end
return ret
end
---@param arr table<string, Player> ---@param arr table<string, Player>
---@return string[] ---@return string[]
local function WhoPartitioned(arr) local function WhoPartitioned(arr)
@@ -116,10 +149,23 @@ function shared.Commander.Init()
end end
---@param arr table<string, Player> ---@param arr table<string, Player>
---@return string[] ---@return string[]
local function WhoPartitionedRu(arr)
local who = WhoRu(arr)
local text = {}
---@diagnostic disable-next-line: param-type-mismatch something wrong with luals, it's picking up the "wrong" unpack
for _, line in pairs(Partition(strjoin(", ", unpack(who)), 200)) do
text[#text + 1] = "кто: " .. line
end
return text
end
---@param arr table<string, Player>
---@return string[]
local function CountClass(arr) local function CountClass(arr)
local ret = {} local ret = {}
for _, player in pairs(arr) do for _, player in pairs(arr) do
if shared.Whoer.ShouldNotifyForZone(player.zone) then ret[player.class] = (ret[player.class] or 0) + 1 end if shared.Whoer.ShouldNotifyForZone(player.zone) then
ret[player.class] = (ret[player.class] or 0) + 1
end
end end
local text = {} local text = {}
for class, count in pairs(ret) do for class, count in pairs(ret) do
@@ -152,12 +198,21 @@ function shared.Commander.Init()
local function WhoPartitionedStinkies() local function WhoPartitionedStinkies()
if Heimdall_Data.config.commander.debug then if Heimdall_Data.config.commander.debug then
print(string.format("[%s] Executing: WhoPartitionedStinkies", ModuleName)) print(string.format("[%s] Executing: WhoPartitionedStinkies", ModuleName))
shared.dumpTable(HeimdallStinkies) shared.dump(HeimdallStinkies)
end end
local res = WhoPartitioned(HeimdallStinkies) local res = WhoPartitioned(HeimdallStinkies)
if #res == 0 then return { "No stinkies found" } end if #res == 0 then return { "No stinkies found" } end
return res return res
end end
local function WhoPartitionedStinkiesRu()
if Heimdall_Data.config.commander.debug then
print(string.format("[%s] Executing: WhoPartitionedStinkies", ModuleName))
shared.dump(HeimdallStinkies)
end
local res = WhoPartitionedRu(HeimdallStinkies)
if #res == 0 then return { "No stinkies found" } end
return res
end
local function CountPartitionedStinkies() local function CountPartitionedStinkies()
if Heimdall_Data.config.commander.debug then if Heimdall_Data.config.commander.debug then
print(string.format("[%s] Executing: CountPartitionedStinkies", ModuleName)) print(string.format("[%s] Executing: CountPartitionedStinkies", ModuleName))
@@ -234,12 +289,40 @@ function shared.Commander.Init()
if Heimdall_Data.config.commander.debug then if Heimdall_Data.config.commander.debug then
print(string.format("[%s] Adding stinky: %s/%s", ModuleName, name, tostring(class))) print(string.format("[%s] Adding stinky: %s/%s", ModuleName, name, tostring(class)))
end end
shared.stinkyTracker.stinkies[name] = { shared.StinkyTracker.Track({
name = name, name = name,
class = class or "unknown", class = class or "unknown",
seenAt = GetTime(), seenAt = GetTime(),
hostile = true, hostile = true,
} })
if Heimdall_Data.config.commander.debug then
print(string.format("[%s] Added stinky: %s/%s", ModuleName, name, tostring(class)))
end
end
return {}
end
---@param args string[]
local function IgnoreMacroTarget(args)
if Heimdall_Data.config.commander.debug then
---@diagnostic disable-next-line: param-type-mismatch something wrong with luals, it's picking up the "wrong" unpack
print(string.format("[%s] Macroing: %s", ModuleName, strjoin(" ", unpack(args))))
end
if #args < 1 then
if Heimdall_Data.config.commander.debug then
print(string.format("[%s] Invalid number of arguments for IgnoreMacroTarget", ModuleName))
end
return {}
end
table.remove(args, 1)
for i = 1, #args do
local stinky = strtrim(args[i])
local name = stinky:match("([^/]+)")
if Heimdall_Data.config.commander.debug then
print(string.format("[%s] Ignoring stinky: %s", ModuleName, name))
end
shared.StinkyTracker.Ignore(name)
end end
return {} return {}
end end
@@ -251,6 +334,7 @@ function shared.Commander.Init()
local commands = { local commands = {
{ keywordRe = "^who$", commanderOnly = false, callback = WhoPartitionedStinkies }, { keywordRe = "^who$", commanderOnly = false, callback = WhoPartitionedStinkies },
{ keywordRe = "^кто$", commanderOnly = false, callback = WhoPartitionedStinkiesRu },
{ keywordRe = "^howmany$", commanderOnly = false, callback = CountPartitionedStinkies }, { keywordRe = "^howmany$", commanderOnly = false, callback = CountPartitionedStinkies },
{ keywordRe = "^classes$", commanderOnly = false, callback = CountClassPartitionedStinkies }, { keywordRe = "^classes$", commanderOnly = false, callback = CountClassPartitionedStinkies },
{ keywordRe = "^help$", commanderOnly = false, callback = HelpRu }, { keywordRe = "^help$", commanderOnly = false, callback = HelpRu },
@@ -259,6 +343,7 @@ function shared.Commander.Init()
{ keywordRe = "^leavegroup$", commanderOnly = false, callback = LeaveGroup }, { keywordRe = "^leavegroup$", commanderOnly = false, callback = LeaveGroup },
{ keywordRe = "^follow$", commanderOnly = false, callback = FollowTarget }, { keywordRe = "^follow$", commanderOnly = false, callback = FollowTarget },
{ keywordRe = "^macro", commanderOnly = false, callback = MacroTarget }, { keywordRe = "^macro", commanderOnly = false, callback = MacroTarget },
{ keywordRe = "^ignore", commanderOnly = false, callback = IgnoreMacroTarget },
} }
local commanderChannelFrame = CreateFrame("Frame") local commanderChannelFrame = CreateFrame("Frame")
@@ -266,7 +351,7 @@ function shared.Commander.Init()
commanderChannelFrame:SetScript("OnEvent", function(self, event, msg, sender, ...) commanderChannelFrame:SetScript("OnEvent", function(self, event, msg, sender, ...)
--if Heimdall_Data.config.commander.debug then --if Heimdall_Data.config.commander.debug then
-- print(string.format("[%s] Event received", ModuleName)) -- print(string.format("[%s] Event received", ModuleName))
-- shared.dumpTable(Heimdall_Data.config.commander) -- shared.dump(Heimdall_Data.config.commander)
--end --end
if not Heimdall_Data.config.commander.enabled then if not Heimdall_Data.config.commander.enabled then
--if Heimdall_Data.config.commander.debug then --if Heimdall_Data.config.commander.debug then
@@ -300,18 +385,22 @@ function shared.Commander.Init()
sender = string.match(sender, "^[^-]+") sender = string.match(sender, "^[^-]+")
if Heimdall_Data.config.commander.debug then if Heimdall_Data.config.commander.debug then
print(string.format("[%s] Message from: %s", ModuleName, sender)) print(string.format("[%s] Message from: %s", ModuleName, sender))
shared.dumpTable(Heimdall_Data.config.commander) shared.dump(Heimdall_Data.config.commander)
end end
for _, command in ipairs(commands) do for _, command in ipairs(commands) do
local enabled = Heimdall_Data.config.commander.commands[command.keywordRe] == true or false local enabled = Heimdall_Data.config.commander.commands[command.keywordRe] == true or false
if Heimdall_Data.config.commander.debug then if Heimdall_Data.config.commander.debug then
print(string.format("[%s] Command match: %s = %s", ModuleName, command.keywordRe, tostring(enabled))) print(
string.format("[%s] Command match: %s = %s", ModuleName, command.keywordRe, tostring(enabled))
)
end end
if if
enabled enabled
and ( and (
not command.commanderOnly not command.commanderOnly
-- if Heimdall_Data.config.commander.debug then print(string.format("[%s] Ignoring command, sender %s not commander %s", ModuleName, sender, Heimdall_Data.config.commander.commander)) end
or (command.commanderOnly and sender == Heimdall_Data.config.commander.commander) or (command.commanderOnly and sender == Heimdall_Data.config.commander.commander)
) )
then then
@@ -319,8 +408,8 @@ function shared.Commander.Init()
---@diagnostic disable-next-line: redundant-parameter Currently luals does not support variadic functions as a @field ---@diagnostic disable-next-line: redundant-parameter Currently luals does not support variadic functions as a @field
local messages = command.callback({ strsplit(",", msg) }) local messages = command.callback({ strsplit(",", msg) })
if Heimdall_Data.config.commander.debug then if Heimdall_Data.config.commander.debug then
---@diagnostic disable-next-line: param-type-mismatch print(string.format("[%s] Messages to send: %s", ModuleName, #messages))
print(string.format("[%s] Messages to send: %s", ModuleName, strjoin(", ", unpack(messages)))) shared.dump(messages)
end end
for _, message in ipairs(messages) do for _, message in ipairs(messages) do
---@type Message ---@type Message
@@ -331,15 +420,19 @@ function shared.Commander.Init()
} }
if Heimdall_Data.config.commander.debug then if Heimdall_Data.config.commander.debug then
print(string.format("[%s] Queuing message", ModuleName)) print(string.format("[%s] Queuing message", ModuleName))
shared.dumpTable(msg) shared.dump(msg)
end
if Heimdall_Data.config.networkMessenger.enabled then
shared.NetworkMessenger.Enqueue(returnmsg)
elseif Heimdall_Data.config.messenger.enabled then
shared.Messenger.Enqueue(returnmsg)
end end
--table.insert(shared.messenger.queue, msg)
table.insert(shared.networkMessenger.queue, returnmsg)
end end
end end
end end
end end
end) end)
print("[Heimdall] Commander module loaded") print(string.format("[%s] Module initialized", ModuleName))
end end,
}

View File

@@ -1,5 +1,6 @@
local _, shared = ... local _, shared = ...
---@cast shared HeimdallShared ---@cast shared HeimdallShared
local ModuleName = "Config"
---@param str string ---@param str string
---@return table<string, boolean> ---@return table<string, boolean>
@@ -398,9 +399,9 @@ end
--HeimdallTestFrame:SetWidth(512) --HeimdallTestFrame:SetWidth(512)
--configFrame:Add(HeimdallTestFrame, 20, 12) --configFrame:Add(HeimdallTestFrame, 20, 12)
---@diagnostic disable-next-line: missing-fields ---@class Config
shared.Config = {} shared.Config = {
function shared.Config.Init() Init = function()
configFrame.frame:SetScale(Heimdall_Data.config.scale) configFrame.frame:SetScale(Heimdall_Data.config.scale)
local buttonColors = { local buttonColors = {
@@ -570,7 +571,9 @@ function shared.Config.Init()
) )
configFrame:Add(scale, 2, 2) configFrame:Add(scale, 2, 2)
local title = configFrame.frame:CreateFontString(nil, "ARTWORK", "GameFontNormal") local title = configFrame.frame:CreateFontString(nil, "ARTWORK", "GameFontNormal")
title:SetText(string.format("%s - v%s", shared._L("heimdallConfig", Heimdall_Data.config.locale), shared.VERSION)) title:SetText(
string.format("%s - v%s", shared._L("heimdallConfig", Heimdall_Data.config.locale), shared.VERSION)
)
configFrame:Add(title, 2, 7) configFrame:Add(title, 2, 7)
local debug = CreateBasicButton( local debug = CreateBasicButton(
@@ -706,7 +709,7 @@ function shared.Config.Init()
local text = self:GetText() local text = self:GetText()
Heimdall_Data.config.spotter.channels = StringToArray(text, ",") Heimdall_Data.config.spotter.channels = StringToArray(text, ",")
print("Channels set to") print("Channels set to")
shared.dumpTable(Heimdall_Data.config.spotter.channels) shared.dump(Heimdall_Data.config.spotter.channels)
end end
) )
spotterConfigFrame:Add(channels, 2, 4) spotterConfigFrame:Add(channels, 2, 4)
@@ -806,7 +809,7 @@ function shared.Config.Init()
local text = self:GetText() local text = self:GetText()
Heimdall_Data.config.who.channels = StringToArray(text, ",") Heimdall_Data.config.who.channels = StringToArray(text, ",")
print("Channels set to") print("Channels set to")
shared.dumpTable(Heimdall_Data.config.who.channels) shared.dump(Heimdall_Data.config.who.channels)
end end
) )
whoerConfigFrame:Add(channels, 2, 3) whoerConfigFrame:Add(channels, 2, 3)
@@ -1018,7 +1021,7 @@ function shared.Config.Init()
local text = self:GetText() local text = self:GetText()
Heimdall_Data.config.deathReporter.channels = StringToArray(text, ",") Heimdall_Data.config.deathReporter.channels = StringToArray(text, ",")
print("Channels set to") print("Channels set to")
shared.dumpTable(Heimdall_Data.config.deathReporter.channels) shared.dump(Heimdall_Data.config.deathReporter.channels)
end end
) )
deathReporterConfigFrame:Add(channels, 2, 6) deathReporterConfigFrame:Add(channels, 2, 6)
@@ -1143,7 +1146,7 @@ function shared.Config.Init()
local text = self:GetText() local text = self:GetText()
Heimdall_Data.config.inviter.channels = StringToArray(text, ",") Heimdall_Data.config.inviter.channels = StringToArray(text, ",")
print("Channels set to") print("Channels set to")
shared.dumpTable(Heimdall_Data.config.inviter.channels) shared.dump(Heimdall_Data.config.inviter.channels)
end end
) )
inviterConfigFrame:Add(channels, 2, 6) inviterConfigFrame:Add(channels, 2, 6)
@@ -1298,7 +1301,7 @@ function shared.Config.Init()
local text = self:GetText() local text = self:GetText()
Heimdall_Data.config.agentTracker.channels = StringToArray(text, ",") Heimdall_Data.config.agentTracker.channels = StringToArray(text, ",")
print("Channels set to") print("Channels set to")
shared.dumpTable(Heimdall_Data.config.agentTracker.channels) shared.dump(Heimdall_Data.config.agentTracker.channels)
end end
) )
agentTrackerConfigFrame:Add(channels, 2, 6) agentTrackerConfigFrame:Add(channels, 2, 6)
@@ -1351,7 +1354,7 @@ function shared.Config.Init()
local text = self:GetText() local text = self:GetText()
Heimdall_Data.config.stinkyTracker.channels = StringToArray(text, ",") Heimdall_Data.config.stinkyTracker.channels = StringToArray(text, ",")
print("Channels set to") print("Channels set to")
shared.dumpTable(Heimdall_Data.config.stinkyTracker.channels) shared.dump(Heimdall_Data.config.stinkyTracker.channels)
end end
) )
stinkyTrackerConfigFrame:Add(channels, 2, 6) stinkyTrackerConfigFrame:Add(channels, 2, 6)
@@ -1404,7 +1407,7 @@ function shared.Config.Init()
local text = self:GetText() local text = self:GetText()
Heimdall_Data.config.emoter.channels = StringToArray(text, ",") Heimdall_Data.config.emoter.channels = StringToArray(text, ",")
print("Channels set to") print("Channels set to")
shared.dumpTable(Heimdall_Data.config.emoter.channels) shared.dump(Heimdall_Data.config.emoter.channels)
end end
) )
emoterConfigFrame:Add(channels, 2, 6) emoterConfigFrame:Add(channels, 2, 6)
@@ -1475,7 +1478,7 @@ function shared.Config.Init()
local text = self:GetText() local text = self:GetText()
Heimdall_Data.config.echoer.channels = StringToArray(text, ",") Heimdall_Data.config.echoer.channels = StringToArray(text, ",")
print("Channels set to") print("Channels set to")
shared.dumpTable(Heimdall_Data.config.echoer.channels) shared.dump(Heimdall_Data.config.echoer.channels)
end end
) )
echoerConfigFrame:Add(channels, 2, 6) echoerConfigFrame:Add(channels, 2, 6)
@@ -1546,7 +1549,7 @@ function shared.Config.Init()
local text = self:GetText() local text = self:GetText()
Heimdall_Data.config.commander.channels = StringToArray(text, ",") Heimdall_Data.config.commander.channels = StringToArray(text, ",")
print("Channels set to") print("Channels set to")
shared.dumpTable(Heimdall_Data.config.commander.channels) shared.dump(Heimdall_Data.config.commander.channels)
end end
) )
commanderConfigFrame:Add(channels, 2, 6) commanderConfigFrame:Add(channels, 2, 6)
@@ -1680,7 +1683,7 @@ function shared.Config.Init()
local text = self:GetText() local text = self:GetText()
Heimdall_Data.config.combatAlerter.channels = StringToArray(text, ",") Heimdall_Data.config.combatAlerter.channels = StringToArray(text, ",")
print("Channels set to") print("Channels set to")
shared.dumpTable(Heimdall_Data.config.combatAlerter.channels) shared.dump(Heimdall_Data.config.combatAlerter.channels)
end end
) )
combatAlerterConfigFrame:Add(channels, 2, 6) combatAlerterConfigFrame:Add(channels, 2, 6)
@@ -1745,7 +1748,7 @@ function shared.Config.Init()
local text = self:GetText() local text = self:GetText()
Heimdall_Data.config.sniffer.channels = StringToArray(text, ",") Heimdall_Data.config.sniffer.channels = StringToArray(text, ",")
print("Channels set to") print("Channels set to")
shared.dumpTable(Heimdall_Data.config.sniffer.channels) shared.dump(Heimdall_Data.config.sniffer.channels)
end end
) )
snifferConfigFrame:Add(channels, 2, 6) snifferConfigFrame:Add(channels, 2, 6)
@@ -1835,7 +1838,7 @@ function shared.Config.Init()
local text = self:GetText() local text = self:GetText()
Heimdall_Data.config.bonkDetector.channels = StringToArray(text, ",") Heimdall_Data.config.bonkDetector.channels = StringToArray(text, ",")
print("Channels set to") print("Channels set to")
shared.dumpTable(Heimdall_Data.config.bonkDetector.channels) shared.dump(Heimdall_Data.config.bonkDetector.channels)
end end
) )
bonkDetectorConfigFrame:Add(channels, 2, 6) bonkDetectorConfigFrame:Add(channels, 2, 6)
@@ -1906,7 +1909,7 @@ function shared.Config.Init()
local text = self:GetText() local text = self:GetText()
Heimdall_Data.config.minimapTagger.channels = StringToArray(text, ",") Heimdall_Data.config.minimapTagger.channels = StringToArray(text, ",")
print("Channels set to") print("Channels set to")
shared.dumpTable(Heimdall_Data.config.minimapTagger.channels) shared.dump(Heimdall_Data.config.minimapTagger.channels)
end end
) )
minimapTaggerConfigFrame:Add(channels, 2, 3) minimapTaggerConfigFrame:Add(channels, 2, 3)
@@ -2275,7 +2278,7 @@ function shared.Config.Init()
local text = self:GetText() local text = self:GetText()
Heimdall_Data.config.noter.channels = StringToArray(text, ",") Heimdall_Data.config.noter.channels = StringToArray(text, ",")
print("Channels set to") print("Channels set to")
shared.dumpTable(Heimdall_Data.config.noter.channels) shared.dump(Heimdall_Data.config.noter.channels)
end end
) )
noterConfigFrame:Add(channels, 2, 6) noterConfigFrame:Add(channels, 2, 6)
@@ -2462,7 +2465,8 @@ function shared.Config.Init()
achievementSnifferConfigFrame.frame, achievementSnifferConfigFrame.frame,
shared._L("enabled", Heimdall_Data.config.locale), shared._L("enabled", Heimdall_Data.config.locale),
function() function()
Heimdall_Data.config.achievementSniffer.enabled = not Heimdall_Data.config.achievementSniffer.enabled Heimdall_Data.config.achievementSniffer.enabled =
not Heimdall_Data.config.achievementSniffer.enabled
return Heimdall_Data.config.achievementSniffer.enabled return Heimdall_Data.config.achievementSniffer.enabled
end end
) )
@@ -2656,9 +2660,50 @@ function shared.Config.Init()
channelLocaleConfigFrame:Add(channelLocale, 8, 12) channelLocaleConfigFrame:Add(channelLocale, 8, 12)
end end
-- ChatSniffer
do
local r, g, b, a = GetNextColor()
local chatSnifferConfigFrame = GridFrame.new("HeimdallChatSnifferConfig", UIParent, 12, 20)
chatSnifferConfigFrame.frame:SetBackdropColor(r, g, b, 0.3)
configFrame:Add(chatSnifferConfigFrame, 4, 1)
title = CreateFancyText(
"HeimdallChatSnifferConfigTitle",
chatSnifferConfigFrame.frame,
shared._L("chatSniffer", Heimdall_Data.config.locale),
{ r, g, b, a }
)
chatSnifferConfigFrame:Add(title, 1, 8)
local debugButton = CreateBasicButton(
"HeimdallChatSnifferConfigDebugButton",
chatSnifferConfigFrame.frame,
shared._L("debug", Heimdall_Data.config.locale),
function()
Heimdall_Data.config.chatSniffer.debug = not Heimdall_Data.config.chatSniffer.debug
return Heimdall_Data.config.chatSniffer.debug
end
)
debugButton:UpdateColor(Heimdall_Data.config.chatSniffer.debug)
chatSnifferConfigFrame:Add(debugButton, 1, 4)
local enableButton = CreateBasicButton(
"HeimdallChatSnifferConfigEnableButton",
chatSnifferConfigFrame.frame,
shared._L("enabled", Heimdall_Data.config.locale),
function()
Heimdall_Data.config.chatSniffer.enabled = not Heimdall_Data.config.chatSniffer.enabled
return Heimdall_Data.config.chatSniffer.enabled
end
)
enableButton:UpdateColor(Heimdall_Data.config.chatSniffer.enabled)
chatSnifferConfigFrame:Add(enableButton, 1, 12)
end
configFrame.frame:Hide() configFrame.frame:Hide()
print("[Heimdall] Config loaded") print("[Heimdall] Config loaded")
end end,
}
SlashCmdList["HEIMDALL_CONFIG"] = function() configFrame.frame:Show() end SlashCmdList["HEIMDALL_CONFIG"] = function() configFrame.frame:Show() end
SLASH_HEIMDALL_CONFIG1 = "/heimdall_config" SLASH_HEIMDALL_CONFIG1 = "/heimdall_config"

View File

@@ -2,6 +2,11 @@ local _, shared = ...
---@cast shared HeimdallShared ---@cast shared HeimdallShared
local ModuleName = "Configurator" local ModuleName = "Configurator"
---@diagnostic disable-next-line: missing-fields ---@class HeimdallConfiguratorConfig
shared.Configurator = {} ---@field enabled boolean
function shared.Configurator.Init() print(string.format("[Heimdall] %s module loaded", ModuleName)) end ---@field debug boolean
---@class Configurator
shared.Configurator = {
Init = function() print(string.format("[%s] Module initialized", ModuleName)) end,
}

View File

@@ -2,9 +2,18 @@ local _, shared = ...
---@cast shared HeimdallShared ---@cast shared HeimdallShared
local ModuleName = "DeathReporter" local ModuleName = "DeathReporter"
---@diagnostic disable-next-line: missing-fields ---@class HeimdallDeathReporterConfig
shared.DeathReporter = {} ---@field enabled boolean
function shared.DeathReporter.Init() ---@field debug boolean
---@field throttle number
---@field doWhisper boolean
---@field channels string[]
---@field zoneOverride string?
---@field duelThrottle number
---@class DeathReporter
shared.DeathReporter = {
Init = function()
---@type table<string, number> ---@type table<string, number>
local recentDeaths = {} local recentDeaths = {}
---@type table<string, number> ---@type table<string, number>
@@ -38,7 +47,8 @@ function shared.DeathReporter.Init()
and GetTime() - recentDeaths[destination] < Heimdall_Data.config.deathReporter.throttle and GetTime() - recentDeaths[destination] < Heimdall_Data.config.deathReporter.throttle
then then
if Heimdall_Data.config.deathReporter.debug then if Heimdall_Data.config.deathReporter.debug then
local timeLeft = Heimdall_Data.config.deathReporter.throttle - (GetTime() - recentDeaths[destination]) local timeLeft = Heimdall_Data.config.deathReporter.throttle
- (GetTime() - recentDeaths[destination])
print( print(
string.format( string.format(
"[%s] Death report throttled for %s (%.1f seconds remaining)", "[%s] Death report throttled for %s (%.1f seconds remaining)",
@@ -168,7 +178,7 @@ function shared.DeathReporter.Init()
} }
if Heimdall_Data.config.deathReporter.debug then if Heimdall_Data.config.deathReporter.debug then
print(string.format("[%s] Queuing death report message", ModuleName)) print(string.format("[%s] Queuing death report message", ModuleName))
shared.dumpTable(msg) shared.dump(msg)
end end
table.insert(shared.messenger.queue, msg) table.insert(shared.messenger.queue, msg)
end end
@@ -222,7 +232,12 @@ function shared.DeathReporter.Init()
if Heimdall_Data.config.deathReporter.debug then if Heimdall_Data.config.deathReporter.debug then
print(string.format("[%s] Received system message: %s", ModuleName, msg)) print(string.format("[%s] Received system message: %s", ModuleName, msg))
print( print(
string.format("[%s] Source: %s, Destination: %s", ModuleName, tostring(source), tostring(destination)) string.format(
"[%s] Source: %s, Destination: %s",
ModuleName,
tostring(source),
tostring(destination)
)
) )
end end
if not source or not destination then return end if not source or not destination then return end
@@ -248,5 +263,6 @@ function shared.DeathReporter.Init()
) )
) )
end end
print("[Heimdall] DeathReporter loaded") print(string.format("[%s] Module initialized", ModuleName))
end end,
}

View File

@@ -2,9 +2,14 @@ local _, shared = ...
---@cast shared HeimdallShared ---@cast shared HeimdallShared
local ModuleName = "Dueler" local ModuleName = "Dueler"
---@diagnostic disable-next-line: missing-fields ---@class HeimdallDuelerConfig
shared.Dueler = {} ---@field enabled boolean
function shared.Dueler.Init() ---@field debug boolean
---@field declineOther boolean
---@class Dueler
shared.Dueler = {
Init = function()
local frame = CreateFrame("Frame") local frame = CreateFrame("Frame")
frame:RegisterEvent("DUEL_REQUESTED") frame:RegisterEvent("DUEL_REQUESTED")
frame:SetScript("OnEvent", function(self, event, sender) frame:SetScript("OnEvent", function(self, event, sender)
@@ -22,7 +27,7 @@ function shared.Dueler.Init()
print(string.format("[%s] Checking if sender '%s' is in agents list", ModuleName, sender)) print(string.format("[%s] Checking if sender '%s' is in agents list", ModuleName, sender))
end end
local allow = Heimdall_Data.config.agents[sender] local allow = shared.AgentTracker.IsAgent(sender)
if allow then if allow then
if Heimdall_Data.config.dueler.debug then if Heimdall_Data.config.dueler.debug then
print(string.format("[%s] Accepting duel from trusted agent: %s", ModuleName, sender)) print(string.format("[%s] Accepting duel from trusted agent: %s", ModuleName, sender))
@@ -36,7 +41,9 @@ function shared.Dueler.Init()
CancelDuel() CancelDuel()
else else
if Heimdall_Data.config.dueler.debug then if Heimdall_Data.config.dueler.debug then
print(string.format("[%s] Leaving duel request from %s for manual response", ModuleName, sender)) print(
string.format("[%s] Leaving duel request from %s for manual response", ModuleName, sender)
)
end end
end end
end end
@@ -51,5 +58,6 @@ function shared.Dueler.Init()
) )
) )
end end
print("[Heimdall] Dueler loaded") print(string.format("[%s] Module initialized", ModuleName))
end end,
}

View File

@@ -1,25 +1,31 @@
local _, shared = ... local _, shared = ...
---@cast shared HeimdallShared ---@cast shared HeimdallShared
if not shared.dumpTable then if not shared.dump then
---@param table table ---@param value any
---@param msg string?
---@param depth number? ---@param depth number?
shared.dumpTable = function(table, depth) shared.dump = function(value, msg, depth)
if not table then if not value then
print(tostring(table)) print(tostring(value))
return return
end end
if type(value) ~= "table" then
print(tostring(value))
return
end
if msg then print(msg) end
if depth == nil then depth = 0 end if depth == nil then depth = 0 end
if depth > 200 then if depth > 200 then
print("Error: Depth > 200 in dumpTable()") print("Error: Depth > 200 in dump()")
return return
end end
for k, v in pairs(table) do for k, v in pairs(value) do
if type(v) == "table" then if type(v) == "table" then
print(string.rep(" ", depth) .. k .. ":") print(string.rep(" ", depth) .. tostring(k) .. ":")
shared.dumpTable(v, depth + 1) shared.dump(v, msg, depth + 1)
else else
print(string.rep(" ", depth) .. k .. ": ", v) print(string.rep(" ", depth) .. tostring(k) .. ": " .. tostring(v))
end end
end end
end end

View File

@@ -2,9 +2,15 @@ local _, shared = ...
---@cast shared HeimdallShared ---@cast shared HeimdallShared
local ModuleName = "Echoer" local ModuleName = "Echoer"
---@diagnostic disable-next-line: missing-fields ---@class HeimdallEchoerConfig
shared.Echoer = {} ---@field enabled boolean
function shared.Echoer.Init() ---@field debug boolean
---@field channels string[]
---@field prefix string
---@class Echoer
shared.Echoer = {
Init = function()
local frame = CreateFrame("Frame") local frame = CreateFrame("Frame")
frame:RegisterEvent("CHAT_MSG_CHANNEL") frame:RegisterEvent("CHAT_MSG_CHANNEL")
frame:SetScript("OnEvent", function(self, event, msg, sender, ...) frame:SetScript("OnEvent", function(self, event, msg, sender, ...)
@@ -36,7 +42,7 @@ function shared.Echoer.Init()
end end
if Heimdall_Data.config.echoer.debug then if Heimdall_Data.config.echoer.debug then
print(string.format("[%s] Processing message from master channel: %s", ModuleName, sender)) print(string.format("[%s] Processing message from master channel: %s", ModuleName, sender))
shared.dumpTable(Heimdall_Data.config.echoer) shared.dump(Heimdall_Data.config.echoer)
end end
if string.find(msg, "^" .. Heimdall_Data.config.echoer.prefix) then if string.find(msg, "^" .. Heimdall_Data.config.echoer.prefix) then
@@ -54,5 +60,6 @@ function shared.Echoer.Init()
end) end)
if Heimdall_Data.config.echoer.debug then print(string.format("[%s] Module initialized", ModuleName)) end if Heimdall_Data.config.echoer.debug then print(string.format("[%s] Module initialized", ModuleName)) end
print("[Heimdall] Echoer loaded") print(string.format("[%s] Module initialized", ModuleName))
end end,
}

View File

@@ -2,9 +2,15 @@ local _, shared = ...
---@cast shared HeimdallShared ---@cast shared HeimdallShared
local ModuleName = "Emoter" local ModuleName = "Emoter"
---@diagnostic disable-next-line: missing-fields ---@class HeimdallEmoterConfig
shared.Emoter = {} ---@field enabled boolean
function shared.Emoter.Init() ---@field debug boolean
---@field channels string[]
---@field prefix string
---@class Emoter
shared.Emoter = {
Init = function()
local frame = CreateFrame("Frame") local frame = CreateFrame("Frame")
frame:RegisterEvent("CHAT_MSG_CHANNEL") frame:RegisterEvent("CHAT_MSG_CHANNEL")
frame:SetScript("OnEvent", function(self, event, msg, sender, ...) frame:SetScript("OnEvent", function(self, event, msg, sender, ...)
@@ -37,7 +43,7 @@ function shared.Emoter.Init()
if Heimdall_Data.config.emoter.debug then if Heimdall_Data.config.emoter.debug then
print(string.format("[%s] Processing message from master channel: %s", ModuleName, sender)) print(string.format("[%s] Processing message from master channel: %s", ModuleName, sender))
shared.dumpTable(Heimdall_Data.config.emoter) shared.dump(Heimdall_Data.config.emoter)
end end
if string.find(msg, "^" .. Heimdall_Data.config.emoter.prefix) then if string.find(msg, "^" .. Heimdall_Data.config.emoter.prefix) then
@@ -55,5 +61,6 @@ function shared.Emoter.Init()
end) end)
if Heimdall_Data.config.emoter.debug then print(string.format("[%s] Module initialized", ModuleName)) end if Heimdall_Data.config.emoter.debug then print(string.format("[%s] Module initialized", ModuleName)) end
print("[Heimdall] Emoter loaded") print(string.format("[%s] Module initialized", ModuleName))
end end,
}

View File

@@ -2,9 +2,22 @@ local _, shared = ...
---@cast shared HeimdallShared ---@cast shared HeimdallShared
local ModuleName = "Inviter" local ModuleName = "Inviter"
---@diagnostic disable-next-line: missing-fields ---@class HeimdallInviterConfig
shared.Inviter = {} ---@field enabled boolean
function shared.Inviter.Init() ---@field debug boolean
---@field channels string[]
---@field keyword string
---@field allAssist boolean
---@field agentsAssist boolean
---@field throttle number
---@field kickOffline boolean
---@field cleanupInterval number
---@field afkThreshold number
---@field listeningChannel table<string, boolean>
---@class Inviter
shared.Inviter = {
Init = function()
-- Fallback for old config -- Fallback for old config
if type(Heimdall_Data.config.inviter.listeningChannel) == "string" then if type(Heimdall_Data.config.inviter.listeningChannel) == "string" then
Heimdall_Data.config.inviter.listeningChannel = { Heimdall_Data.config.inviter.listeningChannel = {
@@ -35,29 +48,25 @@ function shared.Inviter.Init()
if Heimdall_Data.config.inviter.agentsAssist then if Heimdall_Data.config.inviter.agentsAssist then
if Heimdall_Data.config.inviter.debug then if Heimdall_Data.config.inviter.debug then
local agentCount = 0 print(string.format("[%s] Processing agents for assistant promotion", ModuleName))
for _ in pairs(Heimdall_Data.config.agents) do
agentCount = agentCount + 1
end
print(string.format("[%s] Processing %d agents for assistant promotion", ModuleName, agentCount))
end end
for name, _ in pairs(Heimdall_Data.config.agents) do shared.AgentTracker.ForEach(function(agent)
if UnitInParty(name) and not UnitIsGroupLeader(name) and not UnitIsRaidOfficer(name) then if UnitInParty(agent) and not UnitIsGroupLeader(agent) and not UnitIsRaidOfficer(agent) then
if Heimdall_Data.config.inviter.debug then if Heimdall_Data.config.inviter.debug then
print(string.format("[%s] Promoting agent to assistant: %s", ModuleName, name)) print(string.format("[%s] Promoting agent to assistant: %s", ModuleName, agent))
end end
PromoteToAssistant(name, true) PromoteToAssistant(agent, true)
elseif Heimdall_Data.config.inviter.debug then elseif Heimdall_Data.config.inviter.debug then
if not UnitInParty(name) then if not UnitInParty(agent) then
print(string.format("[%s] Agent not in party: %s", ModuleName, name)) print(string.format("[%s] Agent not in party: %s", ModuleName, agent))
elseif UnitIsGroupLeader(name) then elseif UnitIsGroupLeader(agent) then
print(string.format("[%s] Agent is already leader: %s", ModuleName, name)) print(string.format("[%s] Agent is already leader: %s", ModuleName, agent))
elseif UnitIsRaidOfficer(name) then elseif UnitIsRaidOfficer(agent) then
print(string.format("[%s] Agent is already assistant: %s", ModuleName, name)) print(string.format("[%s] Agent is already assistant: %s", ModuleName, agent))
end
end end
end end
end)
end end
if Heimdall_Data.config.inviter.debug then if Heimdall_Data.config.inviter.debug then
@@ -205,7 +214,7 @@ function shared.Inviter.Init()
inviterChannelFrame:SetScript("OnEvent", function(self, event, msg, sender, ...) inviterChannelFrame:SetScript("OnEvent", function(self, event, msg, sender, ...)
--if Heimdall_Data.config.inviter.debug then --if Heimdall_Data.config.inviter.debug then
-- print(string.format("[%s] Chat message received: %s", ModuleName, msg)) -- print(string.format("[%s] Chat message received: %s", ModuleName, msg))
-- shared.dumpTable(Heimdall_Data.config.inviter) -- shared.dump(Heimdall_Data.config.inviter)
--end --end
if not Heimdall_Data.config.inviter.enabled then return end if not Heimdall_Data.config.inviter.enabled then return end
local channelId = select(6, ...) local channelId = select(6, ...)
@@ -229,7 +238,9 @@ function shared.Inviter.Init()
return return
end end
if msg == Heimdall_Data.config.inviter.keyword then if msg == Heimdall_Data.config.inviter.keyword then
if Heimdall_Data.config.inviter.debug then print(string.format("[%s] Inviting %s", ModuleName, sender)) end if Heimdall_Data.config.inviter.debug then
print(string.format("[%s] Inviting %s", ModuleName, sender))
end
InviteUnit(sender) InviteUnit(sender)
else else
if Heimdall_Data.config.inviter.debug then if Heimdall_Data.config.inviter.debug then
@@ -259,5 +270,6 @@ function shared.Inviter.Init()
) )
) )
end end
print("[Heimdall] Inviter loaded") print(string.format("[%s] Module initialized", ModuleName))
end end,
}

View File

@@ -2,15 +2,14 @@ local _, shared = ...
---@cast shared HeimdallShared ---@cast shared HeimdallShared
local ModuleName = "Macroer" local ModuleName = "Macroer"
---@diagnostic disable-next-line: missing-fields ---@class HeimdallMacroerConfig
shared.Macroer = {} ---@field enabled boolean
function shared.Macroer.Init() ---@field debug boolean
---@class stinky ---@field priority string[]
---@field name string
---@field class string
---@field seenAt number
---@field hostile boolean
---@class Macroer
shared.Macroer = {
Init = function()
local function FindOrCreateMacro(macroName) local function FindOrCreateMacro(macroName)
if Heimdall_Data.config.macroer.debug then if Heimdall_Data.config.macroer.debug then
print(string.format("[%s] Finding or creating macro: %s", ModuleName, macroName)) print(string.format("[%s] Finding or creating macro: %s", ModuleName, macroName))
@@ -27,7 +26,7 @@ function shared.Macroer.Init()
return idx return idx
end end
---@param stinkies table<string, stinky> ---@param stinkies table<string, Stinky>
local function FixMacro(stinkies) local function FixMacro(stinkies)
if Heimdall_Data.config.macroer.debug then if Heimdall_Data.config.macroer.debug then
print(string.format("[%s] Fixing macro with %d stinkies", ModuleName, #stinkies)) print(string.format("[%s] Fixing macro with %d stinkies", ModuleName, #stinkies))
@@ -53,7 +52,7 @@ function shared.Macroer.Init()
local sortedStinkies = {} local sortedStinkies = {}
for _, stinky in pairs(stinkies) do for _, stinky in pairs(stinkies) do
if not Heimdall_Data.config.agents[stinky.name] then sortedStinkies[#sortedStinkies + 1] = stinky end if not shared.AgentTracker.IsAgent(stinky.name) then sortedStinkies[#sortedStinkies + 1] = stinky end
end end
if Heimdall_Data.config.macroer.debug then if Heimdall_Data.config.macroer.debug then
@@ -68,7 +67,7 @@ function shared.Macroer.Init()
if Heimdall_Data.config.macroer.debug then if Heimdall_Data.config.macroer.debug then
print(string.format("[%s] Sorted stinkies: %d", ModuleName, #sortedStinkies)) print(string.format("[%s] Sorted stinkies: %d", ModuleName, #sortedStinkies))
shared.dumpTable(sortedStinkies) shared.dump(sortedStinkies)
end end
local lines = { "/targetenemy" } local lines = { "/targetenemy" }
for _, stinky in pairs(sortedStinkies) do for _, stinky in pairs(sortedStinkies) do
@@ -89,13 +88,14 @@ function shared.Macroer.Init()
EditMacro(idx, "HeimdallTarget", "INV_Misc_QuestionMark", body) EditMacro(idx, "HeimdallTarget", "INV_Misc_QuestionMark", body)
end end
shared.stinkyTracker.stinkies:onChange(function(value) shared.StinkyTracker.OnChange(function(stinkies)
if Heimdall_Data.config.macroer.debug then if Heimdall_Data.config.macroer.debug then
print(string.format("[%s] Stinkies changed, updating macro", ModuleName)) print(string.format("[%s] Stinkies changed, updating macro", ModuleName))
shared.dump(stinkies)
end end
FixMacro(value) FixMacro(stinkies)
end) end)
if Heimdall_Data.config.macroer.debug then print(string.format("[%s] Module initialized", ModuleName)) end if Heimdall_Data.config.macroer.debug then print(string.format("[%s] Module initialized", ModuleName)) end
print("[Heimdall] Macroer loaded") print(string.format("[%s] Module initialized", ModuleName))
end end,
}

View File

@@ -2,13 +2,28 @@ local _, shared = ...
---@cast shared HeimdallShared ---@cast shared HeimdallShared
local ModuleName = "Messenger" local ModuleName = "Messenger"
---@diagnostic disable-next-line: missing-fields ---@class HeimdallMessengerConfig
shared.Messenger = {} ---@field enabled boolean
function shared.Messenger.Init() ---@field debug boolean
---@class Message ---@field interval number
---@field message string
---@field channel string ---@class HeimdallMessengerData
---@field data string ---@field queue ReactiveValue<table<string, Message>>
---@field ticker Timer?
---@class Message
---@field message string
---@field channel string
---@field data string
---@class Messenger
shared.Messenger = {
---@param message Message
Enqueue = function(message) table.insert(shared.messenger.queue, message) end,
Init = function()
shared.messenger = {
queue = ReactiveValue.new({}),
}
local function FindOrJoinChannel(channelName, password) local function FindOrJoinChannel(channelName, password)
local channelId = GetChannelName(channelName) local channelId = GetChannelName(channelName)
@@ -29,84 +44,76 @@ function shared.Messenger.Init()
return channelId return channelId
end end
---@diagnostic disable-next-line: missing-fields
if not shared.messenger then shared.messenger = {} end
if not shared.messenger.queue then shared.messenger.queue = {} end
if not shared.messenger.ticker then if not shared.messenger.ticker then
local function DoMessage() local function DoMessage()
if Heimdall_Data.config.messenger.debug then -- if Heimdall_Data.config.messenger.debug then
print(string.format("[%s] Processing message queue - Size: %d", ModuleName, #shared.messenger.queue)) -- print(
end -- string.format(
-- "[%s] Processing message queue - Size: %d",
-- ModuleName,
-- #shared.messenger.queue:get()
-- )
-- )
-- end
if not Heimdall_Data.config.messenger.enabled then if not Heimdall_Data.config.messenger.enabled then
if Heimdall_Data.config.messenger.debug then -- if Heimdall_Data.config.messenger.debug then
print(string.format("[%s] Module disabled, skipping message processing", ModuleName)) -- print(string.format("[%s] Module disabled, skipping message processing", ModuleName))
end -- end
return return
end end
---@type Message ---@type Message
local message = shared.messenger.queue[1] local message = shared.messenger.queue[1]
if not message then if not message then
if Heimdall_Data.config.messenger.debug then -- if Heimdall_Data.config.messenger.debug then
print(string.format("[%s] Message queue empty", ModuleName)) -- print(string.format("[%s] Message queue empty", ModuleName))
end -- end
return return
end end
if Heimdall_Data.config.messenger.debug then if Heimdall_Data.config.messenger.debug then shared.dump(message, "[%s] Processing message:") end
print(
string.format(
"[%s] Processing message - Channel: %s, Data: %s",
ModuleName,
message.channel or "nil",
message.data or "nil"
)
)
print(string.format("[%s] Message content: %s", ModuleName, message.message or "nil"))
end
if not message.message or message.message == "" then if not message.message or message.message == "" then
if Heimdall_Data.config.messenger.debug then if Heimdall_Data.config.messenger.debug then
print(string.format("[%s] Invalid message: empty content", ModuleName)) shared.dump(message, string.format("[%s] Invalid message: empty content", ModuleName))
end end
return return
end end
if not message.channel or message.channel == "" then if not message.channel or message.channel == "" then
if Heimdall_Data.config.messenger.debug then if Heimdall_Data.config.messenger.debug then
print(string.format("[%s] Invalid message: no channel specified", ModuleName)) shared.dump(message, string.format("[%s] Invalid message: no channel specified", ModuleName))
end end
return return
end end
if string.find(message.channel, "^C") then if string.find(message.channel, "^C") then
if Heimdall_Data.config.messenger.debug then if Heimdall_Data.config.messenger.debug then
print(string.format("[%s] Converting channel type from C to CHANNEL", ModuleName)) shared.dump(
message,
string.format("[%s] Converting channel type from C to CHANNEL", ModuleName)
)
end end
message.channel = "CHANNEL" message.channel = "CHANNEL"
elseif string.find(message.channel, "^W") then elseif string.find(message.channel, "^W") then
if Heimdall_Data.config.messenger.debug then if Heimdall_Data.config.messenger.debug then
print(string.format("[%s] Converting channel type from W to WHISPER", ModuleName)) shared.dump(
message,
string.format("[%s] Converting channel type from W to WHISPER", ModuleName)
)
end end
message.channel = "WHISPER" message.channel = "WHISPER"
end end
if message.channel == "CHANNEL" and message.data and string.match(message.data, "%D") then if message.channel == "CHANNEL" and message.data and string.match(message.data, "%D") then
if Heimdall_Data.config.messenger.debug then if Heimdall_Data.config.messenger.debug then
print( shared.dump(message, string.format("[%s] Processing channel message:", ModuleName))
string.format(
"[%s] Processing channel message: '%s' to '%s'",
ModuleName,
message.message,
message.data
)
)
end end
local channelId = GetChannelName(message.data) local channelId = GetChannelName(message.data)
if channelId == 0 then if channelId == 0 then
if Heimdall_Data.config.messenger.debug then if Heimdall_Data.config.messenger.debug then
print(string.format("[%s] Channel not found, attempting to join: %s", ModuleName, message.data)) shared.dump(message, string.format("[%s] Channel not found, joining:", ModuleName))
end end
channelId = FindOrJoinChannel(message.data) channelId = FindOrJoinChannel(message.data)
if Heimdall_Data.config.messenger.debug then if Heimdall_Data.config.messenger.debug then
@@ -119,44 +126,36 @@ function shared.Messenger.Init()
table.remove(shared.messenger.queue, 1) table.remove(shared.messenger.queue, 1)
if not message.message or message.message == "" then if not message.message or message.message == "" then
if Heimdall_Data.config.messenger.debug then if Heimdall_Data.config.messenger.debug then
print(string.format("[%s] Skipping empty message", ModuleName)) shared.dump(message, string.format("[%s] Skipping empty message", ModuleName))
end end
return return
end end
if not message.channel or message.channel == "" then if not message.channel or message.channel == "" then
if Heimdall_Data.config.messenger.debug then if Heimdall_Data.config.messenger.debug then
print(string.format("[%s] Skipping message with no channel", ModuleName)) shared.dump(message, string.format("[%s] Skipping message with no channel", ModuleName))
end end
return return
end end
if not message.data or message.data == "" then if not message.data or message.data == "" then
if Heimdall_Data.config.messenger.debug then if Heimdall_Data.config.messenger.debug then
print(string.format("[%s] Skipping message with no data", ModuleName)) shared.dump(message, string.format("[%s] Skipping message with no data", ModuleName))
end end
return return
end end
if Heimdall_Data.config.messenger.debug then if Heimdall_Data.config.messenger.debug then
print( shared.dump(message, string.format("[%s] Sending message:", ModuleName))
string.format(
"[%s] Sending message: '%s' to %s:%s",
ModuleName,
message.message,
message.channel,
message.data
)
)
end end
if string.len(message.message) > 255 then if string.len(message.message) > 255 then
print(string.format("[%s] Message too long!!!!: %s", ModuleName, message.message)) shared.dump(message, string.format("[%s] Message too long!!!!: %s", ModuleName, message.message))
return return
end end
SendChatMessage(message.message, message.channel, nil, message.data) SendChatMessage(message.message, message.channel, nil, message.data)
end end
local function Tick() local function Tick()
if Heimdall_Data.config.messenger.debug then -- if Heimdall_Data.config.messenger.debug then
print(string.format("[%s] Tick - Queue size: %d", ModuleName, #shared.messenger.queue)) -- print(string.format("[%s] Tick - Queue size: %d", ModuleName, #shared.messenger.queue:get()))
end -- end
DoMessage() DoMessage()
shared.messenger.ticker = C_Timer.NewTimer(Heimdall_Data.config.messenger.interval, Tick, 1) shared.messenger.ticker = C_Timer.NewTimer(Heimdall_Data.config.messenger.interval, Tick, 1)
end end
@@ -172,5 +171,6 @@ function shared.Messenger.Init()
) )
) )
end end
print("[Heimdall] Messenger loaded") print(string.format("[%s] Module initialized", ModuleName))
end end,
}

View File

@@ -1,14 +1,42 @@
local _, shared = ... local _, shared = ...
---@cast shared HeimdallShared ---@cast shared HeimdallShared
local ModuleName = "MinimapTagger" local ModuleName = "MinimapTagger"
---@class HeimdallMinimapTaggerConfig
---@field enabled boolean
---@field debug boolean
---@field channels string[]
---@field throttle number
---@field scale number
---@field tagTTL number
---@field tagSound boolean
---@field tagSoundFile string
---@field tagSoundThrottle number
---@field tagTextureFile string
---@field alertTTL number
---@field alertSound boolean
---@field alertSoundFile string
---@field alertSoundThrottle number
---@field alertTextureFile string
---@field combatTTL number
---@field combatSound boolean
---@field combatSoundFile string
---@field combatSoundThrottle number
---@field combatTextureFile string
---@field helpTTL number
---@field helpSound boolean
---@field helpSoundFile string
---@field helpSoundThrottle number
---@field helpTextureFile string
local HeimdallRoot = "Interface\\AddOns\\Heimdall\\" local HeimdallRoot = "Interface\\AddOns\\Heimdall\\"
local SoundRoot = HeimdallRoot .. "Sounds\\" local SoundRoot = HeimdallRoot .. "Sounds\\"
local TextureRoot = HeimdallRoot .. "Texture\\" local TextureRoot = HeimdallRoot .. "Texture\\"
--/run local a=GetChannelName("Agent")local b,c=GetPlayerMapPosition("player")b,c=b*100,c*100;local d=string.format("I need help at %s (%s) [%s](%2.2f, %2.2f)",GetZoneText(),GetSubZoneText(),GetCurrentMapAreaID(),b,c)SendChatMessage(d,"CHANNEL",nil,a) --/run local a=GetChannelName("Agent")local b,c=GetPlayerMapPosition("player")b,c=b*100,c*100;local d=string.format("I need help at %s (%s) [%s](%2.2f, %2.2f)",GetZoneText(),GetSubZoneText(),GetCurrentMapAreaID(),b,c)SendChatMessage(d,"CHANNEL",nil,a)
---@diagnostic disable-next-line: missing-fields ---@class MinimapTagger
shared.MinimapTagger = {} shared.MinimapTagger = {
function shared.MinimapTagger.Init() Init = function()
---@param x number ---@param x number
---@param y number ---@param y number
---@param frame Frame ---@param frame Frame
@@ -445,7 +473,7 @@ function shared.MinimapTagger.Init()
end end
if Heimdall_Data.config.minimapTagger.debug then if Heimdall_Data.config.minimapTagger.debug then
print(string.format("[%s] Processing message from master channel: %s", ModuleName, sender)) print(string.format("[%s] Processing message from master channel: %s", ModuleName, sender))
shared.dumpTable(Heimdall_Data.config.minimapTagger) shared.dump(Heimdall_Data.config.minimapTagger)
end end
local doTag = true local doTag = true
@@ -564,8 +592,6 @@ function shared.MinimapTagger.Init()
--endregion --endregion
end) end)
print("[Heimdall] MinimapTagger loaded") print(string.format("[%s] Module initialized", ModuleName))
end end,
}
SlashCmdList["HEIMDALL_MINIMAPTAGGER"] = function(args) shared.MinimapTagger.Init() end
SLASH_HEIMDALL_MINIMAPTAGGER1 = "/mf"

View File

@@ -2,9 +2,18 @@ local _, shared = ...
---@cast shared HeimdallShared ---@cast shared HeimdallShared
local ModuleName = "Network" local ModuleName = "Network"
---@diagnostic disable-next-line: missing-fields ---@class HeimdallNetworkConfig
shared.Network = {} ---@field enabled boolean
function shared.Network.Init() ---@field debug boolean
---@field members string[]
---@field updateInterval number
---@class HeimdallNetworkData
---@field ticker Timer?
---@class Network
shared.Network = {
Init = function()
if not shared.network then shared.network = {} end if not shared.network then shared.network = {} end
local updatePending = false local updatePending = false
@@ -18,7 +27,9 @@ function shared.Network.Init()
if name then if name then
friends[name] = connected friends[name] = connected
if Heimdall_Data.config.network.debug then if Heimdall_Data.config.network.debug then
print(string.format("[%s] Friend %s is %s", ModuleName, name, connected and "online" or "offline")) print(
string.format("[%s] Friend %s is %s", ModuleName, name, connected and "online" or "offline")
)
end end
else else
if Heimdall_Data.config.network.debug then if Heimdall_Data.config.network.debug then
@@ -50,7 +61,7 @@ function shared.Network.Init()
end end
if Heimdall_Data.config.network.debug then if Heimdall_Data.config.network.debug then
print(string.format("[%s] Network nodes:", ModuleName)) print(string.format("[%s] Network nodes:", ModuleName))
shared.dumpTable(shared.networkNodes) shared.dump(shared.networkNodes)
end end
end end
@@ -69,5 +80,6 @@ function shared.Network.Init()
end end
NetworkTick() NetworkTick()
print("[Heimdall] Network module loaded") print(string.format("[%s] Module initialized", ModuleName))
end end,
}

View File

@@ -2,13 +2,26 @@ local _, shared = ...
---@cast shared HeimdallShared ---@cast shared HeimdallShared
local ModuleName = "NetworkMessenger" local ModuleName = "NetworkMessenger"
---@diagnostic disable-next-line: missing-fields ---@class HeimdallNetworkMessengerConfig
shared.NetworkMessenger = {} ---@field enabled boolean
function shared.NetworkMessenger.Init() ---@field debug boolean
---@field interval number
---@class HeimdallNetworkMessengerData
---@field queue table<string, Message>
---@field ticker Timer?
---@class NetworkMessenger
shared.NetworkMessenger = {
---@param message Message
Enqueue = function(message) table.insert(shared.networkMessenger.queue, message) end,
Init = function()
RegisterAddonMessagePrefix(Heimdall_Data.config.addonPrefix) RegisterAddonMessagePrefix(Heimdall_Data.config.addonPrefix)
if not shared.networkMessenger then shared.networkMessenger = {} end shared.networkMessenger = {
if not shared.networkMessenger.queue then shared.networkMessenger.queue = {} end queue = ReactiveValue.new({}),
}
if not shared.networkMessenger.ticker then if not shared.networkMessenger.ticker then
local function DoMessage() local function DoMessage()
--if Heimdall_Data.config.networkMessenger.debug then --if Heimdall_Data.config.networkMessenger.debug then
@@ -91,7 +104,8 @@ function shared.NetworkMessenger.Init()
-- print(string.format("[%s] Queue check - Network messages pending: %d", ModuleName, queueSize)) -- print(string.format("[%s] Queue check - Network messages pending: %d", ModuleName, queueSize))
--end --end
DoMessage() DoMessage()
shared.networkMessenger.ticker = C_Timer.NewTimer(Heimdall_Data.config.networkMessenger.interval, Tick, 1) shared.networkMessenger.ticker =
C_Timer.NewTimer(Heimdall_Data.config.networkMessenger.interval, Tick, 1)
end end
Tick() Tick()
end end
@@ -131,7 +145,7 @@ function shared.NetworkMessenger.Init()
local parts = shared.Split(message, "|") local parts = shared.Split(message, "|")
if Heimdall_Data.config.networkMessenger.debug then if Heimdall_Data.config.networkMessenger.debug then
print(string.format("[%s] Received message parts:", ModuleName)) print(string.format("[%s] Received message parts:", ModuleName))
shared.dumpTable(parts) shared.dump(parts)
end end
local command = strtrim(parts[1]) local command = strtrim(parts[1])
if command == "message" then if command == "message" then
@@ -140,7 +154,13 @@ function shared.NetworkMessenger.Init()
local target = strtrim(tostring(parts[4])) local target = strtrim(tostring(parts[4]))
if Heimdall_Data.config.networkMessenger.debug then if Heimdall_Data.config.networkMessenger.debug then
print( print(
string.format("[%s] Received message command: %s %s %s", ModuleName, content, targetchannel, target) string.format(
"[%s] Received message command: %s %s %s",
ModuleName,
content,
targetchannel,
target
)
) )
end end
---@type Message ---@type Message
@@ -179,5 +199,6 @@ function shared.NetworkMessenger.Init()
end end
end end
print("[Heimdall] NetworkMessenger module loaded") print(string.format("[%s] Module initialized", ModuleName))
end end,
}

View File

@@ -2,15 +2,21 @@ local _, shared = ...
---@cast shared HeimdallShared ---@cast shared HeimdallShared
local ModuleName = "Noter" local ModuleName = "Noter"
---@class HeimdallNoterConfig
---@field enabled boolean
---@field debug boolean
---@field channels string[]
---@field lastNotes number
---@class Note ---@class Note
---@field source string ---@field source string
---@field for string ---@field for string
---@field date string ---@field date string
---@field note string ---@field note string
---@diagnostic disable-next-line: missing-fields ---@class Noter
shared.Noter = {} shared.Noter = {
function shared.Noter.Init() Init = function()
-- ---Hopefully this will not be necessary -- ---Hopefully this will not be necessary
-- ---@param text string -- ---@param text string
-- ---@param size number -- ---@param size number
@@ -61,14 +67,16 @@ function shared.Noter.Init()
local indices = shared.Split(range, "..") local indices = shared.Split(range, "..")
if Heimdall_Data.config.noter.debug then if Heimdall_Data.config.noter.debug then
print(string.format("[%s] Indices for range deletion: %s", ModuleName, table.concat(indices, ", "))) print(string.format("[%s] Indices for range deletion: %s", ModuleName, table.concat(indices, ", ")))
shared.dumpTable(indices) shared.dump(indices)
end end
local start = tonumber(indices[1]) local start = tonumber(indices[1])
local finish = tonumber(indices[2]) local finish = tonumber(indices[2])
if not start then if not start then
if Heimdall_Data.config.noter.debug then if Heimdall_Data.config.noter.debug then
print(string.format("[%s] Invalid start range for delete note: %s", ModuleName, tostring(start))) print(
string.format("[%s] Invalid start range for delete note: %s", ModuleName, tostring(start))
)
end end
return return
end end
@@ -90,7 +98,7 @@ function shared.Noter.Init()
else else
if Heimdall_Data.config.noter.debug then if Heimdall_Data.config.noter.debug then
print(string.format("[%s] Deleting note %s at index %s", ModuleName, name, i)) print(string.format("[%s] Deleting note %s at index %s", ModuleName, name, i))
shared.dumpTable(Heimdall_Data.config.notes[name][i]) shared.dump(Heimdall_Data.config.notes[name][i])
end end
Heimdall_Data.config.notes[name][i] = nil Heimdall_Data.config.notes[name][i] = nil
end end
@@ -113,8 +121,11 @@ function shared.Noter.Init()
data = channel, data = channel,
message = string.format("[%s][%d] %s: %s", note.source, index, note.date, note.note), message = string.format("[%s][%d] %s: %s", note.source, index, note.date, note.note),
} }
--table.insert(shared.messenger.queue, msg) if Heimdall_Data.config.networkMessenger.enabled then
table.insert(shared.networkMessenger.queue, msg) shared.NetworkMessenger.Enqueue(msg)
elseif Heimdall_Data.config.messenger.enabled then
shared.Messenger.Enqueue(msg)
end
end end
---@param name string ---@param name string
---@param args string[] ---@param args string[]
@@ -151,7 +162,7 @@ function shared.Noter.Init()
local indices = shared.Split(range, "..") local indices = shared.Split(range, "..")
if Heimdall_Data.config.noter.debug then if Heimdall_Data.config.noter.debug then
print(string.format("[%s] Indices for range printing: %s", ModuleName, table.concat(indices, ", "))) print(string.format("[%s] Indices for range printing: %s", ModuleName, table.concat(indices, ", ")))
shared.dumpTable(indices) shared.dump(indices)
end end
local start = tonumber(indices[1]) local start = tonumber(indices[1])
local finish = tonumber(indices[2]) local finish = tonumber(indices[2])
@@ -177,7 +188,7 @@ function shared.Noter.Init()
else else
if Heimdall_Data.config.noter.debug then if Heimdall_Data.config.noter.debug then
print(string.format("[%s] Printing note %s at index %s", ModuleName, name, i)) print(string.format("[%s] Printing note %s at index %s", ModuleName, name, i))
shared.dumpTable(Heimdall_Data.config.notes[name][i]) shared.dump(Heimdall_Data.config.notes[name][i])
end end
PrintNote(channel, i, Heimdall_Data.config.notes[name][i]) PrintNote(channel, i, Heimdall_Data.config.notes[name][i])
end end
@@ -192,7 +203,7 @@ function shared.Noter.Init()
if not Heimdall_Data.config.notes[name] then Heimdall_Data.config.notes[name] = {} end if not Heimdall_Data.config.notes[name] then Heimdall_Data.config.notes[name] = {} end
if Heimdall_Data.config.noter.debug then if Heimdall_Data.config.noter.debug then
print(string.format("[%s] Adding note for: %s from: %s", ModuleName, name, sender)) print(string.format("[%s] Adding note for: %s from: %s", ModuleName, name, sender))
shared.dumpTable(args) shared.dump(args)
end end
local msgparts = {} local msgparts = {}
for i = 3, #args do for i = 3, #args do
@@ -213,7 +224,7 @@ function shared.Noter.Init()
if Heimdall_Data.config.noter.debug then if Heimdall_Data.config.noter.debug then
print(string.format("[%s] Adding note", ModuleName)) print(string.format("[%s] Adding note", ModuleName))
shared.dumpTable(note) shared.dump(note)
end end
table.insert(Heimdall_Data.config.notes[name], note) table.insert(Heimdall_Data.config.notes[name], note)
end end
@@ -231,7 +242,7 @@ function shared.Noter.Init()
noterChannelFrame:SetScript("OnEvent", function(self, event, msg, sender, ...) noterChannelFrame:SetScript("OnEvent", function(self, event, msg, sender, ...)
--if Heimdall_Data.config.noter.debug then --if Heimdall_Data.config.noter.debug then
-- print(string.format("[%s] Event received", ModuleName)) -- print(string.format("[%s] Event received", ModuleName))
-- shared.dumpTable(Heimdall_Data.config.noter) -- shared.dump(Heimdall_Data.config.noter)
--end --end
if not Heimdall_Data.config.noter.enabled then if not Heimdall_Data.config.noter.enabled then
--if Heimdall_Data.config.noter.debug then --if Heimdall_Data.config.noter.debug then
@@ -258,7 +269,7 @@ function shared.Noter.Init()
sender = string.match(sender, "^[^-]+") sender = string.match(sender, "^[^-]+")
if Heimdall_Data.config.noter.debug then if Heimdall_Data.config.noter.debug then
print(string.format("[%s] Message from: %s", ModuleName, sender)) print(string.format("[%s] Message from: %s", ModuleName, sender))
shared.dumpTable(Heimdall_Data.config.noter) shared.dump(Heimdall_Data.config.noter)
end end
if not msg or msg == "" then if not msg or msg == "" then
@@ -271,7 +282,7 @@ function shared.Noter.Init()
local args = { strsplit(" ", msg) } local args = { strsplit(" ", msg) }
if Heimdall_Data.config.noter.debug then if Heimdall_Data.config.noter.debug then
print(string.format("[%s] Arguments received: %s", ModuleName, table.concat(args, ", "))) print(string.format("[%s] Arguments received: %s", ModuleName, table.concat(args, ", ")))
shared.dumpTable(args) shared.dump(args)
end end
local command = args[1] local command = args[1]
if command == "note" then if command == "note" then
@@ -291,5 +302,6 @@ function shared.Noter.Init()
end end
end) end)
print("[Heimdall] Commander module loaded") print(string.format("[%s] Module initialized", ModuleName))
end end,
}

View File

@@ -483,7 +483,7 @@ local function Init()
-- S local clbk = test:onChange(function(value) -- S local clbk = test:onChange(function(value)
-- S invocations = invocations + 1 -- S invocations = invocations + 1
-- S print("test changed to") -- S print("test changed to")
-- S dumpTable(value, 0) -- S dump(value, 0)
-- S end) -- S end)
-- S test:set({1, 2, 3, 4}) -- S test:set({1, 2, 3, 4})
-- S assert(invocations == 1) -- S assert(invocations == 1)
@@ -516,7 +516,7 @@ local function Init()
-- S test:once(function(value) -- S test:once(function(value)
-- S invocations = invocations + 1 -- S invocations = invocations + 1
-- S print("test changed to") -- S print("test changed to")
-- S dumpTable(value, 0) -- S dump(value, 0)
-- S end) -- S end)
-- S test:set({3, 2, 1}) -- S test:set({3, 2, 1})
-- S assert(invocations == 1) -- S assert(invocations == 1)
@@ -527,7 +527,7 @@ local function Init()
-- S test:onChange(function(value) -- S test:onChange(function(value)
-- S invocations = invocations + 1 -- S invocations = invocations + 1
-- S print("test changed to") -- S print("test changed to")
-- S dumpTable(value, 0) -- S dump(value, 0)
-- S end) -- S end)
-- S test:onAnyFieldChange(function(field, value) -- S test:onAnyFieldChange(function(field, value)
-- S invocations = invocations + 1 -- S invocations = invocations + 1

View File

@@ -2,15 +2,23 @@ local _, shared = ...
---@cast shared HeimdallShared ---@cast shared HeimdallShared
local ModuleName = "Sniffer" local ModuleName = "Sniffer"
---@diagnostic disable-next-line: missing-fields ---@class HeimdallSnifferConfig
shared.Sniffer = {} ---@field enabled boolean
function shared.Sniffer.Init() ---@field debug boolean
---@field channels string[]
---@field throttle number -- throttleTime in the original code, matching config name now
---@field zoneOverride string?
---@field stinky boolean
---@class Sniffer
shared.Sniffer = {
Init = function()
if Heimdall_Data.config.sniffer.debug then print(string.format("[%s] Module initializing", ModuleName)) end if Heimdall_Data.config.sniffer.debug then print(string.format("[%s] Module initializing", ModuleName)) end
local smellThrottle = {} local smellThrottle = {}
local SmellStinky = function(stinky) local SmellStinky = function(stinky)
if Heimdall_Data.config.sniffer.debug then if Heimdall_Data.config.sniffer.debug then
print(string.format("%s: SmellStinky", ModuleName)) print(string.format("%s: SmellStinky", ModuleName))
shared.dumpTable(Heimdall_Data.config.sniffer) shared.dump(Heimdall_Data.config.sniffer)
end end
if not Heimdall_Data.config.sniffer.enabled then return end if not Heimdall_Data.config.sniffer.enabled then return end
if Heimdall_Data.config.sniffer.stinky and not shared.IsStinky(stinky) then if Heimdall_Data.config.sniffer.stinky and not shared.IsStinky(stinky) then
@@ -19,7 +27,7 @@ function shared.Sniffer.Init()
end end
return return
end end
if smellThrottle[stinky] and GetTime() - smellThrottle[stinky] < Heimdall_Data.config.sniffer.throttleTime then if smellThrottle[stinky] and GetTime() - smellThrottle[stinky] < Heimdall_Data.config.sniffer.throttle then
if Heimdall_Data.config.sniffer.debug then print(string.format("%s: Throttled", ModuleName)) end if Heimdall_Data.config.sniffer.debug then print(string.format("%s: Throttled", ModuleName)) end
return return
end end
@@ -36,7 +44,7 @@ function shared.Sniffer.Init()
} }
if Heimdall_Data.config.sniffer.debug then if Heimdall_Data.config.sniffer.debug then
print(string.format("[%s] Queuing sniffer message", ModuleName)) print(string.format("[%s] Queuing sniffer message", ModuleName))
shared.dumpTable(msg) shared.dump(msg)
end end
table.insert(shared.messenger.queue, msg) table.insert(shared.messenger.queue, msg)
end end
@@ -79,5 +87,6 @@ function shared.Sniffer.Init()
SmellStinky(destination) SmellStinky(destination)
end) end)
if Heimdall_Data.config.sniffer.debug then print(string.format("[%s] Module initialized", ModuleName)) end if Heimdall_Data.config.sniffer.debug then print(string.format("[%s] Module initialized", ModuleName)) end
print("[Heimdall] Sniffer loaded") print(string.format("[%s] Module initialized", ModuleName))
end end,
}

View File

@@ -2,9 +2,20 @@ local _, shared = ...
---@cast shared HeimdallShared ---@cast shared HeimdallShared
local ModuleName = "Spotter" local ModuleName = "Spotter"
---@diagnostic disable-next-line: missing-fields ---@class HeimdallSpotterConfig
shared.Spotter = {} ---@field enabled boolean
function shared.Spotter.Init() ---@field debug boolean
---@field everyone boolean
---@field hostile boolean
---@field alliance boolean
---@field stinky boolean
---@field channels string[]
---@field zoneOverride string?
---@field throttleTime number
---@class Spotter
shared.Spotter = {
Init = function()
local function FormatHP(hp) local function FormatHP(hp)
if hp > 1e9 then if hp > 1e9 then
return string.format("%.1fB", hp / 1e9) return string.format("%.1fB", hp / 1e9)
@@ -31,7 +42,7 @@ function shared.Spotter.Init()
print(string.format("[%s] Checking notification criteria for %s (%s)", ModuleName, name, faction)) print(string.format("[%s] Checking notification criteria for %s (%s)", ModuleName, name, faction))
end end
if Heimdall_Data.config.agents[name] then if shared.AgentTracker.IsAgent(name) then
if Heimdall_Data.config.spotter.debug then if Heimdall_Data.config.spotter.debug then
print(string.format("[%s] Skipping agent: %s", ModuleName, name)) print(string.format("[%s] Skipping agent: %s", ModuleName, name))
end end
@@ -102,7 +113,9 @@ function shared.Spotter.Init()
if throttleTable[name] and time - throttleTable[name] < Heimdall_Data.config.spotter.throttleTime then if throttleTable[name] and time - throttleTable[name] < Heimdall_Data.config.spotter.throttleTime then
if Heimdall_Data.config.spotter.debug then if Heimdall_Data.config.spotter.debug then
local remainingTime = Heimdall_Data.config.spotter.throttleTime - (time - throttleTable[name]) local remainingTime = Heimdall_Data.config.spotter.throttleTime - (time - throttleTable[name])
print(string.format("[%s] Player %s throttled for %.1f more seconds", ModuleName, name, remainingTime)) print(
string.format("[%s] Player %s throttled for %.1f more seconds", ModuleName, name, remainingTime)
)
end end
return string.format("Throttled %s", tostring(name)) return string.format("Throttled %s", tostring(name))
end end
@@ -188,7 +201,7 @@ function shared.Spotter.Init()
} }
if Heimdall_Data.config.spotter.debug then if Heimdall_Data.config.spotter.debug then
print(string.format("[%s] Queuing spotter message", ModuleName)) print(string.format("[%s] Queuing spotter message", ModuleName))
shared.dumpTable(msg) shared.dump(msg)
end end
table.insert(shared.messenger.queue, msg) table.insert(shared.messenger.queue, msg)
end end
@@ -220,5 +233,6 @@ function shared.Spotter.Init()
end) end)
if Heimdall_Data.config.spotter.debug then print(string.format("[%s] Module initialized", ModuleName)) end if Heimdall_Data.config.spotter.debug then print(string.format("[%s] Module initialized", ModuleName)) end
print("[Heimdall] Spotter loaded") print(string.format("[%s] Module initialized", ModuleName))
end end,
}

View File

@@ -1,11 +1,19 @@
local addonname, shared = ... local _, shared = ...
---@cast shared HeimdallShared ---@cast shared HeimdallShared
---@cast addonname string
local ModuleName = "StinkyCache" local ModuleName = "StinkyCache"
---@diagnostic disable-next-line: missing-fields ---@class HeimdallStinkyCacheConfig
shared.StinkyCache = {} ---@field enabled boolean
function shared.StinkyCache.Init() ---@field debug boolean
---@field commander string
---@field ttl number
---@class HeimdallStinkyCacheData
---@field stinkies table<string, {value: number, timestamp: number}>
---@class StinkyCache
shared.StinkyCache = {
Init = function()
shared.stinkyCache = { shared.stinkyCache = {
stinkies = {}, stinkies = {},
} }
@@ -64,9 +72,12 @@ function shared.StinkyCache.Init()
__index = function(self, key) __index = function(self, key)
local value = rawget(self, key) local value = rawget(self, key)
local now = GetTime() local now = GetTime()
if value == nil or now - value.timestamp > Heimdall_Data.config.stinkyCache.ttl then AskCommander(key) end if value == nil or now - value.timestamp > Heimdall_Data.config.stinkyCache.ttl then
AskCommander(key)
end
return rawget(self, key) return rawget(self, key)
end, end,
}) })
print("[Heimdall] StinkyCache module loaded") print(string.format("[%s] Module initialized", ModuleName))
end end,
}

View File

@@ -2,16 +2,107 @@ local _, shared = ...
---@cast shared HeimdallShared ---@cast shared HeimdallShared
local ModuleName = "StinkyTracker" local ModuleName = "StinkyTracker"
---@diagnostic disable-next-line: missing-fields ---@class Stinky
shared.StinkyTracker = {} ---@field name string
function shared.StinkyTracker.Init() ---@field class string
---@field seenAt number
---@field hostile boolean
---@class HeimdallStinkyTrackerConfig
---@field enabled boolean
---@field debug boolean
---@field ignoredTimeout number
---@field channels string[]
---@class StinkyTrackerData
---@field stinkies ReactiveValue<table<string, Stinky>>
---@field ignored ReactiveValue<table<string, number>>
---@class StinkyTracker
shared.StinkyTracker = {
---@param stinky Stinky
---@return boolean
Track = function(stinky)
if Heimdall_Data.config.stinkyTracker.debug then
print(string.format("[%s] Request to track stinky: %s (%s)", ModuleName, stinky.name, stinky.class))
end
local ignored = shared.stinkyTracker.ignored[stinky.name]
-- TODO: Add a config option for the ignored timeout
if ignored and ignored > GetTime() - 60 then
if Heimdall_Data.config.stinkyTracker.debug then
print(
string.format(
"[%s] Stinky is ignored, not tracking: %s (%s)",
ModuleName,
stinky.name,
stinky.class
)
)
shared.dump(shared.stinkyTracker.ignored:get())
shared.dump(shared.stinkyTracker.stinkies:get())
end
return false
else
-- Timed out or was never ignored
shared.stinkyTracker.stinkies[stinky.name] = nil
end
shared.stinkyTracker.stinkies[stinky.name] = stinky
if Heimdall_Data.config.stinkyTracker.debug then
print(string.format("[%s] Stinky is now tracked: %s (%s)", ModuleName, stinky.name, stinky.class))
shared.dump(shared.stinkyTracker.stinkies:get())
shared.dump(shared.stinkyTracker.ignored:get())
end
return true
end,
---@param name string
---@return nil
Ignore = function(name)
if Heimdall_Data.config.stinkyTracker.debug then
print(string.format("[%s] Request to ignore stinky: %s", ModuleName, name))
end
shared.stinkyTracker.ignored[name] = GetTime()
shared.stinkyTracker.stinkies[name] = nil
if Heimdall_Data.config.stinkyTracker.debug then
print(string.format("[%s] Stinky is now ignored: %s", ModuleName, name))
shared.dump(shared.stinkyTracker.ignored:get())
shared.dump(shared.stinkyTracker.stinkies:get())
end
end,
---@param name string
---@return boolean
IsStinky = function(name)
if not shared.stinkyTracker.stinkies then return false end
if not shared.stinkyTracker.stinkies[name] then return false end
if shared.stinkyTracker.ignored[name] then return false end
return true
end,
---@param callback fun(stinkies: table<string, Stinky>)
---@return nil
OnChange = function(callback) shared.stinkyTracker.stinkies:onChange(callback) end,
---@param callback fun(name: string, stinky: Stinky)
---@return nil
ForEach = function(callback)
---@type table<string, Stinky>
local stinkies = shared.stinkyTracker.stinkies:get()
for name, stinky in pairs(stinkies) do
callback(name, stinky)
end
end,
Init = function()
shared.stinkyTracker = { shared.stinkyTracker = {
stinkies = ReactiveValue.new({}), stinkies = ReactiveValue.new({}),
ignored = ReactiveValue.new({}),
} }
local whoRegex = "([^ -/]+)-?%w*/(%w+)" local whoRegex = "([^ -/]+)-?%w*/(%w+)"
---@param msg string ---@param msg string
---@return table<string, stinky> ---@return table<string, Stinky>
local function ParseWho(msg) local function ParseWho(msg)
if Heimdall_Data.config.stinkyTracker.debug then if Heimdall_Data.config.stinkyTracker.debug then
print(string.format("[%s] Parsing WHO message: '%s'", ModuleName, msg)) print(string.format("[%s] Parsing WHO message: '%s'", ModuleName, msg))
@@ -34,7 +125,7 @@ function shared.StinkyTracker.Init()
date("%H:%M:%S", time()) date("%H:%M:%S", time())
) )
) )
shared.dumpTable(stinkies) shared.dump(stinkies)
end end
end end
return stinkies return stinkies
@@ -42,7 +133,7 @@ function shared.StinkyTracker.Init()
local seeRegex = "I see %((%w+)%) ([^ -/]+)-?%w*/(%w+)" local seeRegex = "I see %((%w+)%) ([^ -/]+)-?%w*/(%w+)"
---@param msg string ---@param msg string
---@return table<string, stinky> ---@return table<string, Stinky>
local function ParseSee(msg) local function ParseSee(msg)
if Heimdall_Data.config.stinkyTracker.debug then if Heimdall_Data.config.stinkyTracker.debug then
print(string.format("[%s] Parsing SEE message: '%s'", ModuleName, msg)) print(string.format("[%s] Parsing SEE message: '%s'", ModuleName, msg))
@@ -73,7 +164,7 @@ function shared.StinkyTracker.Init()
date("%H:%M:%S", time()) date("%H:%M:%S", time())
) )
) )
shared.dumpTable(stinkies) shared.dump(stinkies)
end end
return stinkies return stinkies
end end
@@ -81,7 +172,7 @@ function shared.StinkyTracker.Init()
local arrivedRegex = "([^ -/]+)-?%w*; c:([^;]+)" local arrivedRegex = "([^ -/]+)-?%w*; c:([^;]+)"
local arrivedRegexAlt = "([^ -/]+)-?%w*%(!!!!%); c:([^;]+)" local arrivedRegexAlt = "([^ -/]+)-?%w*%(!!!!%); c:([^;]+)"
---@param msg string ---@param msg string
---@return table<string, stinky> ---@return table<string, Stinky>
local function ParseArrived(msg) local function ParseArrived(msg)
if Heimdall_Data.config.stinkyTracker.debug then if Heimdall_Data.config.stinkyTracker.debug then
print(string.format("%s: Parsing arrived message: %s", ModuleName, msg)) print(string.format("%s: Parsing arrived message: %s", ModuleName, msg))
@@ -106,7 +197,7 @@ function shared.StinkyTracker.Init()
stinkies[name] = stinky stinkies[name] = stinky
if Heimdall_Data.config.stinkyTracker.debug then if Heimdall_Data.config.stinkyTracker.debug then
print(string.format("%s: Found stinky in arrived: %s/%s", ModuleName, name, class)) print(string.format("%s: Found stinky in arrived: %s/%s", ModuleName, name, class))
shared.dumpTable(stinkies) shared.dump(stinkies)
end end
return stinkies return stinkies
end end
@@ -140,9 +231,10 @@ function shared.StinkyTracker.Init()
end end
if Heimdall_Data.config.stinkyTracker.debug then if Heimdall_Data.config.stinkyTracker.debug then
print(string.format("[%s] Processing message from master channel: %s", ModuleName, sender)) print(string.format("[%s] Processing message from master channel: %s", ModuleName, sender))
shared.dumpTable(Heimdall_Data.config.stinkyTracker) shared.dump(Heimdall_Data.config.stinkyTracker)
end end
local stinkies = {}
if string.find(msg, "^who:") then if string.find(msg, "^who:") then
if Heimdall_Data.config.stinkyTracker.debug then if Heimdall_Data.config.stinkyTracker.debug then
print(string.format("[%s] Processing WHO message from %s", ModuleName, sender)) print(string.format("[%s] Processing WHO message from %s", ModuleName, sender))
@@ -150,16 +242,10 @@ function shared.StinkyTracker.Init()
local whoStinkies = ParseWho(msg) local whoStinkies = ParseWho(msg)
if Heimdall_Data.config.stinkyTracker.debug then if Heimdall_Data.config.stinkyTracker.debug then
print(string.format("[%s] Found stinkies in WHO message", ModuleName)) print(string.format("[%s] Found stinkies in WHO message", ModuleName))
shared.dump(whoStinkies)
end end
for name, stinky in pairs(whoStinkies) do for name, stinky in pairs(whoStinkies) do
if stinky.hostile then stinkies[name] = stinky
shared.stinkyTracker.stinkies[name] = stinky
if Heimdall_Data.config.stinkyTracker.debug then
print(
string.format("[%s] Added hostile stinky from WHO: %s (%s)", ModuleName, name, stinky.class)
)
end
end
end end
end end
if string.find(msg, "^I see") then if string.find(msg, "^I see") then
@@ -169,22 +255,10 @@ function shared.StinkyTracker.Init()
local seeStinkies = ParseSee(msg) local seeStinkies = ParseSee(msg)
if Heimdall_Data.config.stinkyTracker.debug then if Heimdall_Data.config.stinkyTracker.debug then
print(string.format("[%s] Found stinkies in SEE message", ModuleName)) print(string.format("[%s] Found stinkies in SEE message", ModuleName))
shared.dump(seeStinkies)
end end
for name, stinky in pairs(seeStinkies) do for name, stinky in pairs(seeStinkies) do
if stinky.hostile then stinkies[name] = stinky
shared.stinkyTracker.stinkies[name] = stinky
if Heimdall_Data.config.stinkyTracker.debug then
print(
string.format("[%s] Added hostile stinky from SEE: %s (%s)", ModuleName, name, stinky.class)
)
end
end
if not stinky.hostile then
shared.stinkyTracker.stinkies[name] = nil
if Heimdall_Data.config.stinkyTracker.debug then
print(string.format("[%s] Removed non-hostile stinky from SEE: %s", ModuleName, name))
end
end
end end
end end
if string.find(msg, "arrived to") or string.find(msg, "moved to") then if string.find(msg, "arrived to") or string.find(msg, "moved to") then
@@ -194,11 +268,23 @@ function shared.StinkyTracker.Init()
local arrivedStinkies = ParseArrived(msg) local arrivedStinkies = ParseArrived(msg)
if Heimdall_Data.config.stinkyTracker.debug then if Heimdall_Data.config.stinkyTracker.debug then
print(string.format("[%s] Found stinkies in ARRIVED message", ModuleName)) print(string.format("[%s] Found stinkies in ARRIVED message", ModuleName))
shared.dump(arrivedStinkies)
end end
for name, stinky in pairs(arrivedStinkies) do for name, stinky in pairs(arrivedStinkies) do
stinkies[name] = stinky
end
end
for name, stinky in pairs(stinkies) do
if shared.stinkyTracker.ignored[name] then
if Heimdall_Data.config.stinkyTracker.debug then
print(string.format("[%s] Ignoring stinky: %s (%s)", ModuleName, name, stinky.class))
end
shared.stinkyTracker.ignored[name] = nil
else
shared.stinkyTracker.stinkies[name] = stinky shared.stinkyTracker.stinkies[name] = stinky
if Heimdall_Data.config.stinkyTracker.debug then if Heimdall_Data.config.stinkyTracker.debug then
print(string.format("[%s] Added stinky from ARRIVED: %s (%s)", ModuleName, name, stinky.class)) print(string.format("[%s] Added stinky: %s (%s)", ModuleName, name, stinky.class))
end end
end end
end end
@@ -212,14 +298,14 @@ function shared.StinkyTracker.Init()
print(string.format("[%s] Current total stinkies tracked: %d", ModuleName, count)) print(string.format("[%s] Current total stinkies tracked: %d", ModuleName, count))
end end
for name, stinky in pairs(shared.stinkyTracker.stinkies) do shared.StinkyTracker.ForEach(function(name, stinky)
if Heimdall_Data.config.agents[name] then if shared.AgentTracker.IsAgent(name) then
shared.stinkyTracker.stinkies[name] = nil shared.stinkyTracker.stinkies[name] = nil
if Heimdall_Data.config.stinkyTracker.debug then if Heimdall_Data.config.stinkyTracker.debug then
print(string.format("[%s] Removed agent from stinkies: %s", ModuleName, name)) print(string.format("[%s] Removed agent from stinkies: %s", ModuleName, name))
end end
end end
end end)
end) end)
local targetFrame = CreateFrame("Frame") local targetFrame = CreateFrame("Frame")
@@ -273,5 +359,6 @@ function shared.StinkyTracker.Init()
end) end)
if Heimdall_Data.config.stinkyTracker.debug then print(string.format("[%s] Module initialized", ModuleName)) end if Heimdall_Data.config.stinkyTracker.debug then print(string.format("[%s] Module initialized", ModuleName)) end
print("[Heimdall] StinkyTracker loaded") print(string.format("[%s] Module initialized", ModuleName))
end end,
}

View File

@@ -2,9 +2,24 @@ local _, shared = ...
---@cast shared HeimdallShared ---@cast shared HeimdallShared
local ModuleName = "Whoer" local ModuleName = "Whoer"
---@diagnostic disable-next-line: missing-fields ---@class HeimdallWhoConfig
shared.Whoer = {} ---@field enabled boolean
function shared.Whoer.Init() ---@field debug boolean
---@field ignored table<string, boolean>
---@field channels string[]
---@field ttl number
---@field doWhisper boolean
---@field zoneNotifyFor table<string, boolean>
---@field queries string
---@class HeimdallWhoData
---@field updateTicker Timer?
---@field whoTicker Timer?
local whoWaiting = false
---@class Whoer
shared.Whoer = {
Init = function()
if not Heimdall_Data.who then Heimdall_Data.who = {} end if not Heimdall_Data.who then Heimdall_Data.who = {} end
if not Heimdall_Data.who.data then Heimdall_Data.who.data = {} end if not Heimdall_Data.who.data then Heimdall_Data.who.data = {} end
@@ -161,7 +176,7 @@ function shared.Whoer.Init()
if Heimdall_Data.config.who.debug then if Heimdall_Data.config.who.debug then
print(string.format("[%s] WHO query: %s with %d filters", ModuleName, queryParts[1], #filters)) print(string.format("[%s] WHO query: %s with %d filters", ModuleName, queryParts[1], #filters))
end end
shared.dumpTable(filters) shared.dump(filters)
return WHOQuery.new(queryParts[1], filters) return WHOQuery.new(queryParts[1], filters)
end, end,
---@param queryStr string ---@param queryStr string
@@ -184,12 +199,19 @@ function shared.Whoer.Init()
print(string.format("[%s] ShouldNotifyForZone %s", ModuleName, inputZone)) print(string.format("[%s] ShouldNotifyForZone %s", ModuleName, inputZone))
end end
for zone, _ in pairs(Heimdall_Data.config.who.zoneNotifyFor) do for zone, _ in pairs(Heimdall_Data.config.who.zoneNotifyFor) do
if Heimdall_Data.config.who.debug then print(string.format("[%s] Checking zone %s", ModuleName, zone)) end if Heimdall_Data.config.who.debug then
print(string.format("[%s] Checking zone %s", ModuleName, zone))
end
if zone == "*" then return true end if zone == "*" then return true end
if string.find(inputZone, zone) then if string.find(inputZone, zone) then
if not Heimdall_Data.config.who.debug then if not Heimdall_Data.config.who.debug then
print( print(
string.format("[%s] ShouldNotifyForZone %s is true thanks to %s", ModuleName, inputZone, zone) string.format(
"[%s] ShouldNotifyForZone %s is true thanks to %s",
ModuleName,
inputZone,
zone
)
) )
end end
return true return true
@@ -269,7 +291,11 @@ function shared.Whoer.Init()
--if not Heimdall_Data.config.who.zoneNotifyFor[player.zone] then --if not Heimdall_Data.config.who.zoneNotifyFor[player.zone] then
if Heimdall_Data.config.who.debug then if Heimdall_Data.config.who.debug then
print( print(
string.format("[%s] Skipping notification - Zone '%s' not in notify list", ModuleName, player.zone) string.format(
"[%s] Skipping notification - Zone '%s' not in notify list",
ModuleName,
player.zone
)
) )
end end
return string.format("Not notifying for zone %s", tostring(player.zone)) return string.format("Not notifying for zone %s", tostring(player.zone))
@@ -295,9 +321,13 @@ function shared.Whoer.Init()
} }
if Heimdall_Data.config.who.debug then if Heimdall_Data.config.who.debug then
print(string.format("[%s] Queuing channel notification", ModuleName)) print(string.format("[%s] Queuing channel notification", ModuleName))
shared.dumpTable(msg) shared.dump(msg)
end
if Heimdall_Data.config.networkMessenger.enabled then
shared.NetworkMessenger.Enqueue(msg)
elseif Heimdall_Data.config.messenger.enabled then
shared.Messenger.Enqueue(msg)
end end
table.insert(shared.networkMessenger.queue, msg)
end end
--if Heimdall_Data.config.who.doWhisper then --if Heimdall_Data.config.who.doWhisper then
@@ -354,9 +384,13 @@ function shared.Whoer.Init()
} }
if Heimdall_Data.config.who.debug then if Heimdall_Data.config.who.debug then
print(string.format("[%s] Queuing channel notification", ModuleName)) print(string.format("[%s] Queuing channel notification", ModuleName))
shared.dumpTable(msg) shared.dump(msg)
end
if Heimdall_Data.config.networkMessenger.enabled then
shared.NetworkMessenger.Enqueue(msg)
elseif Heimdall_Data.config.messenger.enabled then
shared.Messenger.Enqueue(msg)
end end
table.insert(shared.networkMessenger.queue, msg)
end end
--if Heimdall_Data.config.who.doWhisper then --if Heimdall_Data.config.who.doWhisper then
@@ -405,10 +439,13 @@ function shared.Whoer.Init()
} }
if Heimdall_Data.config.who.debug then if Heimdall_Data.config.who.debug then
print(string.format("[%s] Queuing channel notification", ModuleName)) print(string.format("[%s] Queuing channel notification", ModuleName))
shared.dumpTable(msg) shared.dump(msg)
end
if Heimdall_Data.config.networkMessenger.enabled then
shared.NetworkMessenger.Enqueue(msg)
elseif Heimdall_Data.config.messenger.enabled then
shared.Messenger.Enqueue(msg)
end end
--table.insert(shared.messenger.queue, msg)
table.insert(shared.networkMessenger.queue, msg)
end end
--if Heimdall_Data.config.who.doWhisper then --if Heimdall_Data.config.who.doWhisper then
@@ -432,7 +469,9 @@ function shared.Whoer.Init()
frame:SetScript("OnEvent", function(self, event, ...) frame:SetScript("OnEvent", function(self, event, ...)
if Heimdall_Data.config.who.debug then if Heimdall_Data.config.who.debug then
print(string.format("[%s] WHO list update received", ModuleName)) print(string.format("[%s] WHO list update received", ModuleName))
print(string.format("[%s] Query index: %d/%d", ModuleName, whoQueryIdx, #shared.WhoQueryService.queries)) print(
string.format("[%s] Query index: %d/%d", ModuleName, whoQueryIdx, #shared.WhoQueryService.queries)
)
end end
if not Heimdall_Data.config.who.enabled then if not Heimdall_Data.config.who.enabled then
@@ -460,7 +499,15 @@ function shared.Whoer.Init()
local name, guild, level, race, class, zone = GetWhoInfo(i) local name, guild, level, race, class, zone = GetWhoInfo(i)
if Heimdall_Data.config.who.debug then if Heimdall_Data.config.who.debug then
print( print(
string.format("[%s] Processing result %d/%d: %s/%s/%s", ModuleName, i, results, name, class, zone) string.format(
"[%s] Processing result %d/%d: %s/%s/%s",
ModuleName,
i,
results,
name,
class,
zone
)
) )
end end
@@ -470,13 +517,25 @@ function shared.Whoer.Init()
for _, filter in pairs(filters) do for _, filter in pairs(filters) do
if Heimdall_Data.config.who.debug then if Heimdall_Data.config.who.debug then
print( print(
string.format("[%s] Running filter %s on %s/%s/%s", ModuleName, filter.key, name, class, zone) string.format(
"[%s] Running filter %s on %s/%s/%s",
ModuleName,
filter.key,
name,
class,
zone
)
) )
end end
if not filter.Run(name, guild, level, race, class, zone) then if not filter.Run(name, guild, level, race, class, zone) then
if Heimdall_Data.config.who.debug then if Heimdall_Data.config.who.debug then
print( print(
string.format("[%s] Player %s filtered out by WHO filter %s", ModuleName, name, filter.key) string.format(
"[%s] Player %s filtered out by WHO filter %s",
ModuleName,
name,
filter.key
)
) )
end end
continue = true continue = true
@@ -502,7 +561,9 @@ function shared.Whoer.Init()
local player = HeimdallStinkies[name] local player = HeimdallStinkies[name]
if not player then if not player then
if Heimdall_Data.config.who.debug then if Heimdall_Data.config.who.debug then
print(string.format("[%s] New player detected: %s (%s) in %s", ModuleName, name, class, zone)) print(
string.format("[%s] New player detected: %s (%s) in %s", ModuleName, name, class, zone)
)
end end
player = Player.new(name, guild, race, class, zone) player = Player.new(name, guild, race, class, zone)
@@ -530,7 +591,14 @@ function shared.Whoer.Init()
if player.firstSeen == "never" then if player.firstSeen == "never" then
player.firstSeen = timestamp player.firstSeen = timestamp
if Heimdall_Data.config.who.debug then if Heimdall_Data.config.who.debug then
print(string.format("[%s] First time seeing player: %s at %s", ModuleName, name, timestamp)) print(
string.format(
"[%s] First time seeing player: %s at %s",
ModuleName,
name,
timestamp
)
)
end end
end end
@@ -548,7 +616,12 @@ function shared.Whoer.Init()
local err = Notify(player) local err = Notify(player)
if err then if err then
print( print(
string.format("[%s] Error notifying for %s: %s", ModuleName, tostring(name), tostring(err)) string.format(
"[%s] Error notifying for %s: %s",
ModuleName,
tostring(name),
tostring(err)
)
) )
end end
@@ -571,7 +644,9 @@ function shared.Whoer.Init()
) )
end end
local err = NotifyZoneChanged(player, zone) local err = NotifyZoneChanged(player, zone)
if err then print(string.format("Error notifying for %s: %s", tostring(name), tostring(err))) end if err then
print(string.format("Error notifying for %s: %s", tostring(name), tostring(err)))
end
end end
player.zone = zone player.zone = zone
player.lastSeen = timestamp player.lastSeen = timestamp
@@ -583,7 +658,8 @@ function shared.Whoer.Init()
end end
-- Turns out WA cannot do this ( -- Turns out WA cannot do this (
-- aura_env.UpdateMacro() -- aura_env.UpdateMacro()
_G["FriendsFrameCloseButton"]:Click() -- No longer needed with the hook to friends frame show
-- _G["FriendsFrameCloseButton"]:Click()
end) end)
do do
@@ -610,7 +686,10 @@ function shared.Whoer.Init()
local query = shared.WhoQueryService.queries[whoQueryIdx] local query = shared.WhoQueryService.queries[whoQueryIdx]
if not query then if not query then
if Heimdall_Data.config.who.debug then if Heimdall_Data.config.who.debug then
print(string.format("[%s] Error: No WHO query found to run at index %d", ModuleName, whoQueryIdx)) print(
string.format("[%s] Error: No WHO query found to run at index %d", ModuleName, whoQueryIdx)
)
whoQueryIdx = 1
end end
return return
end end
@@ -633,8 +712,10 @@ function shared.Whoer.Init()
whoQueryIdx = whoQueryIdx + 1 whoQueryIdx = whoQueryIdx + 1
if whoQueryIdx > #shared.WhoQueryService.queries then whoQueryIdx = 1 end if whoQueryIdx > #shared.WhoQueryService.queries then whoQueryIdx = 1 end
lastQuery = query lastQuery = query
whoWaiting = true
---@diagnostic disable-next-line: param-type-mismatch ---@diagnostic disable-next-line: param-type-mismatch
SetWhoToUI(1) SetWhoToUI(1)
SetWhoToUI(1)
SendWho(query.query) SendWho(query.query)
end end
local function Tick() local function Tick()
@@ -643,6 +724,12 @@ function shared.Whoer.Init()
end end
Tick() Tick()
end end
local original_FriendsFrame_OnEvent = FriendsFrame_OnEvent
local function my_FriendsFrame_OnEvent(self, event, ...)
if not (event == "WHO_LIST_UPDATE" and whoWaiting) then original_FriendsFrame_OnEvent(self, event, ...) end
end
FriendsFrame_OnEvent = my_FriendsFrame_OnEvent
print("[Heimdall] Whoer loaded") print(string.format("[%s] Module initialized", ModuleName))
end end,
}

2
_L.lua
View File

@@ -90,6 +90,7 @@ shared._Locale = {
updateInterval = "Update Interval", updateInterval = "Update Interval",
networkMessenger = "Network Messenger", networkMessenger = "Network Messenger",
queries = "Who queries", queries = "Who queries",
chatSniffer = "Chat Sniffer",
}, },
ru = { ru = {
bonkDetected = "%s ударил %s (%s)", bonkDetected = "%s ударил %s (%s)",
@@ -175,6 +176,7 @@ shared._Locale = {
updateInterval = "Интервал Обновления", updateInterval = "Интервал Обновления",
networkMessenger = "Сетевой Мессенджер", networkMessenger = "Сетевой Мессенджер",
queries = "Запросы Who", queries = "Запросы Who",
chatSniffer = "Сниффер Чата",
["Orgrimmar"] = "Оргриммар", ["Orgrimmar"] = "Оргриммар",
["Valley of Strength"] = "Долина Силы", ["Valley of Strength"] = "Долина Силы",
["Valley of Trials"] = "Долина Испытаний", ["Valley of Trials"] = "Долина Испытаний",