-
Notifications
You must be signed in to change notification settings - Fork 4
/
bot.js
55 lines (46 loc) · 1.52 KB
/
bot.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
const SteamUser = require('steam-user');
const SteamTotp = require('steam-totp');
const SteamCommunity = require('steamcommunity');
const TradeOfferManager = require('steam-tradeoffer-manager');
const config = require('./config.json');
const client = new SteamUser();
const community = new SteamCommunity();
const manager = new TradeOfferManager ({
steam: client,
community: community,
language: 'en'
});
const logOnOptions = {
accountName: config.username,
password: config.password,
twoFactorCode: SteamTotp.generateAuthCode(config.sharedSecret)
};
client.logOn(logOnOptions);
client.on('loggedOn', () => {
console.log('succesfully logged on.');
client.setPersona(SteamUser.Steam.EPersonaState.Online);
client.gamesPlayed(["404"]);
});
client.on("friendMessage", function(steamID, message) {
if (message == "!help") {
client.chatMessage(steamID, "Hello!, At the moment this bot isn't available for trades. It will be 15 days away from: Wednesday - 3 January - 2018 ");
}
});
client.on('webSession', (sessionid, cookies) => {
manager.setCookies(cookies);
community.setCookies(cookies);
community.startConfirmationChecker(10000, config.identitySecret);
});
function acceptOffer(offer) {
offer.accept((err) => {
community.checkConfirmations();
console.log("We Accepted an offer");
if (err) console.log("There was an error accepting the offer.");
});
}
function declineOffer(offer) {
offer.decline((err) => {
console.log("We Declined an offer");
if (err) console.log("There was an error declining the offer.");
});
}