Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
28 changes: 13 additions & 15 deletions src/ServerScriptService/MainSystem.server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,21 @@ local Players = game:GetService("Players")
-- Example #1: Kicking Players if Datastores are down.

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")== "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. =")
Comment thread
J-Man775 marked this conversation as resolved.
Outdated
end
end)

-- Example #2 Printing latest tests if something is down or not.
-- Example #2 Printing the Roblox website's status every 5 minutes.

while true do
Comment thread
J-Man775 marked this conversation as resolved.
Outdated
if DowntimeService:GetSiteStatus() == "down" then

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!")
local siteStatus = DowntimeService.statusFromAlias("site")
if siteStatus == "Down" then
Comment thread
J-Man775 marked this conversation as resolved.
Outdated
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
wait(300)
end
wait(300)
end