64 lines
1.7 KiB
Lua
64 lines
1.7 KiB
Lua
local addonname, data = ...
|
|
---@cast addonname string
|
|
local channelNameLength = 8
|
|
local messageLength = 32
|
|
local lowerBound = 53
|
|
local upperBound = 77
|
|
|
|
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
|
|
|
|
local function GenerateString(length)
|
|
local string = ""
|
|
for i = 1, length do
|
|
string = string .. string.char(math.random(97, 122))
|
|
end
|
|
return string
|
|
end
|
|
local channelName = GenerateString(channelNameLength)
|
|
|
|
local function Yap()
|
|
local message = GenerateString(messageLength)
|
|
print(string.format("YAPPING %s", tostring(message)))
|
|
|
|
local channelId = GetChannelId(channelName)
|
|
if channelId ~= nil then
|
|
SendChatMessage(message, "CHANNEL", nil, channelId)
|
|
else
|
|
print(string.format("Channel %s not found", channelName))
|
|
end
|
|
|
|
local delay = math.random(lowerBound, upperBound)
|
|
print(string.format("Yapper yapping in %d seconds", delay))
|
|
C_Timer.After(delay, Yap)
|
|
end
|
|
|
|
local function init()
|
|
JoinTemporaryChannel(channelName)
|
|
print(string.format("Yapper joined %s", tostring(channelName)))
|
|
local delay = math.random(lowerBound, upperBound)
|
|
print(string.format("Yapper yapping in %d seconds", delay))
|
|
C_Timer.After(delay, Yap)
|
|
end
|
|
|
|
local loadedFrame = CreateFrame("Frame")
|
|
loadedFrame:RegisterEvent("ADDON_LOADED")
|
|
loadedFrame:SetScript("OnEvent", function(self, event, addonName)
|
|
if addonName == addonname then
|
|
init()
|
|
end
|
|
end)
|
|
|
|
local logoutFrame = CreateFrame("Frame")
|
|
logoutFrame:RegisterEvent("PLAYER_LOGOUT")
|
|
logoutFrame:SetScript("OnEvent", function(self, event)
|
|
end)
|