Also auto disable on error

This commit is contained in:
2024-12-17 15:10:54 +01:00
parent b4f6d92347
commit d065606cbe

View File

@@ -56,21 +56,29 @@ local function Yap()
if not shared.config.enabled then return end if not shared.config.enabled then return end
if not shared.config.message then if not shared.config.message then
print(string.format("Yapper found no message to yap (%s)", tostring(shared.config.message))) print(string.format("Yapper found no message to yap (%s)", tostring(shared.config.message)))
shared.config.enabled = false
return return
end end
if not shared.config.channel then if not shared.config.channel then
print(string.format("Yapper found no channel to yap in (%s)", tostring(shared.config.channel))) print(string.format("Yapper found no channel to yap in (%s)", tostring(shared.config.channel)))
shared.config.enabled = false
return return
end end
local data = shared.config.channelData local data = shared.config.channelData
if shared.config.channel == "CHANNEL" and not tonumber(shared.config.channelData) then if shared.config.channel == "CHANNEL" and not tonumber(shared.config.channelData) then
data = GetChannelId(shared.config.channelData) data = GetChannelId(shared.config.channelData)
if data == nil then
print(string.format("Yapper found no channel id for %s", shared.config.channelData))
shared.config.enabled = false
return
end
end end
SendChatMessage(shared.config.message, shared.config.channel, nil, data) SendChatMessage(shared.config.message, shared.config.channel, nil, data)
if not shared.config.interval or shared.config.interval <= 0 then if not shared.config.interval or shared.config.interval <= 0 then
print("Yapper has no interval set, quitting (%s)", tostring(shared.config.interval)) print("Yapper has no interval set, quitting (%s)", tostring(shared.config.interval))
shared.config.enabled = false
return return
end end
timer = C_Timer.NewTimer(shared.config.interval, Yap) timer = C_Timer.NewTimer(shared.config.interval, Yap)