Files
wow-weakauras/FreshShit/ChannelJoiner/init.lua

42 lines
1.1 KiB
Lua

---@type string[]
local channelNames = {}
---@type string[]
local channelPasswords = {}
---@type string|nil
local err
---@param input string
---@param deliminer string
---@return string[], string|nil
local function StrSplit(input, deliminer)
if not deliminer then return {}, "deliminer is nil" end
if not input then return {}, "input is nil" end
local parts = {}
for part in string.gmatch(input, "([^" .. deliminer .. "]+)") do
table.insert(parts, strtrim(part))
end
return parts, nil
end
channelNames, err = StrSplit(aura_env.config.channels, ",")
if err then
print(string.format("Error splitting channels: %s", err))
return
end
channelPasswords, err = StrSplit(aura_env.config.channelPasswords, ",")
if err then
print(string.format("Error splitting channel passwords: %s", err))
return
end
aura_env.JoinChannels = function()
for i, channelName in ipairs(channelNames) do
channelName = strtrim(channelName)
local password = nil
if i <= #channelPasswords then
password = strtrim(channelPasswords[i])
end
JoinPermanentChannel(channelName, password)
end
end