Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
173 changes: 19 additions & 154 deletions src/ServerScriptService/MainModule.lua
Original file line number Diff line number Diff line change
@@ -1,167 +1,32 @@
local DowntimeService = {}

local HttpService = game:GetService("HttpService")
local sumurl = "https://raw.githubusercontent.com/Status-Plus/StatusPlus/master/history/summary.json"
local StatSummary = "https://api.statusplus.xyz/status"

function ReturnTableThroughSlug(slug, data)
function DowntimeService.statusFromAlias(alias)
local jsonData = HttpService:GetAsync(StatSummary)
local data = HttpService:JSONDecode(jsonData)
if data then
for i, value in ipairs(data) do
if value["slug"] == slug then
return value
for _, apiTable in ipairs(data) do
for _, apiAlias in ipairs(apiTable.aliases) do
if apiAlias == alias then
return apiTable.status
end
end
end
end
end

function DowntimeService.GetSiteStatus()

local GetStatus = HttpService:GetAsync(sumurl)

local Data = HttpService:JSONDecode(GetStatus)
local Table = ReturnTableThroughSlug("roblox-site", Data)

return Table.status -- Will return "up", "degraded" or "down"
end

function DowntimeService.GetDevForumStatus()

local GetStatus = HttpService:GetAsync(sumurl)

local Data = HttpService:JSONDecode(GetStatus)
local Table = ReturnTableThroughSlug("roblox-devforum", Data)

return Table.status -- Will return "up", "degraded" or "down"
end

function DowntimeService.GetDevHubStatus()

local GetStatus = HttpService:GetAsync(sumurl)

local Data = HttpService:JSONDecode(GetStatus)
local Table = ReturnTableThroughSlug("roblox-devhub", Data)

return Table.status -- Will return "up", "degraded" or "down"
end

function DowntimeService.GetAvatarAPIStatus()

local GetStatus = HttpService:GetAsync(sumurl)

local Data = HttpService:JSONDecode(GetStatus)
local Table = ReturnTableThroughSlug("avatar-api-endpoint", Data)

return Table.status
end

function DowntimeService.GetBadgesAPIStatus()

local GetStatus = HttpService:GetAsync(sumurl)

local Data = HttpService:JSONDecode(GetStatus)
local Table = ReturnTableThroughSlug("badges-api-endpoint", Data)

return Table.status -- Will return "up", "degraded" or "down"
end

function DowntimeService.GetCDNAPIStatus()

local GetStatus = HttpService:GetAsync(sumurl)

local Data = HttpService:JSONDecode(GetStatus)
local Table = ReturnTableThroughSlug("cdn-api-endpoint", Data)

return Table.status -- Will return "up", "degraded" or "down"
end

function DowntimeService.GetCatalogAPIStatus()

local GetStatus = HttpService:GetAsync(sumurl)

local Data = HttpService:JSONDecode(GetStatus)
local Table = ReturnTableThroughSlug("catalog-api-endpoint", Data)

return Table.status -- Will return "up", "degraded" or "down"
end

function DowntimeService.GetDatastoreAPIStatus()

local GetStatus = HttpService:GetAsync(sumurl)

local Data = HttpService:JSONDecode(GetStatus)
local Table = ReturnTableThroughSlug("datastore-api-endpoint", Data)

return Table.status -- Will return "up", "degraded" or "down"
end


function DowntimeService.GetDevelopAPIStatus()

local GetStatus = HttpService:GetAsync(sumurl)

local Data = HttpService:JSONDecode(GetStatus)
local Table = ReturnTableThroughSlug("develop-api-endpoint", Data)

return Table.status -- Will return "up", "degraded" or "down"
end

function DowntimeService.GetFriendsAPIStatus()

local GetStatus = HttpService:GetAsync(sumurl)

local Data = HttpService:JSONDecode(GetStatus)
local Table = ReturnTableThroughSlug("friends-api-endpoint", Data)

return Table.status -- Will return "up", "degraded" or "down"
end

function DowntimeService.GetGameJoinAPIStatus()

local GetStatus = HttpService:GetAsync(sumurl)

local Data = HttpService:JSONDecode(GetStatus)
local Table = ReturnTableThroughSlug("game-join-api-endpoint", Data)

return Table.status -- Will return "up", "degraded" or "down"
end

function DowntimeService.GetGroupsAPIStatus()

local GetStatus = HttpService:GetAsync(sumurl)

local Data = HttpService:JSONDecode(GetStatus)
local Table = ReturnTableThroughSlug("groups-api-endpoint", Data)

return Table.status -- Will return "up", "degraded" or "down"
end

function DowntimeService.GetInventoryAPIStatus()

local GetStatus = HttpService:GetAsync(sumurl)

local Data = HttpService:JSONDecode(GetStatus)
local Table = ReturnTableThroughSlug("inventory-api-endpoint", Data)

return Table.status -- Will return "up", "degraded" or "down"
end

function DowntimeService.GetTextFilterAPIStatus()

local GetStatus = HttpService:GetAsync(sumurl)

local Data = HttpService:JSONDecode(GetStatus)
local Table = ReturnTableThroughSlug("text-filter-api-endpoint", Data)

return Table.status -- Will return "up", "degraded" or "down"
end

function DowntimeService.GetThumbnailsAPIStatus()

local GetStatus = HttpService:GetAsync(sumurl)

local Data = HttpService:JSONDecode(GetStatus)
local Table = ReturnTableThroughSlug("thumbnails-api-endpoint", Data)

return Table.status -- Will return "up", "degraded" or "down"
function DowntimeService.statusFromName(name)
local jsonData = HttpService:GetAsync(StatSummary)
local data = HttpService:JSONDecode(jsonData)
if data then
for _, apiTable in ipairs(data) do
if apiTable.name == name then
return apiTable.status
end
end
end
end

return DowntimeService
44 changes: 26 additions & 18 deletions src/ServerScriptService/MainSystem.server.lua
Original file line number Diff line number Diff line change
@@ -1,26 +1,34 @@
local DowntimeService = require(6317978171) -- Or require by using the file path. (Requiring by ID is better for quicker updates.)
local Players = game:GetService("Players")

-- Example #1: Kicking Players if Datastores are down.
-- Example #1: Kicking Players if Datastores are down and the variable is set to true.

local kickPlayers = true

Players.PlayerAdded:Connect(function(player)
if DowntimeService:GetDatastoreAPIStatus() == "down" then
player:Kick("Datastores are currently down. To prevent critical errors we have kicked you. If this issue persits please contact the game owner. =")
end
if DowntimeService.statusFromAlias("datastore"):lower() == "down" then
if kickPlayers then
player:Kick("Datastores are currently down. To prevent critical errors we have kicked you. If this issue persits please contact the game owner. =)")
end
end
end)

-- Example #2 Printing latest tests if something is down or not.

while true do

if DowntimeService:GetSiteStatus() == "down" then
-- Example #2 Printing the Roblox website's status every 5 minutes.

warn("Roblox Website is Currently Down! Please be patient while Roblox works on a fix! :)")

elseif DowntimeService.GetSiteStatus() == "degraded" then
print("Roblox Website is Currently slow! Please be patient while Roblox works on it! :)")
elseif DowntimeService:GetSiteStatus() == "up" then
print("Roblox website is currently up!")
end
wait(300)
end
local debounce = false
game:GetService('RunService').Heartbeat:Connect(function()
if debounce then return end
coroutine.wrap(function()
debounce = true
task.wait(300) -- 300 seconds so 5 minutes.
debounce = false
end)()
local siteStatus = DowntimeService.statusFromAlias("site"):lower()
if siteStatus == "down" then
warn("Roblox Website is Currently Down! Please be patient while Roblox works on a fix! :)")
elseif siteStatus == "degraded" then
print("Roblox Website is Currently slow! Please be patient while Roblox works on it! :)")
elseif siteStatus == "up" then
print("Roblox website is currently up!")
end
end)