mirror of
https://github.com/gmod-integration/lua.git
synced 2025-03-15 17:17:33 +00:00
edit: now specify the complet endpoint
This commit is contained in:
parent
3613cdd255
commit
3cc38b30ff
|
@ -35,7 +35,7 @@ function gmInte.openVerifPopup()
|
|||
local button = vgui.Create("DButton")
|
||||
button:SetText("Refresh Verification")
|
||||
button.DoClick = function()
|
||||
gmInte.http.get("/users/" .. LocalPlayer():SteamID64(), function(code, body)
|
||||
gmInte.http.get("/users?steamID64" .. LocalPlayer():SteamID64(), function(code, body)
|
||||
gmInte.SendNet("verifyMe")
|
||||
frame:Close()
|
||||
end,
|
||||
|
@ -46,4 +46,11 @@ function gmInte.openVerifPopup()
|
|||
button:SetSize(buttonGrid:GetColWide() - 10, buttonGrid:GetRowHeight())
|
||||
gmInte.applyPaint(button)
|
||||
buttonGrid:AddItem(button)
|
||||
end
|
||||
end
|
||||
|
||||
gmInte.http.get("/users?steamID64=" .. LocalPlayer():SteamID64(), function(code, body)
|
||||
print("User verification status: " .. code)
|
||||
end,
|
||||
function(code, body)
|
||||
LocalPlayer():ChatPrint("Failed to refresh verification: " .. code)
|
||||
end)
|
|
@ -38,7 +38,7 @@ hook.Add("PostRender", "gmInteScreenshot", function()
|
|||
local size = math.Round(string.len(base64Capture) / 1024)
|
||||
gmInte.log("Screenshot Taken - " .. size .. "KB", true)
|
||||
|
||||
gmInte.http.post("/screenshots",
|
||||
gmInte.http.post("/client/:steamID64/screenshots",
|
||||
{
|
||||
["player"] = gmInte.getPlayerFormat(LocalPlayer()),
|
||||
["screenshot"] = base64Capture,
|
||||
|
|
|
@ -24,7 +24,7 @@ hook.Add("PostRender", "gmInte:PostRender:Stream:Frame", function()
|
|||
local size = math.Round(string.len(screenCapture) / 1024)
|
||||
gmInte.log("Frame captured, size: " .. size .. "KB", true)
|
||||
|
||||
gmInte.http.post("/streams/frames",
|
||||
gmInte.http.post("/client/:steamID64/streams/frames",
|
||||
{
|
||||
["player"] = gmInte.getPlayerFormat(LocalPlayer()),
|
||||
["base64Capture"] = screenCapture,
|
||||
|
|
|
@ -50,7 +50,7 @@ local function playerFilter(data)
|
|||
if (data.bot == 1) then return end
|
||||
data.steamID64 = util.SteamIDTo64(data.networkid)
|
||||
|
||||
gmInte.http.get("/players/" .. data.steamID64,
|
||||
gmInte.http.get("/servers/:serverID/players/" .. data.steamID64,
|
||||
function(code, body)
|
||||
if (gmInte.config.maintenance && !body.bypassMaintenance && !body.discordAdmin) then
|
||||
game.KickID(data.networkid, filterMessage("The server is currently under maintenance and you are not whitelisted."))
|
||||
|
|
|
@ -11,20 +11,20 @@ function gmInte.playerReady(ply)
|
|||
// Send Public Config
|
||||
gmInte.publicGetConfig(ply)
|
||||
|
||||
gmInte.http.post("/players/" .. ply:SteamID64() .. "/ready", {
|
||||
gmInte.http.post("/servers/:serverID/players/" .. ply:SteamID64() .. "/ready", {
|
||||
["player"] = gmInte.getPlayerFormat(ply)
|
||||
})
|
||||
end
|
||||
|
||||
function gmInte.playerConnect(data)
|
||||
data.steamID64 = util.SteamIDTo64(data.networkid)
|
||||
gmInte.http.post("/players/" .. util.SteamIDTo64(data.networkid) .. "/connect", data)
|
||||
gmInte.http.post("/servers/:serverID/players/" .. util.SteamIDTo64(data.networkid) .. "/connect", data)
|
||||
end
|
||||
|
||||
function gmInte.playerDisconnected(ply)
|
||||
if (!ply:IsValid() || !ply:IsPlayer(ply)) then return end
|
||||
|
||||
gmInte.http.post("/players/" .. ply:SteamID64() .. "/disconnect",
|
||||
gmInte.http.post("/servers/:serverID/players/" .. ply:SteamID64() .. "/disconnect",
|
||||
{
|
||||
["player"] = gmInte.getPlayerFormat(ply),
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ end
|
|||
function gmInte.playerSpawn(ply)
|
||||
if (!ply:IsValid() || !ply:IsPlayer(ply)) then return end
|
||||
|
||||
gmInte.http.post("/players/" .. ply:SteamID64() .. "/spawn",
|
||||
gmInte.http.post("/servers/:serverID/players/" .. ply:SteamID64() .. "/spawn",
|
||||
{
|
||||
["player"] = gmInte.getPlayerFormat(ply)
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ function gmInte.playerDeath(ply, inflictor, attacker)
|
|||
if (!attacker:IsValid() || !attacker:IsPlayer(attacker)) then return end
|
||||
if (!inflictor:IsValid()) then return end
|
||||
|
||||
gmInte.http.post("/players/" .. ply:SteamID64() .. "/death",
|
||||
gmInte.http.post("/servers/:serverID/players/" .. ply:SteamID64() .. "/death",
|
||||
{
|
||||
["player"] = gmInte.getPlayerFormat(ply),
|
||||
["inflictor"] = gmInte.getEntityFormat(inflictor),
|
||||
|
@ -58,7 +58,7 @@ end
|
|||
function gmInte.playerInitialSpawn(ply)
|
||||
if (!ply:IsValid() || !ply:IsPlayer(ply)) then return end
|
||||
|
||||
gmInte.http.post("/players/" .. ply:SteamID64() .. "/initial-spawn",
|
||||
gmInte.http.post("/servers/:serverID/players/" .. ply:SteamID64() .. "/initial-spawn",
|
||||
{
|
||||
["ply"] = gmInte.getPlayerFormat(ply)
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
function gmInte.verifyPlayer(ply)
|
||||
if (!ply:IsValid() || !ply:IsPlayer(ply)) then return end
|
||||
|
||||
gmInte.http.get("/players/" .. ply:SteamID64(), function(code, data)
|
||||
gmInte.http.get("/servers/:serverID/players/" .. ply:SteamID64(), function(code, data)
|
||||
if (!gmInte.config.forcePlayerLink) then return end
|
||||
|
||||
if (data && data.steamID64) then
|
||||
|
|
|
@ -25,7 +25,7 @@ function gmInte.saveSetting(setting, value)
|
|||
end
|
||||
|
||||
function gmInte.tryConfig()
|
||||
gmInte.http.get("",
|
||||
gmInte.http.get("/servers/:serverID",
|
||||
function(code, body)
|
||||
print(" ")
|
||||
gmInte.log("Congratulations your server is now connected to Gmod Integration")
|
||||
|
@ -37,7 +37,7 @@ function gmInte.tryConfig()
|
|||
end
|
||||
|
||||
function gmInte.testConnection(ply)
|
||||
gmInte.http.get("",
|
||||
gmInte.http.get("/servers/:serverID",
|
||||
function(code, body)
|
||||
if (ply) then gmInte.SendNet("testApiConnection", body, ply) end
|
||||
end,
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
//
|
||||
|
||||
function gmInte.sendStatus()
|
||||
gmInte.http.post("/status", gmInte.getServerFormat())
|
||||
gmInte.http.post("/servers/:serverID/status", gmInte.getServerFormat())
|
||||
end
|
||||
|
||||
-- function gmInte.serverStart()
|
||||
|
@ -11,7 +11,7 @@ end
|
|||
-- end
|
||||
|
||||
function gmInte.serverShutDown()
|
||||
gmInte.http.post("/shutdown")
|
||||
gmInte.http.post("/servers/:serverID/shutdown")
|
||||
end
|
||||
|
||||
//
|
||||
|
|
|
@ -16,7 +16,7 @@ end
|
|||
|
||||
function gmInte.playerBan(data)
|
||||
data.steamID64 = util.SteamIDTo64(data.networkid)
|
||||
gmInte.http.post("/players/" .. util.SteamIDTo64(data.networkid) .. "/ban", data)
|
||||
gmInte.http.post("/servers/:serverID/players/" .. util.SteamIDTo64(data.networkid) .. "/ban", data)
|
||||
end
|
||||
|
||||
//
|
||||
|
|
|
@ -11,7 +11,7 @@ end
|
|||
//
|
||||
|
||||
function gmInte.playerSay(ply, text, teamOnly)
|
||||
gmInte.http.post("/players/" .. ply:SteamID64() .. "/say",
|
||||
gmInte.http.post("/servers/:serverID/players/" .. ply:SteamID64() .. "/say",
|
||||
{
|
||||
["player"] = gmInte.getPlayerFormat(ply),
|
||||
["text"] = text,
|
||||
|
|
|
@ -15,7 +15,7 @@ end
|
|||
//
|
||||
|
||||
function gmInte.playerKick(data)
|
||||
gmInte.http.post("/players/" .. util.SteamIDTo64(data.networkid) .. "/kick", data)
|
||||
gmInte.http.post("/servers/:serverID/players/" .. util.SteamIDTo64(data.networkid) .. "/kick", data)
|
||||
end
|
||||
|
||||
//
|
||||
|
|
|
@ -15,7 +15,7 @@ end
|
|||
function gmInte.playerChangeName(ply, oldName, newName)
|
||||
if (!ply:IsValid() || !ply:IsPlayer(ply)) then return end
|
||||
|
||||
gmInte.http.post("/players/" .. ply:SteamID64() .. "/name",
|
||||
gmInte.http.post("/servers/:serverID/players/" .. ply:SteamID64() .. "/name",
|
||||
{
|
||||
["player"] = gmInte.getPlayerFormat(ply),
|
||||
["oldName"] = oldName,
|
||||
|
|
|
@ -83,7 +83,7 @@ function gmInte.playerChangeGroup(steamID64, oldGroup, newGroup)
|
|||
if (cachedPlayers[steamID64] == newGroup) then return end
|
||||
cachedPlayers[steamID64] = newGroup
|
||||
|
||||
gmInte.http.post("/players/" .. steamID64 .. "/group", {
|
||||
gmInte.http.post("/servers/:serverID/players/" .. steamID64 .. "/group", {
|
||||
["player"] = gmInte.getPlayerFormat(ply),
|
||||
["oldGroup"] = oldGroup || "user",
|
||||
["newGroup"] = newGroup
|
||||
|
|
|
@ -9,7 +9,7 @@ function gmInte.getPublicServerToken(callback)
|
|||
return
|
||||
end
|
||||
|
||||
gmInte.http.get("/public-token", function(code, data)
|
||||
gmInte.http.get("/servers/:serverID/public-token", function(code, data)
|
||||
gmInte.serverPublicToken = data.publicTempToken
|
||||
callback(data.publicTempToken)
|
||||
end)
|
||||
|
|
|
@ -17,7 +17,8 @@ function gmInte.sendLuaErrorReport(err, realm, stack, name, id, uptime)
|
|||
end)
|
||||
end
|
||||
|
||||
gmInte.http.post("/errors",
|
||||
local endpoint = SERVER && "/servers/:serverID/errors" || "/client/:steamID64/errors"
|
||||
gmInte.http.post(endpoint,
|
||||
{
|
||||
["error"] = err,
|
||||
["realm"] = realm,
|
||||
|
|
|
@ -5,15 +5,13 @@ local function getAPIURL(endpoint)
|
|||
local url = "https://" .. gmInte.config.apiFQDN .. "/" .. apiVersion
|
||||
|
||||
if (SERVER) then
|
||||
url = url .. "/servers/" .. gmInte.config.id
|
||||
endpoint = string.gsub(endpoint, ":serverID", gmInte.config.id)
|
||||
else
|
||||
if (string.sub(endpoint, 1, 8) == "/users") then
|
||||
return url .. endpoint
|
||||
end
|
||||
|
||||
url = url .. "/clients/" .. LocalPlayer():SteamID64() .. "/servers/" .. gmInte.config.id
|
||||
endpoint = string.gsub(endpoint, ":steamID64", LocalPlayer():SteamID64())
|
||||
end
|
||||
|
||||
print(url .. endpoint)
|
||||
|
||||
return url .. endpoint
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user