Add messenger, shared weakaura to use chat
This commit is contained in:
48
FreshShit/_Shared/Messenger.lua
Normal file
48
FreshShit/_Shared/Messenger.lua
Normal file
@@ -0,0 +1,48 @@
|
||||
-- TICKER_200
|
||||
function()
|
||||
if not WeakAurasSaved.Cyka then WeakAurasSaved.Cyka = {} end
|
||||
if not WeakAurasSaved.Cyka.MessageQueue then WeakAurasSaved.Cyka.MessageQueue = {} end
|
||||
|
||||
---@type Message
|
||||
local message = WeakAurasSaved.Cyka.MessageQueue[1]
|
||||
if message == nil then return end
|
||||
|
||||
table.remove(WeakAurasSaved.Cyka.MessageQueue, 1)
|
||||
SendChatMessage(message.message, message.channel, nil, message.data)
|
||||
end
|
||||
|
||||
--INIT
|
||||
local function FindOrJoinChannel(channelName, password)
|
||||
local function GetChannelId(channelName)
|
||||
local channels = {GetChannelList()}
|
||||
for i = 1, #channels, 2 do
|
||||
local id = channels[i]
|
||||
local name = channels[i + 1]
|
||||
if name == channelName then
|
||||
return id
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
channelId = GetChannelId(channelName)
|
||||
if not channelId then
|
||||
print(string.format("channel %s not found, joining", channelName))
|
||||
if password then
|
||||
JoinPermanentChannel(channelName, password)
|
||||
else
|
||||
JoinPermanentChannel(channelName)
|
||||
end
|
||||
end
|
||||
channelId = GetChannelId(channelName)
|
||||
return channelId
|
||||
end
|
||||
aura_env.channelId = FindOrJoinChannel(aura_env.channel, aura_env.channelPassword)
|
||||
--aura_env.iterator = 0
|
||||
--WeakAurasSaved.Cyka.MessageQueue = {}
|
||||
--for i = 1, 100 do
|
||||
-- table.insert(WeakAurasSaved.Cyka.MessageQueue, {
|
||||
-- channel = "CHANNEL",
|
||||
-- data = aura_env.channelId,
|
||||
-- message = "TEST" .. i
|
||||
-- })
|
||||
--end
|
||||
Reference in New Issue
Block a user