node-gamedig/tools/attempt_protocols.js
RattleSN4K3 d2397b67e7
feat: add Hawakening support (#648)
* Add support for Hawakening, querying master server

* Outsource backend calls into Api class

* Define json response via schema, optional data validation with Ajv (commented out)

* Add support for Hawakening master query through separate protocol

Protocol 'hawakeningmaster' provides full list of processed server info

* docs: update CHANGELOG and GAMES_LIST for Hawakening

* Additional API check + cleanup

* Allowing public/non-authorized master server query for Hawkening severs

* Fix: Reference the master protocol correctly in docs/games_list

* Reorganized code file, moved schema and API-class to the end
2024-10-12 17:51:56 +03:00

41 lines
1.1 KiB
JavaScript

import Minimist from 'minimist'
import { GameDig } from './../lib/index.js'
import * as protocols from './../protocols/index.js'
const argv = Minimist(process.argv.slice(2), {})
const options = {}
if (argv._.length >= 1) {
const target = argv._[0]
const split = target.split(':')
options.host = split[0]
if (split.length >= 2) {
options.port = split[1]
}
options.debug = argv._[1] === 'debug'
}
const gamedig = new GameDig(options)
const protocolList = []
Object.keys(protocols).forEach((key) => protocolList.push(key))
const ignoredProtocols = ['discord', 'beammpmaster', 'beammp', 'teamspeak2', 'teamspeak3', 'vintagestorymaster', 'renegadexmaster', 'hawakeningmaster']
const protocolListFiltered = protocolList.filter((protocol) => !ignoredProtocols.includes(protocol))
const run = async () => {
for (const protocol of protocolListFiltered) {
try {
const response = await gamedig.query({
...options,
type: `protocol-${protocol}`
})
console.log(`Success on '${protocol}':`, response)
process.exit()
} catch (e) {
console.log(`Error on '${protocol}': ${e}`)
}
}
}
run().then(() => {})