mirror of
https://github.com/tribufu/node-gamedig
synced 2026-06-01 09:42:41 +00:00
feat: Add Factorio support (#527)
* Update eco protocol to include player names and fixed problems when using eco webinterface behind a proxy * changelog + readability * Typo * Typo * Added Factorio * wrong comment * CHANGELOG
This commit is contained in:
parent
3416e8c21a
commit
2338b82307
5 changed files with 37 additions and 1 deletions
25
protocols/factorio.js
Normal file
25
protocols/factorio.js
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import Core from './core.js'
|
||||
|
||||
export default class factorio extends Core {
|
||||
async run (state) {
|
||||
if (!this.options.port) this.options.port = 34197
|
||||
|
||||
// Don't use the tcp ping probing
|
||||
this.usedTcp = true
|
||||
|
||||
const request = await this.request({
|
||||
url: `https://multiplayer.factorio.com/get-game-details/${this.options.address}:${this.options.port}`,
|
||||
responseType: 'json'
|
||||
})
|
||||
|
||||
const serverInfo = request
|
||||
|
||||
state.name = serverInfo.name
|
||||
state.password = serverInfo.has_password
|
||||
state.numplayers = serverInfo.players?.length || 0 // players is undefined if there are no players
|
||||
state.maxplayers = serverInfo.max_players
|
||||
state.players = serverInfo.players?.map(player => ({ name: player, raw: {} })) || []
|
||||
|
||||
state.raw = serverInfo
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue