2 Commits

4 changed files with 48 additions and 3 deletions

View File

@@ -59,6 +59,7 @@ local function init()
---@field StinkyCache InitTable
---@field Configurator InitTable
---@field AchievementSniffer InitTable
---@field ChatSniffer InitTable
--- Config ---
---@class HeimdallConfig
@@ -737,6 +738,7 @@ local function init()
shared.Configurator.Init()
shared.StinkyCache.Init()
shared.AchievementSniffer.Init()
shared.ChatSniffer.Init()
print("Heimdall loaded!")
end

View File

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

40
Modules/ChatSniffer.lua Normal file
View File

@@ -0,0 +1,40 @@
local _, shared = ...
---@cast shared HeimdallShared
local ModuleName = "ChatSniffer"
---@diagnostic disable-next-line: missing-fields
shared.ChatSniffer = {}
function shared.ChatSniffer.Init()
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)
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("[Heimdall] ChatSniffer loaded")
end

View File

@@ -19,11 +19,13 @@ function shared.Sniffer.Init()
end
return
end
if smellThrottle[stinky] and GetTime() - smellThrottle[stinky] < Heimdall_Data.config.sniffer.throttleTime then
local now = GetTime()
local throttle = smellThrottle[stinky] or 0
if now - throttle < Heimdall_Data.config.sniffer.throttle then
if Heimdall_Data.config.sniffer.debug then print(string.format("%s: Throttled", ModuleName)) end
return
end
smellThrottle[stinky] = GetTime()
smellThrottle[stinky] = now
for _, channel in pairs(Heimdall_Data.config.sniffer.channels) do
local locale = shared.GetLocaleForChannel(channel)