generated from Sovereignty/rojo-selene-luau-template
Add Error Popper's primary file
This commit is contained in:
parent
03386f0f04
commit
db7c524e43
1 changed files with 96 additions and 0 deletions
96
src/ServerStorage/ErrorPopper/init.lua
Normal file
96
src/ServerStorage/ErrorPopper/init.lua
Normal file
|
@ -0,0 +1,96 @@
|
||||||
|
local LogService = game:GetService("LogService")
|
||||||
|
local RunService = game:GetService("RunService")
|
||||||
|
|
||||||
|
|
||||||
|
local WebRequester = require(script.WebRequester)
|
||||||
|
local WebhookService = require(script.WebhookService)
|
||||||
|
|
||||||
|
|
||||||
|
local LastError = {}
|
||||||
|
local BlackListed = {}
|
||||||
|
|
||||||
|
local InStudio = RunService:IsStudio()
|
||||||
|
|
||||||
|
local function CheckDictionary(dict: { [string]: any })
|
||||||
|
for _, objects in dict do
|
||||||
|
return objects
|
||||||
|
end
|
||||||
|
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
local function OnMessageOut(message : string, messageType)
|
||||||
|
if messageType == Enum.MessageType.MessageError then
|
||||||
|
local List = message:split(":")
|
||||||
|
local Result = CheckErrorList(List[1],List[2],List[3])
|
||||||
|
|
||||||
|
if Result == false then
|
||||||
|
if InStudio and script.Configuration.StudioRun.Value == false then return end
|
||||||
|
WebRequester.RequestBotHook(List)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function CheckErrorList(Message,Line_Error,Error)
|
||||||
|
if BlackListed[Message] and BlackListed[Message]["Error"] == Error then return true end
|
||||||
|
|
||||||
|
if not LastError[Message] then
|
||||||
|
LastError[Message] = {
|
||||||
|
["Call_Count"] = 1,
|
||||||
|
["Line"] = Line_Error,
|
||||||
|
["Error"] = Error,
|
||||||
|
}
|
||||||
|
|
||||||
|
print("Popped Error") --Where the name comes from - tehehe
|
||||||
|
|
||||||
|
return false
|
||||||
|
elseif LastError[Message] then
|
||||||
|
if LastError[Message]["Error"] == Error then
|
||||||
|
LastError[Message]["Call_Count"] += 1
|
||||||
|
if LastError[Message]["Call_Count"] >= 2 then
|
||||||
|
LastError[CheckDictionary(LastError)] = nil
|
||||||
|
BlackListed[Message] = {
|
||||||
|
["Error"] = Error
|
||||||
|
}
|
||||||
|
if InStudio and script.Configuration.StudioRun.Value == false then return true end
|
||||||
|
|
||||||
|
WebRequester.RequestBotHook({Message,Line_Error,Error},true)
|
||||||
|
WebRequester.RequestBotMessage("Listed Error Will no longer be sent from Game_Id: "..game.GameId.." GameName: "..game.Name..
|
||||||
|
" "
|
||||||
|
)
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
local urlWasSet = false
|
||||||
|
local start = function()
|
||||||
|
if not urlWasSet then error("Please set a webhook URL for ErrorPopper to use.") end
|
||||||
|
if not RunService:IsServer() then error("ErrorPopper can only be used on/by the server!") end
|
||||||
|
|
||||||
|
WebRequester.AttachErrorFieldsToStackField()
|
||||||
|
LogService.MessageOut:Connect(OnMessageOut)
|
||||||
|
end
|
||||||
|
|
||||||
|
return {
|
||||||
|
SetURL = function(discordWebhookUrl: string)
|
||||||
|
urlWasSet = discordWebhookUrl ~= nil
|
||||||
|
local urlProxy = (discordWebhookUrl:gsub("discord%.com", "webhook.newstargeted.com")) .. "/queue"
|
||||||
|
local backurlProxy = (discordWebhookUrl:gsub("discord%.com", "webhook-proxy-jet.vercel.app"))
|
||||||
|
WebhookService.url = urlProxy
|
||||||
|
WebhookService.backupUrl = backurlProxy
|
||||||
|
|
||||||
|
return {
|
||||||
|
Start = start :: (self: any) -> ()
|
||||||
|
}
|
||||||
|
end,
|
||||||
|
|
||||||
|
CustomFields = WebRequester.CreateFields,
|
||||||
|
|
||||||
|
Start = start,
|
||||||
|
}
|
Loading…
Reference in a new issue