Skip to content

Commit c812655

Browse files
authored
Made serverinfo use a better API (#2073)
1 parent 994aa7e commit c812655

File tree

6 files changed

+48
-8
lines changed

6 files changed

+48
-8
lines changed

MainModule/Client/UI/Default/ServerDetails.luau

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ return function(data, env)
170170
if data.ServerInternetInfo then
171171
local serii = data.ServerInternetInfo
172172
for _, v in ipairs({
173-
{"Timezone", serii.timezone or "[Error]"},
173+
-- {"Timezone", serii.timezone or "[Error]"},
174174
{"Country", serii.country or "[Error]"},
175175
{"Region", serii.region or "[Error]"},
176176
{"City", serii.city or "[Error]"},

MainModule/Server/Commands/Moderators.luau

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7450,5 +7450,21 @@ return function(Vargs, env)
74507450
end
74517451
end
74527452
};
7453+
7454+
RefreshServerLocation = {
7455+
Prefix = Settings.Prefix;
7456+
Commands = {"refreshserverlocation"};
7457+
Args = {};
7458+
Description = `Refreshes the server location shown in {Settings.PlayerPrefix}serverinfo`;
7459+
AdminLevel = "Moderators";
7460+
Function = function(plr: Player, args: {string})
7461+
local res = Functions.FetchServerInfo()
7462+
if type(res) == "table" then
7463+
Variables.IPInfo = res
7464+
Functions.Hint(`You have refreshed the server location info`, {plr})
7465+
return
7466+
end
7467+
end
7468+
};
74537469
}
74547470
end

MainModule/Server/Commands/Players.luau

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -703,10 +703,8 @@ return function(Vargs, env)
703703
Args = {};
704704
Description = "Shows the current time and date.";
705705
AdminLevel = "Players";
706-
707706
Function = function(plr: Player)
708707
local now = os.time()
709-
710708
Remote.MakeGui(plr, "List", {
711709
Title = "Time & Date";
712710
Table = {
@@ -862,7 +860,7 @@ return function(Vargs, env)
862860
local elevated = Admin.CheckAdmin(plr)
863861

864862
local serverInfo = select(2, xpcall(function()
865-
local res = Variables.IPInfo or service.HttpService:JSONDecode(service.HttpService:GetAsync(Variables.IPInfoUrl))
863+
local res = Variables.IPInfo or Functions.FetchServerInfo()
866864
if not Variables.IPInfo then
867865
Variables.IPInfo = res
868866
end
@@ -871,7 +869,7 @@ return function(Vargs, env)
871869
city = res.city,
872870
region = res.region,
873871
zipcode = res.postal or "N/A",
874-
timezone = res.timezone,
872+
timezone = "N/A",
875873
ip = elevated and res.ip or "[Redacted]",
876874
coords = elevated and string.format("LAT: %s, LON: %s", string.match(res.loc, "(.*),(.*)")) or "[Redacted]",
877875
}

MainModule/Server/Core/Functions.luau

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1665,7 +1665,33 @@ return function(Vargs, GetEnv)
16651665
GetMainPrefix = function()
16661666
if type(Settings.Prefix) == "table" then return Settings.Prefix[1] else return Settings.Prefix end
16671667
end;
1668+
1669+
FetchServerInfo = function()
1670+
local _, ServerInfo = xpcall(function()
1671+
local res = service.HttpService:JSONDecode(
1672+
service.HttpService:GetAsync(Variables.IPInfoUrl, false, {["referer"] = "https://roblox.com"})
1673+
)
1674+
1675+
if res.latitude and res.longitude then
1676+
res.loc = `{res.latitude},{res.longitude}`
1677+
end
1678+
1679+
return {
1680+
country = res.country or "N/A",
1681+
city = res.city or "N/A",
1682+
region = res.region or "N/A",
1683+
postal = res.postalCode or "N/A",
1684+
timezone = "N/A", -- not supported. Keeping it just incase.
1685+
ip = res.ip or "N/A",
1686+
loc = res.loc or "N/A",
1687+
}
1688+
end, function()
1689+
return
1690+
end)
1691+
1692+
return ServerInfo
1693+
end
16681694
}
16691695

16701696

1671-
end
1697+
end

MainModule/Server/Core/Variables.luau

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ return function(Vargs, GetEnv)
8585
WebPanel_Initiated = false,
8686
DeveloperWhitelist = {1237666, 76328606, 698712377},
8787
HTTPCheckUrl = "https://www.google.com/humans.txt",
88-
IPInfoUrl = "https://ipinfo.io/json",
88+
IPInfoUrl = "https://speed.cloudflare.com/meta",
8989
SizeLimit = 20,
9090
ChatCreateRobloxCommands = true,
9191
OriginalGravity = workspace.Gravity,

MainModule/Shared/Credits.luau

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ return {
2525
{Text = "@ccuser44", Desc = "Open Source Contributor"};
2626
{Text = "@Awesomewebm", Desc = "Open Source Contributor"};
2727
{Text = "@TheLegendarySpark",Desc = "Open Source Contributor"};
28-
{Text = "@EasternBloxxer", Desc = "Open Source Contributor"};
28+
{Text = "@krampuszc", Desc = "Open Source Contributor"};
2929
{Text = "@Dimenpsyonal", Desc = "Open Source Contributor"};
3030
{Text = "@policetonyR", Desc = "Open Source Contributor"};
3131
{Text = "@EpicFazbear", Desc = "Open Source Contributor"};

0 commit comments

Comments
 (0)