Rework the channel commands a little
This commit is contained in:
@@ -367,7 +367,7 @@ function shared.Whoer.Init()
|
||||
Tick()
|
||||
end
|
||||
|
||||
---@return table<string, number>
|
||||
---@return string[]
|
||||
local function Count()
|
||||
local ret = {}
|
||||
for _, player in pairs(HeimdallStinkies) do
|
||||
@@ -375,6 +375,20 @@ function shared.Whoer.Init()
|
||||
ret[player.zone] = (ret[player.zone] or 0) + 1
|
||||
end
|
||||
end
|
||||
local text = {}
|
||||
for zone, count in pairs(ret) do
|
||||
text[#text + 1] = string.format("%s: %d", zone, count)
|
||||
end
|
||||
return text
|
||||
end
|
||||
---@return string[]
|
||||
local function Who()
|
||||
local ret = {}
|
||||
for _, player in pairs(HeimdallStinkies) do
|
||||
if Heimdall_Data.config.who.zoneNotifyFor[player.zone] then
|
||||
ret[#ret + 1] = string.format("%s (%s) %s", player.name, player.zone, player.stinky and "(!!!!)" or "")
|
||||
end
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
@@ -383,29 +397,20 @@ function shared.Whoer.Init()
|
||||
whoQueryWhisperFrame:SetScript("OnEvent", function(self, event, msg, sender)
|
||||
if not Heimdall_Data.config.who.enabled then return end
|
||||
if msg == "who" then
|
||||
for _, player in pairs(HeimdallStinkies) do
|
||||
local text = player:NotifyMessage()
|
||||
---@type Message
|
||||
local msg = {
|
||||
channel = "WHISPER",
|
||||
data = sender,
|
||||
message = text
|
||||
}
|
||||
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
|
||||
message = strjoin(", ", unpack(Who()))
|
||||
}
|
||||
table.insert(shared.messenger.queue, msg)
|
||||
end
|
||||
if msg == "howmany" then
|
||||
---@type Message
|
||||
local msg = {
|
||||
channel = "WHISPER",
|
||||
data = sender,
|
||||
message = strjoin(", ", unpack(Count()))
|
||||
}
|
||||
table.insert(shared.messenger.queue, msg)
|
||||
end
|
||||
@@ -432,29 +437,20 @@ function shared.Whoer.Init()
|
||||
if channelname ~= Heimdall_Data.config.who.notifyChannel then return end
|
||||
|
||||
if msg == "who" then
|
||||
for _, player in pairs(HeimdallStinkies) do
|
||||
local text = player:NotifyMessage()
|
||||
---@type Message
|
||||
local msg = {
|
||||
channel = "CHANNEL",
|
||||
data = channelname,
|
||||
message = text
|
||||
}
|
||||
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
|
||||
message = strjoin(", ", unpack(Who()))
|
||||
}
|
||||
table.insert(shared.messenger.queue, msg)
|
||||
end
|
||||
if msg == "howmany" then
|
||||
---@type Message
|
||||
local msg = {
|
||||
channel = "CHANNEL",
|
||||
data = channelname,
|
||||
message = strjoin(", ", unpack(Count()))
|
||||
}
|
||||
table.insert(shared.messenger.queue, msg)
|
||||
end
|
||||
|
Reference in New Issue
Block a user