Implement "howmany" to whoer
This commit is contained in:
@@ -367,6 +367,17 @@ function shared.Whoer.Init()
|
||||
Tick()
|
||||
end
|
||||
|
||||
---@return table<string, number>
|
||||
local function Count()
|
||||
local ret = {}
|
||||
for _, player in pairs(HeimdallStinkies) do
|
||||
if Heimdall_Data.config.who.zoneNotifyFor[player.zone] then
|
||||
ret[player.zone] = (ret[player.zone] or 0) + 1
|
||||
end
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
local whoQueryWhisperFrame = CreateFrame("Frame")
|
||||
whoQueryWhisperFrame:RegisterEvent("CHAT_MSG_WHISPER")
|
||||
whoQueryWhisperFrame:SetScript("OnEvent", function(self, event, msg, sender)
|
||||
@@ -383,6 +394,21 @@ function shared.Whoer.Init()
|
||||
table.insert(shared.messenger.queue, msg)
|
||||
end
|
||||
end
|
||||
if msg == "howmany" then
|
||||
local count = Count()
|
||||
local text = ""
|
||||
for zone, count in pairs(count) do
|
||||
text = text .. string.format("%s: %d, ", zone, count)
|
||||
end
|
||||
text = text:sub(1, string.len(text) - 2)
|
||||
---@type Message
|
||||
local msg = {
|
||||
channel = "WHISPER",
|
||||
data = sender,
|
||||
message = text
|
||||
}
|
||||
table.insert(shared.messenger.queue, msg)
|
||||
end
|
||||
end)
|
||||
|
||||
local whoQueryChannelFrame = CreateFrame("Frame")
|
||||
@@ -417,6 +443,21 @@ function shared.Whoer.Init()
|
||||
table.insert(shared.messenger.queue, msg)
|
||||
end
|
||||
end
|
||||
if msg == "howmany" then
|
||||
local count = Count()
|
||||
local text = ""
|
||||
for zone, count in pairs(count) do
|
||||
text = text .. string.format("%s: %d, ", zone, count)
|
||||
end
|
||||
text = text:sub(1, string.len(text) - 2)
|
||||
---@type Message
|
||||
local msg = {
|
||||
channel = "CHANNEL",
|
||||
data = channelname,
|
||||
message = text
|
||||
}
|
||||
table.insert(shared.messenger.queue, msg)
|
||||
end
|
||||
end)
|
||||
|
||||
print("Heimdall - Whoer loaded")
|
||||
|
Reference in New Issue
Block a user