This repository has been archived by the owner on Jun 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathclient.js
63 lines (54 loc) · 1.92 KB
/
client.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
var SteamUser = require('steam-user');
var SteamTotp = require('steam-totp');
var botFactory = {};
botFactory.buildBot = function (config)
{
var bot = new SteamUser({
promptSteamGuardCode: false,
dataDirectory: "./sentry",
singleSentryfile: false
});
bot.username = config.username;
bot.password = config.password;
bot.sharedSecret = config.sharedSecret;
bot.games = config.games;
bot.messageReceived = {};
bot.on('loggedOn', function(details) {
console.log("[" + this.username + "] Logged into Steam as " + bot.steamID.getSteam3RenderedID());
bot.setPersona(SteamUser.EPersonaState.Online);
bot.gamesPlayed(this.games);
});
bot.on('error', function(e) {
console.log("[" + this.username + "] " + e);
setTimeout(function() {bot.doLogin();}, 30*60*1000);
});
bot.doLogin = function ()
{
this.logOn({
"accountName": this.username,
"password": this.password
});
}
bot.on('steamGuard', function(domain, callback) {
if ( !this.sharedSecret ) {
var readlineSync = require('readline-sync');
var authCode = readlineSync.question("[" + this.username + "] " + 'Steam Guard' + (!domain ? ' App' : '') + ' Code: ');
callback(authCode);
}
else {
var authCode = SteamTotp.generateAuthCode( this.sharedSecret );
console.log("[" + this.username + "] Generated Auth Code: " + authCode);
callback(authCode);
}
});
bot.on("friendMessage", function(steamID, message) {
console.log("[" + this.username + "] Message from " + steamID+ ": " + message);
if ( !this.messageReceived[steamID] ) {
bot.chatMessage(steamID, "[Automated Message] I am currently idle. I will respond when I am next available.");
// bot.chatMessage(steamID, "[Automated Message_2] I am currently idle. I will respond when I am next available.");
this.messageReceived[steamID] = true;
}
});
return bot;
}
module.exports = botFactory;