whosniffer Notify on detection
This commit is contained in:
@@ -18,6 +18,7 @@ function()
|
||||
["zone"] = zone,
|
||||
}
|
||||
PlaySoundFile("Interface\\Sounds\\Cloak.ogg", "Master")
|
||||
aura_env.Notify(player)
|
||||
end
|
||||
player:Touch()
|
||||
player.zone = zone
|
||||
|
9
FreshShit/WhoSniffer/event4.lua
Normal file
9
FreshShit/WhoSniffer/event4.lua
Normal file
@@ -0,0 +1,9 @@
|
||||
-- TICKER_200
|
||||
function()
|
||||
---@type WHOMessage
|
||||
local message = aura_env.messageQueue[1]
|
||||
if message == nil then return end
|
||||
|
||||
table.remove(aura_env.messageQueue, 1)
|
||||
SendChatMessage(message.message, "WHISPER", nil, message.to)
|
||||
end
|
@@ -7,7 +7,13 @@ if not WeakAurasSaved.Cyka.WhoSniffer then WeakAurasSaved.Cyka.WhoSniffer = {} e
|
||||
---@field classColors table<string, string>
|
||||
---@field whoQuery string
|
||||
---@field ttl number
|
||||
---@field messageQueue WHOMessage[]
|
||||
---@field UpdateMacro fun()
|
||||
---@field Notify fun(string)
|
||||
|
||||
---@class WHOMessage
|
||||
---@field message string
|
||||
---@field to string
|
||||
|
||||
---@param input string
|
||||
---@return number
|
||||
@@ -49,6 +55,7 @@ local function padString(input, targetLength, left)
|
||||
return input
|
||||
end
|
||||
|
||||
aura_env.messageQueue = {}
|
||||
aura_env.ttl = 60
|
||||
aura_env.whoQuery =
|
||||
"z-\"Orgrimmar\" z-\"Durotar\" 110 r-\"Human\" r-\"Dwarf\" r-\"Night Elf\" r-\"Gnome\" r-\"Draenei\" r-\"Worgen\" r-\"Kul Tiran\" r-\"Dark Iron Dwarf\" r-\"Void Elf\" r-\"Lightforged Draenei\" r-\"Mechagnome\""
|
||||
@@ -108,7 +115,8 @@ Player = {
|
||||
self.lastSeen = GetTime()
|
||||
end,
|
||||
ToString = function(self)
|
||||
local out = string.format("%s %s %s", padString(self.name, 16, true), padString(self.guild, 26, false), padString(self.zone, 26, false))
|
||||
local out = string.format("%s %s %s", padString(self.name, 16, true), padString(self.guild, 26, false),
|
||||
padString(self.zone, 26, false))
|
||||
return string.format("|cFF%s%s|r", aura_env.classColors[self.class], out)
|
||||
end
|
||||
}
|
||||
@@ -135,3 +143,37 @@ aura_env.UpdateMacro = function()
|
||||
end
|
||||
EditMacro("tar", nil, nil, string.join("\n", body))
|
||||
end
|
||||
|
||||
---@param input string
|
||||
---@param deliminer string
|
||||
---@return string[], string|nil
|
||||
local function StrSplit(input, deliminer)
|
||||
if not deliminer then return {}, "deliminer is nil" end
|
||||
if not input then return {}, "input is nil" end
|
||||
local parts = {}
|
||||
for part in string.gmatch(input, "([^" .. deliminer .. "]+)") do
|
||||
table.insert(parts, strtrim(part))
|
||||
end
|
||||
return parts, nil
|
||||
end
|
||||
|
||||
---@type string[]
|
||||
local toNotify = StrSplit(aura_env.config.notify, ",")
|
||||
for i, part in ipairs(toNotify) do
|
||||
toNotify[i] = strtrim(part)
|
||||
end
|
||||
---@type table<string, boolean>
|
||||
local notifyFor = {}
|
||||
local notifyForD = StrSplit(aura_env.config.notifyFor, ",")
|
||||
for i, part in ipairs(notifyForD) do
|
||||
notifyFor[part] = true
|
||||
end
|
||||
|
||||
---@param player Player
|
||||
aura_env.Notify = function(player)
|
||||
if not notifyFor[player.zone] then return end
|
||||
local msg = string.format("%s of class %s and guild %s in %s", player.name, player.class, player.guild, player.zone)
|
||||
for _, rec in ipairs(toNotify) do
|
||||
table.insert(aura_env.messageQueue, {to = rec, message = msg})
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user