Add Eco (2018) support. (#363)

* Add initial working eco query

* Add default port and add the game to games.txt

* Add to changelog

* Fix request Info object and add to raw the object

* Rearrange some code to be more readable
This commit is contained in:
CosminPerRam 2023-09-17 13:01:39 +03:00 committed by GitHub
parent 17f91904ab
commit 328d518d5b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 24 additions and 1 deletions

19
protocols/eco.js Normal file
View file

@ -0,0 +1,19 @@
import Core from './core.js';
export default class eco extends Core {
async run(state) {
if (!this.options.port) this.options.port = 3001;
const request = await this.request({
url: `http://${this.options.address}:${this.options.port}/frontpage`,
responseType: 'json'
});
const serverInfo = request.Info;
state.name = serverInfo.Description;
state.maxplayers = serverInfo.TotalPlayers;
state.password = serverInfo.HasPassword;
state.gamePort = serverInfo.GamePort;
state.raw = serverInfo;
}
}