-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
78 lines (68 loc) · 2.4 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
const open = require('open');
const axios = require('axios');
const fs = require('fs').promises;
const readline = require('readline');
const rl = readline.createInterface({input: process.stdin, output: process.stdout});
(async function()
{
try
{
const data = await fs.readFile('config.json', 'utf8');
const config = JSON.parse(data);
if (!config.apiKey || config.apiKey.trim() === '')
{
console.log('APIKEY not found, set it in the configuration file.');
return;
}
for (let id of config.steamIDs)
{
const linkPlayerBans = `http://api.steampowered.com/ISteamUser/GetPlayerBans/v1/?key=${config.apiKey}&steamids=${id}`;
try
{
const resBans = await axios.get(linkPlayerBans);
const playerBans = resBans.data.players[0];
if (!playerBans)
{
console.log(`Error fetching ban data for player: ${id}`);
continue;
}
if (playerBans.VACBanned || playerBans.CommunityBanned || playerBans.NumberOfGameBans != 0)
{
console.log(`\x1b[31mPlayer: ${id} | ✖\x1b[0m`);
const answer = await new Promise(resolve =>
{
rl.question('\x1b[33mOpen browser link? (Y/N): \x1b[0m', answer =>
{
resolve(answer);
});
});
if (answer.toUpperCase() === 'Y')
{
await open(`http://steamcommunity.com/profiles/${id}`);
}
}
else
{
console.log(`\x1b[32mPlayer: ${id} | ✔\x1b[0m`);
}
}
catch(error)
{
console.log(`Error fetching data for player: ${id}`);
}
}
}
catch(error)
{
console.log('The config.json file does not exist.');
return;
}
finally
{
rl.close();
console.log('Press any key to exit...');
process.stdin.setRawMode(true);
process.stdin.resume();
process.stdin.on('data', process.exit.bind(process, 0));
}
})();