Initial commit
Port from weakaura
This commit is contained in:
111
Channeler.lua
Normal file
111
Channeler.lua
Normal file
@@ -0,0 +1,111 @@
|
||||
---@class Channel
|
||||
---@field name string
|
||||
---@field password string|nil
|
||||
|
||||
---@type Channel[]
|
||||
local channels = {
|
||||
{ name = "Agent", password = "agents42" },
|
||||
{ name = "Horde", password = "garrosh" }
|
||||
}
|
||||
---@type string
|
||||
local chatFrameName = "Auto"
|
||||
---@type string[]
|
||||
local subscribedMessageGroups = {
|
||||
"SAY",
|
||||
"YELL",
|
||||
"EMOTE",
|
||||
"PARTY",
|
||||
"PARTY_LEADER",
|
||||
"RAID",
|
||||
"RAID_LEADER",
|
||||
"RAID_WARNING",
|
||||
"BATTLEGROUND",
|
||||
"BATTLEGROUND_LEADER",
|
||||
"INSTANCE_CHAT",
|
||||
"INSTANCE_CHAT_LEADER",
|
||||
"WHISPER"
|
||||
}
|
||||
---@type string[]
|
||||
local subscribedChannels = {
|
||||
"Agent",
|
||||
"Horde"
|
||||
}
|
||||
|
||||
local function JoinChannels()
|
||||
for _, channel in ipairs(channels) do
|
||||
if channel.password then
|
||||
JoinPermanentChannel(channel.name, channel.password)
|
||||
else
|
||||
JoinPermanentChannel(channel.name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function FindOrCreateChatWindow()
|
||||
for i = 1, NUM_CHAT_WINDOWS do
|
||||
local name = GetChatWindowInfo(i)
|
||||
if name == chatFrameName then
|
||||
print(string.format("Found chat window %s", name))
|
||||
local frame = _G["ChatFrame" .. i]
|
||||
if FCF_IsValidChatFrame(frame) then
|
||||
print(string.format("Frame %s is valid", name))
|
||||
return frame
|
||||
else
|
||||
print(string.format("Frame %s is invalid", name))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
print("Opening new chat window")
|
||||
FCF_OpenNewWindow(chatFrameName)
|
||||
for i = 1, NUM_CHAT_WINDOWS do
|
||||
local name = GetChatWindowInfo(i)
|
||||
if name == chatFrameName then
|
||||
print(string.format("Found chat window %s", name))
|
||||
local frame = _G["ChatFrame" .. i]
|
||||
if FCF_IsValidChatFrame(frame) then
|
||||
print(string.format("Frame %s is valid", name))
|
||||
return frame
|
||||
else
|
||||
print(string.format("Frame %s is invalid", name))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
local function ConfigureChatWindow()
|
||||
local general = _G["ChatFrame1"]
|
||||
local chatFrame = FindOrCreateChatWindow()
|
||||
if not chatFrame then
|
||||
print(string.format("Chat window %s not found", chatFrameName))
|
||||
return
|
||||
end
|
||||
|
||||
--SetChatWindowName(chatFrame, chatFrameName)
|
||||
print("Removing all message groups")
|
||||
ChatFrame_RemoveAllMessageGroups(chatFrame)
|
||||
print("Removing all channels")
|
||||
ChatFrame_RemoveAllChannels(chatFrame)
|
||||
print("Adding message groups")
|
||||
for _, messageGroup in ipairs(subscribedMessageGroups) do
|
||||
print(string.format("Adding message group: %s", messageGroup))
|
||||
ChatFrame_AddMessageGroup(chatFrame, strtrim(messageGroup))
|
||||
ChatFrame_RemoveMessageGroup(general, strtrim(messageGroup))
|
||||
end
|
||||
print("Adding channels")
|
||||
for _, channel in ipairs(subscribedChannels) do
|
||||
print(string.format("Adding channel: %s", channel))
|
||||
ChatFrame_AddChannel(chatFrame, strtrim(channel))
|
||||
ChatFrame_RemoveChannel(general, strtrim(channel))
|
||||
end
|
||||
end
|
||||
|
||||
local frame = CreateFrame("Frame")
|
||||
--frame:RegisterEvent("PLAYER_LOGIN")
|
||||
frame:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||
frame:SetScript("OnEvent", function(self, event, ...)
|
||||
JoinChannels()
|
||||
ConfigureChatWindow()
|
||||
end)
|
Reference in New Issue
Block a user