feat: add initial first working query

This commit is contained in:
CosminPerRam 2024-04-08 19:41:52 +03:00
parent 4e6ab05291
commit 8c237980e2
2 changed files with 12 additions and 17 deletions

View File

@ -2092,7 +2092,7 @@ export const games = {
name: 'Palworld',
release_year: 2024,
options: {
port: 8211,
port: 8212,
protocol: 'palworld'
}
},

View File

@ -1,20 +1,15 @@
import Epic from './epic.js'
export default class palworld extends Epic {
constructor () {
super()
// OAuth2 credentials extracted from Palworld files.
this.clientId = 'xyza78916PZ5DF0fAahu4tnrKKyFpqRE'
this.clientSecret = 'j0NapLEPm3R3EOrlQiM8cRLKq3Rt02ZVVwT0SkZstSg'
this.deploymentId = '0a18471f93d448e2a1f60e47e03d3413'
this.authByExternalToken = true
}
import Core from './core.js'
export default class palworld extends Core {
async run (state) {
await super.run(state)
state.name = state.raw.attributes.NAME_s
state.numplayers = state.raw.attributes.PLAYERS_l
state.version = state.raw.attributes.VERSION_S
const url = `http://${this.options.host}:${this.options.port}/v1/api/info`
const headers = {
Authorization: `Basic ${Buffer.from(`${this.options.username}:${this.options.password}`).toString('base64')}`,
Accept: 'application/json'
}
const response = await this.request({ url, headers, method: 'GET' })
console.log(response)
}
}