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