diff --git a/CHANGELOG.md b/CHANGELOG.md index b6d6e32..68f325f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## To Be Released... ## 5.X.Y * Fix: detect BFBC2 Vietnam DLC as BFBC2 (By @cetteup #713) +* Feat: SCP: Secret Laboratory (2020) - Added support (#715, thanks @Draakoor) ## 5.3.1 * Fix: HTTP requests would end up making more retries than needed due to got's internal retry mechanism (#690, thanks @RattleSN4K3) diff --git a/GAMES_LIST.md b/GAMES_LIST.md index b1bb3f2..184f03c 100644 --- a/GAMES_LIST.md +++ b/GAMES_LIST.md @@ -279,6 +279,7 @@ | soulmask | Soulmask | [Valve Protocol](#valve) | | spaceengineers | Space Engineers | [Valve Protocol](#valve) | | squad | Squad | [Valve Protocol](#valve) | +| ssl | SCP: Secret Labratory | [Notes](#ssl) | | sstse | Serious Sam: The Second Encounter | | | stalker | S.T.A.L.K.E.R. | | | starbound | Starbound | [Valve Protocol](#valve) | @@ -554,3 +555,8 @@ have configured `TelnetEnabled` to `true`, `TelnetPort` and `TelnetPassword` and to the query parameters. To fetch more info via telnet (game and mods versions, date and time), at the cost of a longer query time, set `moreData` to `true`. + +### SCP: Secret Laboratory +Unfortunately, only verified servers can be queried, for this you'd need a `accountId`, an `apiKey` and `serverId` +(this optional, not providing this just returns the server list associated with the account in the raw object). + diff --git a/lib/games.js b/lib/games.js index 359249b..536df0e 100644 --- a/lib/games.js +++ b/lib/games.js @@ -2768,6 +2768,16 @@ export const games = { protocol: 'valve' } }, + ssl: { + name: 'SCP: Secret Labratory', + release_year: 2020, + options: { + protocol: 'scpsl' + }, + extra: { + doc_notes: 'ssl' + } + }, stalker: { name: 'S.T.A.L.K.E.R.', release_year: 2007, diff --git a/protocols/index.js b/protocols/index.js index 51e9a59..34c8498 100644 --- a/protocols/index.js +++ b/protocols/index.js @@ -73,11 +73,12 @@ import altvmp from './altvmp.js' import vintagestorymaster from './vintagestorymaster.js' import vintagestory from './vintagestory.js' import sdtd from './sdtd.js' +import scpsl from './scpsl.js' export { armagetron, ase, asa, assettocorsa, battlefield, brokeprotocol, brokeprotocolmaster, buildandshoot, cs2d, discord, doom3, eco, epic, factorio, farmingsimulator, ffow, fivem, gamespy1, gamespy2, gamespy3, geneshift, goldsrc, gtasao, hawakening, hawakeningmaster, hexen2, jc2mp, kspdmp, mafia2mp, mafia2online, minecraft, minecraftbedrock, minecraftvanilla, minetest, mumble, mumbleping, nadeo, openttd, palworld, quake1, quake2, quake3, renegadex, renegadexmaster, renown, rfactor, ragemp, samp, satisfactory, soldat, savage2, starmade, starsiege, teamspeak2, teamspeak3, terraria, toxikk, tribes1, tribes1master, unreal2, ut3, valve, - vcmp, ventrilo, warsow, eldewrito, beammpmaster, beammp, dayz, theisleevrima, xonotic, altvmp, vintagestorymaster, vintagestory, sdtd + vcmp, ventrilo, warsow, eldewrito, beammpmaster, beammp, dayz, theisleevrima, xonotic, altvmp, vintagestorymaster, vintagestory, sdtd, scpsl } diff --git a/protocols/scpsl.js b/protocols/scpsl.js new file mode 100644 index 0000000..8a6f57c --- /dev/null +++ b/protocols/scpsl.js @@ -0,0 +1,54 @@ +import Core from './core.js' + +export default class scpsl extends Core { + constructor () { + super() + this.usedTcp = true + } + + async run (state) { + const { accountId, apiKey, serverId } = this.options + + const request = await this.request({ + url: 'https://api.scpslgame.com/serverinfo.php', + responseType: 'json', + searchParams: { + id: accountId, + key: apiKey, + lo: true, + players: true, + list: true, + info: true, + pastebin: true, + version: true, + flags: true, + nicknames: true, + online: true + } + }) + + state.raw.request = request + + if (!serverId) { + return + } + + const servers = request?.Servers || [] + if (!servers.length) { + throw new Error('No servers provided.') + } + + const server = servers.find(server => server.ID.toString() === serverId) + + if (!server) { + throw new Error('Couldn\'t find the given server id.') + } + + state.version = server.Version + state.name = Buffer.from(server.Info, 'base64').toString() + + const [numplayers, maxplayers] = server.Players.split('/').map(Number) + state.numplayers = numplayers + state.maxplayers = maxplayers + } +}