Implement commander only mode for commands

This commit is contained in:
2025-01-05 23:26:28 +01:00
parent 2e805abef7
commit 6059c16a6e
3 changed files with 17 additions and 12 deletions

View File

@@ -167,18 +167,22 @@ function shared.Commander.Init()
local channelId = select(6, ...)
local _, channelname = GetChannelName(channelId)
if channelname ~= Heimdall_Data.config.commander.masterChannel then return end
sender = string.match(sender, "^[^-]+")
for _, command in ipairs(commands) do
if msg:match(command.keywordRe) then
local messages = command.callback({ strsplit(" ", msg) })
for _, message in ipairs(messages) do
---@type Message
local msg = {
channel = "CHANNEL",
data = channelname,
message = message
}
table.insert(shared.messenger.queue, msg)
if not command.commanderOnly or
(command.commanderOnly and sender == Heimdall_Data.config.commander.commander) then
if msg:match(command.keywordRe) then
local messages = command.callback({ strsplit(" ", msg) })
for _, message in ipairs(messages) do
---@type Message
local msg = {
channel = "CHANNEL",
data = channelname,
message = message
}
table.insert(shared.messenger.queue, msg)
end
end
end
end