Implement yapping
This commit is contained in:
46
Yapper.lua
46
Yapper.lua
@@ -1,8 +1,52 @@
|
||||
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()
|
||||
print("Yapper loaded!")
|
||||
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")
|
||||
|
Reference in New Issue
Block a user