6 Commits

28 changed files with 172 additions and 32 deletions

View File

@@ -60,6 +60,7 @@ local function init()
---@field StinkyCache StinkyCache
---@field StinkyTracker StinkyTracker
---@field Whoer Whoer
---@field ChatSniffer ChatSniffer
--- Config ---
---@class HeimdallConfig
@@ -83,6 +84,7 @@ local function init()
---@field configurator HeimdallConfiguratorConfig
---@field stinkyCache HeimdallStinkyCacheConfig
---@field achievementSniffer HeimdallAchievementSnifferConfig
---@field chatSniffer HeimdallChatSnifferConfig
---@field whisperNotify table<string, string>
---@field addonPrefix string
---@field stinkies table<string, boolean>
@@ -115,6 +117,10 @@ local function init()
--/run Heimdall_Data.config.who.queries="g-\"БеспредеЛ\"|ally"
Heimdall_Data.config = {
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 = {
enabled = shared.GetOrDefault(Heimdall_Data, { "config", "spotter", "enabled" }, true),
debug = shared.GetOrDefault(Heimdall_Data, { "config", "spotter", "debug" }, false),
@@ -533,6 +539,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

View File

@@ -299,6 +299,6 @@ shared.AchievementSniffer = {
end
Tick()
print("[Heimdall] AchievementSniffer loaded")
print(string.format("[%s] Module initialized", ModuleName))
end,
}

View File

@@ -139,6 +139,6 @@ shared.AgentTracker = {
print(string.format("[%s] Module initialized", ModuleName))
shared.dump(shared.agentTracker.agents:get(), "Agents")
end
print("[Heimdall] AgentTracker loaded")
print(string.format("[%s] Module initialized", ModuleName))
end,
}

View File

@@ -137,6 +137,6 @@ shared.BonkDetector = {
end
end)
print("[Heimdall] BonkDetector loaded")
print(string.format("[%s] Module initialized", ModuleName))
end,
}

View File

@@ -11,6 +11,6 @@ shared.Bully = {
---@return nil
Init = function()
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,
}

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

@@ -136,6 +136,6 @@ shared.CombatAlerter = {
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,
}

View File

@@ -110,6 +110,32 @@ shared.Commander = {
end
return ret
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>
---@return string[]
local function WhoPartitioned(arr)
@@ -123,6 +149,17 @@ shared.Commander = {
end
---@param arr table<string, Player>
---@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 ret = {}
for _, player in pairs(arr) do
@@ -167,6 +204,15 @@ shared.Commander = {
if #res == 0 then return { "No stinkies found" } end
return res
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()
if Heimdall_Data.config.commander.debug then
print(string.format("[%s] Executing: CountPartitionedStinkies", ModuleName))
@@ -288,6 +334,7 @@ shared.Commander = {
local commands = {
{ keywordRe = "^who$", commanderOnly = false, callback = WhoPartitionedStinkies },
{ keywordRe = "^кто$", commanderOnly = false, callback = WhoPartitionedStinkiesRu },
{ keywordRe = "^howmany$", commanderOnly = false, callback = CountPartitionedStinkies },
{ keywordRe = "^classes$", commanderOnly = false, callback = CountClassPartitionedStinkies },
{ keywordRe = "^help$", commanderOnly = false, callback = HelpRu },
@@ -386,6 +433,6 @@ shared.Commander = {
end
end)
print("[Heimdall] Commander module loaded")
print(string.format("[%s] Module initialized", ModuleName))
end,
}

View File

@@ -2660,6 +2660,46 @@ shared.Config = {
channelLocaleConfigFrame:Add(channelLocale, 8, 12)
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()
print("[Heimdall] Config loaded")
end,

View File

@@ -8,5 +8,5 @@ local ModuleName = "Configurator"
---@class Configurator
shared.Configurator = {
Init = function() print(string.format("[Heimdall] %s module loaded", ModuleName)) end,
Init = function() print(string.format("[%s] Module initialized", ModuleName)) end,
}

View File

@@ -263,6 +263,6 @@ shared.DeathReporter = {
)
)
end
print("[Heimdall] DeathReporter loaded")
print(string.format("[%s] Module initialized", ModuleName))
end,
}

View File

@@ -58,6 +58,6 @@ shared.Dueler = {
)
)
end
print("[Heimdall] Dueler loaded")
print(string.format("[%s] Module initialized", ModuleName))
end,
}

View File

@@ -60,6 +60,6 @@ shared.Echoer = {
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,
}

View File

@@ -61,6 +61,6 @@ shared.Emoter = {
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,
}

View File

@@ -270,6 +270,6 @@ shared.Inviter = {
)
)
end
print("[Heimdall] Inviter loaded")
print(string.format("[%s] Module initialized", ModuleName))
end,
}

View File

@@ -96,6 +96,6 @@ shared.Macroer = {
FixMacro(stinkies)
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,
}

View File

@@ -83,10 +83,7 @@ shared.Messenger = {
if not message.channel or message.channel == "" then
if Heimdall_Data.config.messenger.debug then
shared.dump(
message,
string.format("[%s] Invalid message: no channel specified", ModuleName)
)
shared.dump(message, string.format("[%s] Invalid message: no channel specified", ModuleName))
end
return
end
@@ -150,10 +147,7 @@ shared.Messenger = {
shared.dump(message, string.format("[%s] Sending message:", ModuleName))
end
if string.len(message.message) > 255 then
shared.dump(
message,
string.format("[%s] Message too long!!!!: %s", ModuleName, message.message)
)
shared.dump(message, string.format("[%s] Message too long!!!!: %s", ModuleName, message.message))
return
end
SendChatMessage(message.message, message.channel, nil, message.data)
@@ -177,6 +171,6 @@ shared.Messenger = {
)
)
end
print("[Heimdall] Messenger loaded")
print(string.format("[%s] Module initialized", ModuleName))
end,
}

View File

@@ -592,6 +592,6 @@ shared.MinimapTagger = {
--endregion
end)
print("[Heimdall] MinimapTagger loaded")
print(string.format("[%s] Module initialized", ModuleName))
end,
}

View File

@@ -80,6 +80,6 @@ shared.Network = {
end
NetworkTick()
print("[Heimdall] Network module loaded")
print(string.format("[%s] Module initialized", ModuleName))
end,
}

View File

@@ -199,6 +199,6 @@ shared.NetworkMessenger = {
end
end
print("[Heimdall] NetworkMessenger module loaded")
print(string.format("[%s] Module initialized", ModuleName))
end,
}

View File

@@ -302,6 +302,6 @@ shared.Noter = {
end
end)
print("[Heimdall] Commander module loaded")
print(string.format("[%s] Module initialized", ModuleName))
end,
}

View File

@@ -87,6 +87,6 @@ shared.Sniffer = {
SmellStinky(destination)
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,
}

View File

@@ -233,6 +233,6 @@ shared.Spotter = {
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,
}

View File

@@ -78,6 +78,6 @@ shared.StinkyCache = {
return rawget(self, key)
end,
})
print("[Heimdall] StinkyCache module loaded")
print(string.format("[%s] Module initialized", ModuleName))
end,
}

View File

@@ -359,6 +359,6 @@ shared.StinkyTracker = {
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,
}

View File

@@ -730,6 +730,6 @@ shared.Whoer = {
end
FriendsFrame_OnEvent = my_FriendsFrame_OnEvent
print("[Heimdall] Whoer loaded")
print(string.format("[%s] Module initialized", ModuleName))
end,
}

2
_L.lua
View File

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