multiple gameservers -> config
This commit is contained in:
parent
264f463a8f
commit
0b0971b6d5
|
@ -1,8 +1,10 @@
|
|||
import fetch from 'flumm-fetch-cookies';
|
||||
import { SourceQuerySocket } from 'source-server-query';
|
||||
import config from "../config.mjs";
|
||||
|
||||
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 => {
|
||||
|
||||
|
@ -11,19 +13,17 @@ export default async bot => {
|
|||
call: /^(\.|\/)gs/i,
|
||||
clients: ['tg','irc'],
|
||||
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 => {
|
||||
const [ _server, _port ] = s.addr.split(':');
|
||||
const info = await ssq.info(_server, _port, 1000);
|
||||
const players = await ssq.players(_server, _port, 1000);
|
||||
servers.forEach(async s => {
|
||||
const [ _server, _port ] = s.addr.split(':');
|
||||
const info = await ssq.info(_server, _port, 1000);
|
||||
const players = await ssq.players(_server, _port, 1000);
|
||||
|
||||
e.reply([
|
||||
`${info.name} (${info.folder})`,
|
||||
`map: ${info.map}`,
|
||||
`players: ${info.players}/${info.max_players}${info.players > 0 ? ": " + players.map(p => p.name).join(", ") : ""}`
|
||||
].join("\n"));
|
||||
});
|
||||
e.reply(`${info.name} (${info.folder}) - map: ${info.map} - players ${info.players}/${info.max_players}${info.players > 0 ? ": " + players.map(p => p.name).join(", ") : ""}`);
|
||||
});
|
||||
}
|
||||
}
|
||||
}];
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user