Rework addon loading to properly load on ADDON_LOADED
insteaad of immediately
This commit is contained in:
8
DeathReporter.lua
Normal file
8
DeathReporter.lua
Normal file
@@ -0,0 +1,8 @@
|
||||
|
||||
local addonname, data = ...
|
||||
---@cast data HeimdallData
|
||||
---@cast addonname string
|
||||
|
||||
data.DeathReporter = {}
|
||||
function data.DeathReporter.Init()
|
||||
end
|
||||
@@ -1,5 +1,6 @@
|
||||
local _, data = ...
|
||||
local addonname, data = ...
|
||||
---@cast data HeimdallData
|
||||
---@cast addonname string
|
||||
|
||||
if not data.dumpTable then
|
||||
---@param table table
|
||||
|
||||
239
Heimdall.lua
239
Heimdall.lua
@@ -1,118 +1,152 @@
|
||||
local _, data = ...
|
||||
local addonname, data = ...
|
||||
---@cast data HeimdallData
|
||||
---@cast addonname string
|
||||
|
||||
---@class Heimdall_Data
|
||||
---@field who { data: table<string, Player> }
|
||||
if not Heimdall_Data then Heimdall_Data = {} end
|
||||
local function init()
|
||||
---@class Heimdall_Data
|
||||
---@field who { data: table<string, Player> }
|
||||
if not Heimdall_Data then Heimdall_Data = {} end
|
||||
if not Heimdall_Data.config then Heimdall_Data.config = {} end
|
||||
|
||||
-- We don't care about these persisting
|
||||
-- Actually we don't want some of them to persist
|
||||
-- For those we DO we use (global) Heimdall_Data
|
||||
-- We don't care about these persisting
|
||||
-- Actually we don't want some of them to persist
|
||||
-- For those we DO we use (global) Heimdall_Data
|
||||
|
||||
---@class HeimdallData
|
||||
---@field config HeimdallConfig
|
||||
---@field raceMap table<string, string>
|
||||
---@field classColors table<string, string>
|
||||
---@field stinkies table<string, Player>
|
||||
---@field messenger HeimdallMessengerData
|
||||
---@field who HeimdallWhoData
|
||||
---@field dumpTable fun(table: any, depth?: number): nil
|
||||
---@field utf8len fun(input: string): number
|
||||
---@field padString fun(input: string, targetLength: number, left?: boolean): string
|
||||
---@class HeimdallData
|
||||
---@field config HeimdallConfig
|
||||
---@field raceMap table<string, string>
|
||||
---@field classColors table<string, string>
|
||||
---@field stinkies table<string, Player>
|
||||
---@field messenger HeimdallMessengerData
|
||||
---@field who HeimdallWhoData
|
||||
---@field dumpTable fun(table: any, depth?: number): nil
|
||||
---@field utf8len fun(input: string): number
|
||||
---@field padString fun(input: string, targetLength: number, left?: boolean): string
|
||||
---@field GetOrDefault fun(table: table<any, any>, keys: string[], default: any): any
|
||||
---@field Whoer { Init: fun() }
|
||||
---@field Messenger { Init: fun() }
|
||||
---@field Spotter { Init: fun() }
|
||||
---@field DeathReporter { Init: fun() }
|
||||
|
||||
--- Config ---
|
||||
---@class HeimdallConfig
|
||||
---@field spotter HeimdallSpotterConfig
|
||||
---@field who HeimdallWhoConfig
|
||||
---@field messenger HeimdallMessengerConfig
|
||||
---@field whisperNotify table<string, string>
|
||||
--- Config ---
|
||||
---@class HeimdallConfig
|
||||
---@field spotter HeimdallSpotterConfig
|
||||
---@field who HeimdallWhoConfig
|
||||
---@field messenger HeimdallMessengerConfig
|
||||
---@field whisperNotify table<string, string>
|
||||
|
||||
---@class HeimdallSpotterConfig
|
||||
---@field enabled boolean
|
||||
---@field everyone boolean
|
||||
---@field hostile boolean
|
||||
---@field alliance boolean
|
||||
---@field stinky boolean
|
||||
---@field notifyChannel string
|
||||
---@field zoneOverride string?
|
||||
---@field throttleTime number
|
||||
---@class HeimdallSpotterConfig
|
||||
---@field enabled boolean
|
||||
---@field everyone boolean
|
||||
---@field hostile boolean
|
||||
---@field alliance boolean
|
||||
---@field stinky boolean
|
||||
---@field notifyChannel string
|
||||
---@field zoneOverride string?
|
||||
---@field throttleTime number
|
||||
|
||||
---@class HeimdallWhoConfig
|
||||
---@field enabled boolean
|
||||
---@field ignored table<string, boolean>
|
||||
---@field notifyChannel string
|
||||
---@field ttl number
|
||||
---@field doWhisper boolean
|
||||
---@field zoneNotifyFor table<string, boolean>
|
||||
---@class HeimdallWhoConfig
|
||||
---@field enabled boolean
|
||||
---@field ignored table<string, boolean>
|
||||
---@field notifyChannel string
|
||||
---@field ttl number
|
||||
---@field doWhisper boolean
|
||||
---@field zoneNotifyFor table<string, boolean>
|
||||
|
||||
---@class HeimdallMessengerConfig
|
||||
---@field enabled boolean
|
||||
---@class HeimdallMessengerConfig
|
||||
---@field enabled boolean
|
||||
|
||||
--- Data ---
|
||||
---@class HeimdallMessengerData
|
||||
---@field queue table<string, Message>
|
||||
---@field ticker number?
|
||||
--- Data ---
|
||||
---@class HeimdallMessengerData
|
||||
---@field queue table<string, Message>
|
||||
---@field ticker number?
|
||||
|
||||
---@class HeimdallWhoData
|
||||
---@field updateTicker number?
|
||||
---@field whoTicker number?
|
||||
---@field ignored table<string, boolean>
|
||||
---@class HeimdallWhoData
|
||||
---@field updateTicker number?
|
||||
---@field whoTicker number?
|
||||
---@field ignored table<string, boolean>
|
||||
|
||||
data.messenger = {
|
||||
data.GetOrDefault = function(table, keys, default)
|
||||
local value = default
|
||||
if not table then return value end
|
||||
if not keys then return value end
|
||||
|
||||
local traverse = table
|
||||
for i = 1, #keys do
|
||||
local key = keys[i]
|
||||
if traverse[key] then
|
||||
traverse = traverse[key]
|
||||
else
|
||||
break
|
||||
end
|
||||
|
||||
if i == #keys then
|
||||
value = traverse
|
||||
end
|
||||
end
|
||||
return value
|
||||
end
|
||||
|
||||
data.messenger = {
|
||||
queue = {}
|
||||
}
|
||||
data.who = {
|
||||
}
|
||||
data.who = {
|
||||
ignored = {},
|
||||
}
|
||||
}
|
||||
|
||||
data.config = {
|
||||
data.config = {
|
||||
spotter = {
|
||||
enabled = true,
|
||||
everyone = false,
|
||||
hostile = true,
|
||||
alliance = false,
|
||||
stinky = false,
|
||||
notifyChannel = "Foobar",
|
||||
zoneOverride = nil,
|
||||
throttleTime = 1
|
||||
enabled = data.GetOrDefault(Heimdall_Data, { "config", "spotter", "enabled" }, true),
|
||||
everyone = data.GetOrDefault(Heimdall_Data, { "config", "spotter", "everyone" }, false),
|
||||
hostile = data.GetOrDefault(Heimdall_Data, { "config", "spotter", "hostile" }, true),
|
||||
alliance = data.GetOrDefault(Heimdall_Data, { "config", "spotter", "alliance" }, false),
|
||||
stinky = data.GetOrDefault(Heimdall_Data, { "config", "spotter", "stinky" }, false),
|
||||
notifyChannel = data.GetOrDefault(Heimdall_Data, { "config", "spotter", "notifyChannel" }, "Foobar"),
|
||||
zoneOverride = data.GetOrDefault(Heimdall_Data, { "config", "spotter", "zoneOverride" }, nil),
|
||||
throttleTime = data.GetOrDefault(Heimdall_Data, { "config", "spotter", "throttleTime" }, 1)
|
||||
},
|
||||
who = {
|
||||
enabled = true,
|
||||
ignored = {},
|
||||
notifyChannel = "Foobar",
|
||||
ttl = 10,
|
||||
doWhisper = true,
|
||||
zoneNotifyFor = {
|
||||
enabled = data.GetOrDefault(Heimdall_Data, { "config", "who", "enabled" }, true),
|
||||
ignored = data.GetOrDefault(Heimdall_Data, { "config", "who", "ignored" }, {}),
|
||||
notifyChannel = data.GetOrDefault(Heimdall_Data, { "config", "who", "notifyChannel" }, "Foobar"),
|
||||
ttl = data.GetOrDefault(Heimdall_Data, { "config", "who", "ttl" }, 10),
|
||||
doWhisper = data.GetOrDefault(Heimdall_Data, { "config", "who", "doWhisper" }, true),
|
||||
zoneNotifyFor = data.GetOrDefault(Heimdall_Data, { "config", "who", "zoneNotifyFor" }, {
|
||||
["Orgrimmar"] = true,
|
||||
["Thunder Bluff"] = true,
|
||||
["Undercity"] = true,
|
||||
["Durotar"] = true,
|
||||
["Echo Isles"] = true,
|
||||
["Valley of Trials"] = true,
|
||||
}
|
||||
}),
|
||||
},
|
||||
messenger = {
|
||||
enabled = true
|
||||
enabled = data.GetOrDefault(Heimdall_Data, { "config", "messenger", "enabled" }, true),
|
||||
},
|
||||
whisperNotify = {
|
||||
"Extazyk",
|
||||
"Smokefire",
|
||||
"Smokemantra",
|
||||
"Хихихантер",
|
||||
"Муркот",
|
||||
"Растафаркрай",
|
||||
"Frosstmorn",
|
||||
"Pulsjkee",
|
||||
"Paskoo",
|
||||
whisperNotify = data.GetOrDefault(Heimdall_Data, { "config", "whisperNotify" }, {
|
||||
-- "Extazyk",
|
||||
-- "Smokefire",
|
||||
-- "Smokemantra",
|
||||
-- "Хихихантер",
|
||||
-- "Муркот",
|
||||
-- "Растафаркрай",
|
||||
-- "Frosstmorn",
|
||||
-- "Pulsjkee",
|
||||
-- "Paskoo",
|
||||
"Totleta",
|
||||
"Healleta",
|
||||
"Deathleta",
|
||||
"Shootleta",
|
||||
"Stableta"
|
||||
}),
|
||||
}
|
||||
}
|
||||
--/run Heimdall_Data = {config = {who = {enabled = false}}}
|
||||
--/dump Heimdall_Data
|
||||
print("138 " .. tostring(Heimdall_Data.config.who.enabled))
|
||||
print("139 " .. tostring(data.GetOrDefault(Heimdall_Data, { "config", "who", "enabled" }, true)))
|
||||
print("140 " .. tostring(data.config.who.enabled))
|
||||
|
||||
data.raceMap = {
|
||||
data.raceMap = {
|
||||
["Orc"] = "Horde",
|
||||
["Undead"] = "Horde",
|
||||
["Tauren"] = "Horde",
|
||||
@@ -134,10 +168,9 @@ data.raceMap = {
|
||||
["Lightforged Draenei"] = "Alliance",
|
||||
["Mechagnome"] = "Alliance",
|
||||
["Mag'har Orc"] = "Horde"
|
||||
}
|
||||
}
|
||||
|
||||
---@type table<string, string>
|
||||
data.classColors = {
|
||||
data.classColors = {
|
||||
["Warrior"] = "C69B6D",
|
||||
["Paladin"] = "F48CBA",
|
||||
["Hunter"] = "AAD372",
|
||||
@@ -150,13 +183,13 @@ data.classColors = {
|
||||
["Monk"] = "00FF98",
|
||||
["Druid"] = "FF7C0A",
|
||||
["Demon Hunter"] = "A330C9"
|
||||
}
|
||||
}
|
||||
|
||||
data.stinkies = {}
|
||||
data.stinkies = {}
|
||||
|
||||
---@param input string
|
||||
---@return number
|
||||
data.utf8len = function(input)
|
||||
---@param input string
|
||||
---@return number
|
||||
data.utf8len = function(input)
|
||||
if not input then
|
||||
return 0
|
||||
end
|
||||
@@ -179,12 +212,12 @@ data.utf8len = function(input)
|
||||
len = len + 1
|
||||
end
|
||||
return len
|
||||
end
|
||||
---@param input string
|
||||
---@param targetLength number
|
||||
---@param left boolean
|
||||
---@return string
|
||||
data.padString = function(input, targetLength, left)
|
||||
end
|
||||
---@param input string
|
||||
---@param targetLength number
|
||||
---@param left boolean
|
||||
---@return string
|
||||
data.padString = function(input, targetLength, left)
|
||||
left = left or false
|
||||
local len = data.utf8len(input)
|
||||
if len < targetLength then
|
||||
@@ -195,4 +228,18 @@ data.padString = function(input, targetLength, left)
|
||||
end
|
||||
end
|
||||
return input
|
||||
end
|
||||
|
||||
data.Whoer.Init()
|
||||
data.Messenger.Init()
|
||||
data.Spotter.Init()
|
||||
data.DeathReporter.Init()
|
||||
end
|
||||
|
||||
local loadedFrame = CreateFrame("Frame")
|
||||
loadedFrame:RegisterEvent("ADDON_LOADED")
|
||||
loadedFrame:SetScript("OnEvent", function(self, event, addonName)
|
||||
if addonName == addonname then
|
||||
init()
|
||||
end
|
||||
end)
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
## SavedVariables: Heimdall_Data
|
||||
|
||||
#core
|
||||
Heimdall.lua
|
||||
CLEUParser.lua
|
||||
DumpTable.lua
|
||||
Spotter.lua
|
||||
Whoer.lua
|
||||
Messenger.lua
|
||||
DumpTable.lua
|
||||
Heimdall.lua
|
||||
@@ -1,17 +1,20 @@
|
||||
local _, data = ...
|
||||
local addonname, data = ...
|
||||
---@cast data HeimdallData
|
||||
---@cast addonname string
|
||||
|
||||
if not data.config.messenger.enabled then return end
|
||||
data.Messenger = {}
|
||||
function data.Messenger.Init()
|
||||
if not data.config.messenger.enabled then return end
|
||||
|
||||
---@class Message
|
||||
---@field message string
|
||||
---@field channel string
|
||||
---@field data string
|
||||
---@class Message
|
||||
---@field message string
|
||||
---@field channel string
|
||||
---@field data string
|
||||
|
||||
---@type table<string, number>
|
||||
local channelIdMap = {}
|
||||
---@type table<string, number>
|
||||
local channelIdMap = {}
|
||||
|
||||
local FindOrJoinChannel = function(channelName, password)
|
||||
local FindOrJoinChannel = function(channelName, password)
|
||||
local function GetChannelId(channelName)
|
||||
local channels = { GetChannelList() }
|
||||
for i = 1, #channels, 2 do
|
||||
@@ -35,20 +38,20 @@ local FindOrJoinChannel = function(channelName, password)
|
||||
channelId = GetChannelId(channelName)
|
||||
channelIdMap[channelName] = channelId
|
||||
return channelId
|
||||
end
|
||||
end
|
||||
|
||||
local ScanChannels = function()
|
||||
local ScanChannels = function()
|
||||
local channels = { GetChannelList() }
|
||||
for i = 1, #channels, 2 do
|
||||
local id = channels[i]
|
||||
local name = channels[i + 1]
|
||||
channelIdMap[name] = id
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if not data.messenger then data.messenger = {} end
|
||||
if not data.messenger.queue then data.messenger.queue = {} end
|
||||
if not data.messenger.ticker then
|
||||
if not data.messenger then data.messenger = {} end
|
||||
if not data.messenger.queue then data.messenger.queue = {} end
|
||||
if not data.messenger.ticker then
|
||||
data.messenger.ticker = C_Timer.NewTicker(0.2, function()
|
||||
---@type Message
|
||||
local message = data.messenger.queue[1]
|
||||
@@ -79,13 +82,14 @@ if not data.messenger.ticker then
|
||||
if not message.data or message.data == "" then return end
|
||||
SendChatMessage(message.message, message.channel, nil, message.data)
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
--C_Timer.NewTicker(2, function()
|
||||
-- print("Q")
|
||||
-- table.insert(data.messenger.queue, {
|
||||
-- channel = "CHANNEL",
|
||||
-- data = "Foobar",
|
||||
-- message = "TEST"
|
||||
-- })
|
||||
--end)
|
||||
--C_Timer.NewTicker(2, function()
|
||||
-- print("Q")
|
||||
-- table.insert(data.messenger.queue, {
|
||||
-- channel = "CHANNEL",
|
||||
-- data = "Foobar",
|
||||
-- message = "TEST"
|
||||
-- })
|
||||
--end)
|
||||
end
|
||||
|
||||
51
Spotter.lua
51
Spotter.lua
@@ -1,9 +1,11 @@
|
||||
local _, data = ...
|
||||
local addonname, data = ...
|
||||
---@cast data HeimdallData
|
||||
---@cast addonname string
|
||||
|
||||
if not data.config.spotter.enabled then return end
|
||||
|
||||
local function FormatHP(hp)
|
||||
data.Spotter = {}
|
||||
function data.Spotter.Init()
|
||||
if not data.config.spotter.enabled then return end
|
||||
local function FormatHP(hp)
|
||||
if hp > 1e9 then
|
||||
return string.format("%.1fB", hp / 1e9)
|
||||
elseif hp > 1e6 then
|
||||
@@ -13,18 +15,18 @@ local function FormatHP(hp)
|
||||
else
|
||||
return hp
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
---@type table<string, number>
|
||||
local throttleTable = {}
|
||||
---@type table<string, number>
|
||||
local throttleTable = {}
|
||||
|
||||
---@param unit string
|
||||
---@param name string
|
||||
---@param faction string
|
||||
---@param hostile boolean
|
||||
---@return boolean
|
||||
---@return string? error
|
||||
local function ShouldNotify(unit, name, faction, hostile)
|
||||
---@param unit string
|
||||
---@param name string
|
||||
---@param faction string
|
||||
---@param hostile boolean
|
||||
---@return boolean
|
||||
---@return string? error
|
||||
local function ShouldNotify(unit, name, faction, hostile)
|
||||
if data.config.spotter.stinky then
|
||||
if data.stinkies[name] then return true end
|
||||
end
|
||||
@@ -35,11 +37,11 @@ local function ShouldNotify(unit, name, faction, hostile)
|
||||
if hostile then return true end
|
||||
end
|
||||
return data.config.spotter.everyone
|
||||
end
|
||||
end
|
||||
|
||||
---@param unit string
|
||||
---@return string?
|
||||
local function NotifySpotted(unit)
|
||||
---@param unit string
|
||||
---@return string?
|
||||
local function NotifySpotted(unit)
|
||||
if not unit then return string.format("Could not find unit %s", tostring(unit)) end
|
||||
if not UnitIsPlayer(unit) then return nil end
|
||||
|
||||
@@ -92,14 +94,15 @@ local function NotifySpotted(unit)
|
||||
}
|
||||
data.dumpTable(msg)
|
||||
table.insert(data.messenger.queue, msg)
|
||||
end
|
||||
end
|
||||
|
||||
local frame = CreateFrame("Frame")
|
||||
frame:RegisterEvent("NAME_PLATE_UNIT_ADDED")
|
||||
frame:RegisterEvent("TARGET_UNIT_CHANGED")
|
||||
frame:SetScript("OnEvent", function(self, event, unit)
|
||||
local frame = CreateFrame("Frame")
|
||||
frame:RegisterEvent("NAME_PLATE_UNIT_ADDED")
|
||||
frame:RegisterEvent("TARGET_UNIT_CHANGED")
|
||||
frame:SetScript("OnEvent", function(self, event, unit)
|
||||
local err = NotifySpotted(unit)
|
||||
if err then
|
||||
print(string.format("Error notifying %s: %s", tostring(unit), tostring(err)))
|
||||
end
|
||||
end)
|
||||
end)
|
||||
end
|
||||
|
||||
144
Whoer.lua
144
Whoer.lua
@@ -1,27 +1,27 @@
|
||||
local _, data = ...
|
||||
local addonname, data = ...
|
||||
---@cast data HeimdallData
|
||||
---@cast addonname string
|
||||
|
||||
if not data.config.who.enabled then return end
|
||||
if not Heimdall_Data.who then Heimdall_Data.who = {} end
|
||||
if not Heimdall_Data.who.data then Heimdall_Data.who.data = {} end
|
||||
print(Heimdall_Data)
|
||||
print(Heimdall_Data.who)
|
||||
print(Heimdall_Data.who.data)
|
||||
data.Whoer = {}
|
||||
function data.Whoer.Init()
|
||||
if not data.config.who.enabled then return end
|
||||
if not Heimdall_Data.who then Heimdall_Data.who = {} end
|
||||
if not Heimdall_Data.who.data then Heimdall_Data.who.data = {} end
|
||||
|
||||
---@type table<string, Player>
|
||||
local players = {}
|
||||
---@type table<string, Player>
|
||||
local players = {}
|
||||
|
||||
---@class Player
|
||||
---@field name string
|
||||
---@field guild string
|
||||
---@field race string
|
||||
---@field class string
|
||||
---@field zone string
|
||||
---@field lastSeenInternal number
|
||||
---@field lastSeen string
|
||||
---@field firstSeen string
|
||||
---@field seenCount number
|
||||
Player = {
|
||||
---@class Player
|
||||
---@field name string
|
||||
---@field guild string
|
||||
---@field race string
|
||||
---@field class string
|
||||
---@field zone string
|
||||
---@field lastSeenInternal number
|
||||
---@field lastSeen string
|
||||
---@field firstSeen string
|
||||
---@field seenCount number
|
||||
Player = {
|
||||
---@param name string
|
||||
---@param guild string
|
||||
---@param race string
|
||||
@@ -56,7 +56,8 @@ Player = {
|
||||
end,
|
||||
---@return string
|
||||
NotifyMessage = function(self)
|
||||
local text = string.format("%s of class %s and guild %s in %s, first seen: %s, last seen: %s, times seen: %d",
|
||||
local text = string.format(
|
||||
"%s of class %s and guild %s in %s, first seen: %s, last seen: %s, times seen: %d",
|
||||
self.name,
|
||||
self.class,
|
||||
self.guild,
|
||||
@@ -66,12 +67,12 @@ Player = {
|
||||
self.seenCount)
|
||||
return text
|
||||
end
|
||||
}
|
||||
}
|
||||
|
||||
---@class WHOQuery
|
||||
---@field query string
|
||||
---@field filters WHOFilter[]
|
||||
WHOQuery = {
|
||||
---@class WHOQuery
|
||||
---@field query string
|
||||
---@field filters WHOFilter[]
|
||||
WHOQuery = {
|
||||
---@param query string
|
||||
---@param filters WHOFilter[]
|
||||
---@return WHOQuery
|
||||
@@ -83,18 +84,18 @@ WHOQuery = {
|
||||
self.filters = filters
|
||||
return self
|
||||
end
|
||||
}
|
||||
}
|
||||
|
||||
---@alias WHOFilter fun(name: string, guild: string, level: number, race: string, class: string, zone: string): boolean
|
||||
---@type WHOFilter
|
||||
local NotSiegeOfOrgrimmarFilter = function(name, guild, level, race, class, zone)
|
||||
---@alias WHOFilter fun(name: string, guild: string, level: number, race: string, class: string, zone: string): boolean
|
||||
---@type WHOFilter
|
||||
local NotSiegeOfOrgrimmarFilter = function(name, guild, level, race, class, zone)
|
||||
if not zone then
|
||||
return false
|
||||
end
|
||||
return zone ~= "Siege of Orgrimmar"
|
||||
end
|
||||
---@type WHOFilter
|
||||
local AllianceFilter = function(name, guild, level, race, class, zone)
|
||||
end
|
||||
---@type WHOFilter
|
||||
local AllianceFilter = function(name, guild, level, race, class, zone)
|
||||
if not race then
|
||||
return false
|
||||
end
|
||||
@@ -102,11 +103,11 @@ local AllianceFilter = function(name, guild, level, race, class, zone)
|
||||
return false
|
||||
end
|
||||
return data.raceMap[race] == "Alliance"
|
||||
end
|
||||
end
|
||||
|
||||
local whoQueryIdx = 1
|
||||
---@type table<number, WHOQuery>
|
||||
local whoQueries = {
|
||||
local whoQueryIdx = 1
|
||||
---@type table<number, WHOQuery>
|
||||
local whoQueries = {
|
||||
WHOQuery.new("g-\"БеспредеЛ\"", {}),
|
||||
WHOQuery.new(
|
||||
"z-\"Orgrimmar\" z-\"Durotar\" z-\"Valley of Trials\" z-\"Echo Isles\" r-\"Human\" r-\"Dwarf\" r-\"Night Elf\"",
|
||||
@@ -121,15 +122,15 @@ local whoQueries = {
|
||||
"z-\"Orgrimmar\" z-\"Durotar\" z-\"Valley of Trials\" z-\"Echo Isles\" r-\"Lightforged Draenei\" r-\"Mechagnome\"",
|
||||
{ NotSiegeOfOrgrimmarFilter, AllianceFilter }),
|
||||
WHOQuery.new("Kekv Demonboo Dotmada Firobot Verminal", {})
|
||||
}
|
||||
local queryPending = false
|
||||
local ttl = #whoQueries * 2
|
||||
---@type WHOQuery?
|
||||
local lastQuery = nil
|
||||
}
|
||||
local queryPending = false
|
||||
local ttl = #whoQueries * 2
|
||||
---@type WHOQuery?
|
||||
local lastQuery = nil
|
||||
|
||||
---@param player Player
|
||||
---@return string?
|
||||
local function Notify(player)
|
||||
---@param player Player
|
||||
---@return string?
|
||||
local function Notify(player)
|
||||
if not player then return string.format("Cannot notify for nil player %s", tostring(player)) end
|
||||
if not data.config.who.zoneNotifyFor[player.zone] then
|
||||
return string.format("Not notifying for zone %s",
|
||||
@@ -158,11 +159,11 @@ local function Notify(player)
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
---@param player Player
|
||||
---@param zone string
|
||||
---@return string?
|
||||
local function NotifyZoneChanged(player, zone)
|
||||
end
|
||||
---@param player Player
|
||||
---@param zone string
|
||||
---@return string?
|
||||
local function NotifyZoneChanged(player, zone)
|
||||
if not player then return string.format("Cannot notify for nil player %s", tostring(player)) end
|
||||
if not data.config.who.zoneNotifyFor[zone]
|
||||
and not data.config.who.zoneNotifyFor[player.zone] then
|
||||
@@ -195,10 +196,10 @@ local function NotifyZoneChanged(player, zone)
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
---@param player Player
|
||||
---@return string?
|
||||
local function NotifyGone(player)
|
||||
end
|
||||
---@param player Player
|
||||
---@return string?
|
||||
local function NotifyGone(player)
|
||||
if not player then return string.format("Cannot notify for nil player %s", tostring(player)) end
|
||||
if not data.config.who.zoneNotifyFor[player.zone] then
|
||||
return string.format("Not notifying for zone %s",
|
||||
@@ -232,11 +233,11 @@ local function NotifyGone(player)
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
local frame = CreateFrame("Frame")
|
||||
frame:RegisterEvent("WHO_LIST_UPDATE")
|
||||
frame:SetScript("OnEvent", function(self, event, ...)
|
||||
local frame = CreateFrame("Frame")
|
||||
frame:RegisterEvent("WHO_LIST_UPDATE")
|
||||
frame:SetScript("OnEvent", function(self, event, ...)
|
||||
---@type WHOQuery?
|
||||
local query = lastQuery
|
||||
if not query then
|
||||
@@ -314,9 +315,9 @@ frame:SetScript("OnEvent", function(self, event, ...)
|
||||
_G["FriendsFrameCloseButton"]:Click()
|
||||
queryPending = false
|
||||
print(queryPending)
|
||||
end)
|
||||
end)
|
||||
|
||||
if not data.who.updateTicker then
|
||||
if not data.who.updateTicker then
|
||||
data.who.updateTicker = C_Timer.NewTicker(0.5, function()
|
||||
for name, player in pairs(players) do
|
||||
if player.lastSeenInternal + data.config.who.ttl < GetTime() then
|
||||
@@ -326,9 +327,9 @@ if not data.who.updateTicker then
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
if not data.who.whoTicker then
|
||||
if not data.who.whoTicker then
|
||||
data.who.whoTicker = C_Timer.NewTicker(1, function()
|
||||
if queryPending then
|
||||
print("Tried running a who query while one is already pending, previous query:")
|
||||
@@ -347,11 +348,11 @@ if not data.who.whoTicker then
|
||||
SetWhoToUI(1)
|
||||
SendWho(query.query)
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
local whoQueryWhisperFrame = CreateFrame("Frame")
|
||||
whoQueryWhisperFrame:RegisterEvent("CHAT_MSG_WHISPER")
|
||||
whoQueryWhisperFrame:SetScript("OnEvent", function(self, event, msg, sender)
|
||||
local whoQueryWhisperFrame = CreateFrame("Frame")
|
||||
whoQueryWhisperFrame:RegisterEvent("CHAT_MSG_WHISPER")
|
||||
whoQueryWhisperFrame:SetScript("OnEvent", function(self, event, msg, sender)
|
||||
if msg == "who" then
|
||||
for _, player in pairs(players) do
|
||||
local text = player:NotifyMessage()
|
||||
@@ -364,11 +365,11 @@ whoQueryWhisperFrame:SetScript("OnEvent", function(self, event, msg, sender)
|
||||
table.insert(data.messenger.queue, msg)
|
||||
end
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
local whoQueryChannelFrame = CreateFrame("Frame")
|
||||
whoQueryChannelFrame:RegisterEvent("CHAT_MSG_CHANNEL")
|
||||
whoQueryChannelFrame:SetScript("OnEvent", function(self, event, msg, sender, ...)
|
||||
local whoQueryChannelFrame = CreateFrame("Frame")
|
||||
whoQueryChannelFrame:RegisterEvent("CHAT_MSG_CHANNEL")
|
||||
whoQueryChannelFrame:SetScript("OnEvent", function(self, event, msg, sender, ...)
|
||||
local channelId = select(6, ...)
|
||||
local channelname = ""
|
||||
---@type any[]
|
||||
@@ -399,4 +400,5 @@ whoQueryChannelFrame:SetScript("OnEvent", function(self, event, msg, sender, ...
|
||||
table.insert(data.messenger.queue, msg)
|
||||
end
|
||||
end
|
||||
end)
|
||||
end)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user