Add ChatSniffer module and update saved variables
This commit is contained in:
@@ -59,6 +59,7 @@ local function init()
|
|||||||
---@field StinkyCache InitTable
|
---@field StinkyCache InitTable
|
||||||
---@field Configurator InitTable
|
---@field Configurator InitTable
|
||||||
---@field AchievementSniffer InitTable
|
---@field AchievementSniffer InitTable
|
||||||
|
---@field ChatSniffer InitTable
|
||||||
|
|
||||||
--- Config ---
|
--- Config ---
|
||||||
---@class HeimdallConfig
|
---@class HeimdallConfig
|
||||||
@@ -737,6 +738,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
|
||||||
|
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
## Version: 3.12.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
|
||||||
|
38
Modules/ChatSniffer.lua
Normal file
38
Modules/ChatSniffer.lua
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
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 log = string.format(
|
||||||
|
"%s|%s|%s|%s|%s",
|
||||||
|
tostring(event),
|
||||||
|
tostring(sender),
|
||||||
|
tostring(msg),
|
||||||
|
tostring(language),
|
||||||
|
tostring(channel)
|
||||||
|
)
|
||||||
|
Heimdall_Chat[#Heimdall_Chat + 1] = log
|
||||||
|
end)
|
||||||
|
|
||||||
|
print("[Heimdall] ChatSniffer loaded")
|
||||||
|
end
|
@@ -19,11 +19,13 @@ function shared.Sniffer.Init()
|
|||||||
end
|
end
|
||||||
return
|
return
|
||||||
end
|
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
|
if Heimdall_Data.config.sniffer.debug then print(string.format("%s: Throttled", ModuleName)) end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
smellThrottle[stinky] = GetTime()
|
smellThrottle[stinky] = now
|
||||||
|
|
||||||
for _, channel in pairs(Heimdall_Data.config.sniffer.channels) do
|
for _, channel in pairs(Heimdall_Data.config.sniffer.channels) do
|
||||||
local locale = shared.GetLocaleForChannel(channel)
|
local locale = shared.GetLocaleForChannel(channel)
|
||||||
|
Reference in New Issue
Block a user