forked from DoseOfCode/buff-163-trader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
70 lines (54 loc) · 1.71 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
const config = require('./config.json');
const Buff163 = require('./Buff163');
const SteamUser = require('steam-user');
const SteamTotp = require('steam-totp');
const SteamCommunity = require('steamcommunity');
const TradeOfferManager = require('steam-tradeoffer-manager');
const steamClient = new SteamUser();
const community = new SteamCommunity();
const manager = new TradeOfferManager({
steam: steamClient,
community: community,
language: 'en'
});
steamClient.on('loggedOn', async () =>
{
console.log(`[Steam] Logged into ${config.steam.username}`);
steamClient.setPersona(SteamUser.EPersonaState.Online);
steamClient.gamesPlayed(730);
});
steamClient.on('webSession', (sessionid, cookies) =>
{
console.log(`[Steam] Web session started (${sessionid})`);
manager.setCookies(cookies);
community.setCookies(cookies);
community.startConfirmationChecker(manager.pollInterval, config.steam.identity_secret);
});
function Login()
{
steamClient.logOn({
accountName: config.steam.username,
password: config.steam.password,
twoFactorCode: SteamTotp.generateAuthCode(config.steam.shared_secret)
});
setInterval(
async () =>
{
let ids = await Buff163.GetTradesToAccept();
console.log(`[Buff] Found ${ids.length} trades to accept.`)
for (let id of ids)
{
manager.getOffer(
id,
(err, offer) =>
{
if (!err)
offer.accept((_err, _status) => { });
}
);
}
},
60 * 1000
);
}
Login();