multiple gameservers -> config
This commit is contained in:
parent
264f463a8f
commit
57b08f568d
|
@ -1,8 +1,10 @@
|
||||||
import fetch from 'flumm-fetch-cookies';
|
import fetch from 'flumm-fetch-cookies';
|
||||||
import { SourceQuerySocket } from 'source-server-query';
|
import { SourceQuerySocket } from 'source-server-query';
|
||||||
|
import config from "../config.mjs";
|
||||||
|
|
||||||
const ssq = new SourceQuerySocket();
|
const ssq = new SourceQuerySocket();
|
||||||
|
|
||||||
const link = "https://api.steampowered.com/ISteamApps/GetServersAtAddress/v0001?addr=135.181.16.244";
|
const api = ip => `${config.apis.gameserver.api}${ip}`;
|
||||||
|
|
||||||
export default async bot => {
|
export default async bot => {
|
||||||
|
|
||||||
|
@ -11,19 +13,17 @@ export default async bot => {
|
||||||
call: /^(\.|\/)gs/i,
|
call: /^(\.|\/)gs/i,
|
||||||
clients: ['tg','irc'],
|
clients: ['tg','irc'],
|
||||||
f: async e => {
|
f: async e => {
|
||||||
const servers = (await (await fetch(link)).json()).response.servers;
|
for(const ip of config.apis.gameserver.ips) {
|
||||||
|
const servers = (await (await fetch(api(ip))).json()).response.servers;
|
||||||
|
|
||||||
servers.forEach(async s => {
|
servers.forEach(async s => {
|
||||||
const [ _server, _port ] = s.addr.split(':');
|
const [ _server, _port ] = s.addr.split(':');
|
||||||
const info = await ssq.info(_server, _port, 1000);
|
const info = await ssq.info(_server, _port, 1000);
|
||||||
const players = await ssq.players(_server, _port, 1000);
|
const players = await ssq.players(_server, _port, 1000);
|
||||||
|
|
||||||
e.reply([
|
e.reply(`${info.name} (${info.folder}) - map: ${info.map} - players ${info.players}/${info.max_players}${info.players > 0 ? ": " + players.map(p => p.name).join(", ") : ""}`);
|
||||||
`${info.name} (${info.folder})`,
|
});
|
||||||
`map: ${info.map}`,
|
}
|
||||||
`players: ${info.players}/${info.max_players}${info.players > 0 ? ": " + players.map(p => p.name).join(", ") : ""}`
|
|
||||||
].join("\n"));
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user