-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclasses_BotAccount.js.html
More file actions
808 lines (725 loc) · 29 KB
/
Copy pathclasses_BotAccount.js.html
File metadata and controls
808 lines (725 loc) · 29 KB
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Source: classes/Bot.js</title>
<script src="scripts/prettify/prettify.js"></script>
<script src="scripts/prettify/lang-css.js"></script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Source: classes/Bot.js</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>BotAccount.prototype.__proto__ = require('events').EventEmitter.prototype;
const AuthManager = require('./Auth.js');
const TradeHandler = require('./Trade.js');
const SteamCommunity = require('steamcommunity');
const SteamUser = require('steam-user');
const SteamStore = require('steamstore');
const TradeOfferManager = require('steam-tradeoffer-manager');
const SteamID = TradeOfferManager.SteamID;
/**
* Creates a new BotAccount instance for a bot.
* @class
*/
//
function BotAccount(username, password, details, settings, logger) {
// Ensure account values are valid
var self = this;
// Init all required variables
if (typeof username != "string" || typeof password != "string")
if (!details.hasOwnProperty("steamguard") || !(details.hasOwnProperty("oAuthToken")))
throw Error("Invalid username/password or missing oAuthToken/Steamguard code");
self.username = username;
self.password = password;
self.settings = settings != undefined ? settings : {
api_key: "",
tradeCancelTime: 60 * 60 * 24,
tradePendingCancelTime: 60 * 60 * 24,
language: "en",
tradePollInterval: 5000,
tradeCancelOfferCount: 30,
tradeCancelOfferCountMinAge: 60 * 60,
cancelTradeOnOverflow: true
};
self.logger = logger;
self.community = new SteamCommunity();
self.client = new SteamUser();
self.TradeOfferManager = new TradeOfferManager({
"steam": self.client,
"community": self.community,
"cancelTime": self.settings.tradeCancelTime, // Keep offers upto 1 day, and then just cancel them.
"pendingCancelTime": self.settings.tradePendingCancelTime, // Keep offers upto 30 mins, and then cancel them if they still need confirmation
"cancelOfferCount": self.settings.tradeCancelOfferCount,// Cancel offers once we hit 7 day threshold
"cancelOfferCountMinAge": self.settings.tradeCancelOfferCountMinAge,// Keep offers until 7 days old
"language": self.settings.language, // We want English item descriptions
"pollInterval": 5000 // We want to poll every 5 seconds since we don't have Steam notifying us of offers
});
self.SteamID = TradeOfferManager.SteamID;
self.request = self.community.request;
self.store = new SteamStore();
self.loggedIn = false;
self.rateLimited = true;
self.delayedTasks = [];
self.details = details;
self.AuthManager = new AuthManager(self, logger);
self.AuthManager.on('updatedAccountDetails', function () {
self.emit('updatedAccountDetails');
});
self.TradeManager = new TradeHandler(self.TradeOfferManager, self.AuthManager, self.settings, logger);
};
/**
* Get the account's username, used to login to Steam
* @returns {String} username
*/
BotAccount.prototype.getAccountName = function () {
var self = this;
return self.username;
};
/**
* Get the account's username, used to login to Steam
* @returns {String} username
*/
BotAccount.prototype.TradeManager = function () {
var self = this;
return self.TradeOfferManager;
};
/**
* Get if the API/account is rate limited by SteamAPI
* @returns {Boolean} rateLimited
*/
BotAccount.prototype.getRateLimited = function () {
var self = this;
return self.rateLimited;
};
/**
* Get if the API/account is rate limited by SteamAPI
* @returns {Boolean} rateLimited
*/
BotAccount.prototype.setRateLimited = function (rateLimited) {
var self = this;
return self.rateLimited = rateLimited;
};
/**
* Fetch SteamID Object from the SteamID.
* @returns {Error | String}
*/
BotAccount.prototype.fromIndividualAccountID = function (id) {
var self = this;
var SteamID = TradeOfferManager.SteamID;
return new self.SteamID(id);
};
/**
* Get account details
* @returns {*|{username: *, password: *}}
*/
BotAccount.prototype.getAccount = function () {
var self = this;
return self.accountDetails;
};
/**
* Send a chat message to a receipient with callback
* @param {SteamID} recipient - Recipient of the message
* @param {String} message - Message to send
* @param {String} type - saytest or typing (message ignored for 'typing')
* @param {messageCallback} callback - Callback upon sending the message (undefined, or Error)
*/
BotAccount.prototype.sendMessage = function (recipient, message, type, callback) {
var self = this;
return self.community.chatMessage(recipient, message, type, callback);
};
/**
* Send a chat message to a receipient with callback
* @param {SteamID} recipient - Recipient of the message
* @param {String} message - Message to send
* @param {messageCallback} callback - Callback upon sending the message (undefined, or Error)
*/
BotAccount.prototype.sendMessage = function (recipient, message, callback) {
var self = this;
return self.community.chatMessage(recipient, message, callback);
};
/**
* Send a chat message to a receipient without callback
* @param {SteamID} recipient - Recipient of the message
* @param {String} message - Message to send
*/
BotAccount.prototype.sendMessage = function (recipient, message) {
var self = this;
return self.community.chatMessage(recipient, message);
};
/**
* Set the user we are chatting with
* @param {*|{username: *, sid: *}} chattingUserInfo
*/
BotAccount.prototype.setChatting = function (chattingUserInfo) {
var self = this;
self.currentChatting = chattingUserInfo;
};
/**
* Get the display name of the account
* @returns {String|undefined} displayName - Display name of the account
*/
BotAccount.prototype.getDisplayName = function () {
var self = this;
return (self.displayName ? self.displayName : undefined);
};
/**
* Function wrapper used to delay function calls by name and paramters
* @param fn - function reference
* @param context - Context to use for call
* @param params - Parameters in arraylist to send with function
* @returns {Function}
*/
BotAccount.prototype.wrapFunction = function (fn, context, params) {
return function () {
fn.apply(context, params);
};
};
/**
* Add a function to the queue which runs when we login usually.
* @param functionV
* @param functionData
*/
BotAccount.prototype.addToQueue = function (queueName, functionV, functionData) {
var self = this;
var functionVal = self.wrapFunction(functionV, self, functionData);
if (!self.delayedTasks.hasOwnProperty(queueName))
self.delayedTasks[queueName] = [];
self.delayedTasks[queueName].push(functionVal);
};
/**
* Process the queue to run tasks that were delayed.
* @param queueName
* @param callback
*/
BotAccount.prototype.processQueue = function (queueName, callback) {
var self = this;
if (self.delayedTasks.hasOwnProperty(queueName)) {
while (self.delayedTasks[queueName].length > 0) {
(self.delayedTasks[queueName].shift())();
}
}
callback(undefined);
};
/**
* Upvote an attachement file on SteamCommunity
* @param sharedFileId
* @param callback
*/
BotAccount.prototype.upvoteSharedFile = function (sharedFileId, callback) {
var self = this;
var options = {
form: {
'sessionid': self.accountDetails.sessionID,
'id': sharedFileId
}
};
self.community.httpRequestPost('https://steamcommunity.com/sharedfiles/voteup', options, function (error, response, body) {
if (!error && response.statusCode == 200)
callback(undefined);
else
callback(error);
});
};
/**
* Downvote an attachement file on SteamCommunity.
* @param sharedFileId
* @param callback
*/
BotAccount.prototype.downvoteSharedFile = function (sharedFileId, callback) {
var self = this;
var options = {
form: {
'sessionid': self.accountDetails.sessionID,
'id': sharedFileId
}
};
self.community.httpRequestPost('https://steamcommunity.com/sharedfiles/votedown', options, function (error, response, body) {
if (!error && response.statusCode == 200) {
callback(undefined);
}
else
callback(error);
});
};
/**
* Change the display name of the account (with prefix)
* @param {String} newName - The new display name
* @param {String} namePrefix - The prefix if there is one (Nullable)
* @param {errorCallback} errorCallback - A callback returned with possible errors
*/
BotAccount.prototype.changeName = function (newName, namePrefix, errorCallback) {
var self = this;
if (!self.loggedIn) {
self.addToQueue('login', self.changeName, [newName, namePrefix, errorCallback]);
}
else {
if (namePrefix == undefined) namePrefix = '';
self.community.editProfile({name: namePrefix + newName}, function (err) {
if (err)
return errorCallback(err.Error);
self.username = newName;
self.emit('updatedAccountDetails');
errorCallback(undefined);
});
}
};
/**
* @callback inventoryCallback
* @param {Error} error - An error message if the process failed, undefined if successful
* @param {Array} inventory - An array of Items returned via fetch (if undefined, then game is not owned by user)
* @param {Array} currencies - An array of currencies (Only a few games use this) - (if undefined, then game is not owned by user)
*/
/**
* Retrieve account inventory based on filters
* @param {Integer} appid - appid by-which to fetch inventory based on.
* @param {Integer} contextid - contextid of lookup (1 - Gifts, 2 - In-game Items, 3 - Coupons, 6 - Game Cards, Profile Backgrounds & Emoticons)
* @param {Boolean} tradableOnly - Items retrieved must be tradable
* @param {inventoryCallback} inventoryCallback - Inventory details (refer to inventoryCallback for more info.)
*/
BotAccount.prototype.getInventory = function (appid, contextid, tradableOnly, inventoryCallback) {
var self = this;
if (!self.loggedIn) {
self.addToQueue('login', self.getInventory, [appid, contextid, tradableOnly, inventoryCallback]);
}
else
self.TradeOfferManager.loadInventory(appid, contextid, tradableOnly, inventoryCallback);
};
/**
* Retrieve account inventory based on filters and provided steamID
* @param {SteamID} steamID - SteamID to use for lookup of inventory
* @param {Integer} appid - appid by-which to fetch inventory based on.
* @param {Integer} contextid - contextid of lookup (1 - Gifts, 2 - In-game Items, 3 - Coupons, 6 - Game Cards, Profile Backgrounds & Emoticons)
* @param {Boolean} tradableOnly - Items retrieved must be tradableOnly
* @param {inventoryCallback} inventoryCallback - Inventory details (refer to inventoryCallback for more info.)
*/
BotAccount.prototype.getUserInventory = function (steamID, appid, contextid, tradableOnly, inventoryCallback) {
var self = this;
if (!self.loggedIn) {
self.addToQueue('login', self.getUserInventory, [steamID, appid, contextid, tradableOnly, inventoryCallback]);
}
else
self.TradeOfferManager.loadUserInventory(steamID, appid, contextid, tradableOnly, inventoryCallback);
};
/**
* Add a phone-number to the account (For example before setting up 2-factor authentication)
* @param phoneNumber - Certain format must be followed
* @param {errorCallback} errorCallback - A callback returned with possible errors
*/
BotAccount.prototype.addPhoneNumber = function (phoneNumber, errorCallback) {
var self = this;
self.store.addPhoneNumber(phoneNumber, true, function (err) {
errorCallback(err);
});
};
/**
* @callback acceptedTradesCallback
* @param {Error} error - An error message if the process failed, undefined if successful
* @param {Array} acceptedTrades - An array of trades that were confirmed in the process.
*/
/**
* Confirm (not accept) all sent trades associated with a certain SteamID via the two-factor authenticator.
* @param {SteamID} steamID - SteamID to use for lookup of inventory
* @param {acceptedTradesCallback} acceptedTradesCallback - Inventory details (refer to inventoryCallback for more info.)
*/
BotAccount.prototype.confirmTradesFromUser = function (SteamID, callback) {
var self = this;
self.TradeOfferManager.getOffers(1, undefined, function (err, sent, received) {
var acceptedTrades = [];
for (var sentOfferIndex in sent) {
if (sent.hasOwnProperty(sentOfferIndex)) {
var sentOfferInfo = sent[sentOfferIndex];
if (sentOfferInfo.partner.getSteamID64() == SteamID.getSteamID64) {
sentOfferInfo.accept();
acceptedTrades.push(sentOfferInfo);
}
}
}
for (var receivedOfferIndex in received) {
if (received.hasOwnProperty(receivedOfferIndex)) {
var receievedOfferInfo = received[receivedOfferIndex];
if (receievedOfferInfo.partner.getSteamID64() == SteamID.getSteamID64) {
receievedOfferInfo.accept();
acceptedTrades.push(receievedOfferInfo);
}
}
}
self.confirmOutstandingTrades(function (err, confirmedTrades) {
callback(err, acceptedTrades);
});
});
};
BotAccount.prototype.verifyPhoneNumber = function (code, callback) {
var self = this;
self.store.verifyPhoneNumber(code, function (err) {
if (err) {
callback(err);
}
else {
callback(undefined);
}
});
};
BotAccount.prototype.getRequest = function (url, callback) {
var self = this;
self.request({
url: url,
method: "GET",
json: true
}, function (err, response, body) {
callback(err, body);
});
}
/**
* @callback callbackRequestAPI
* @param {Error} error - An error message if the process failed, undefined if successful
* @param {Object} body - An object of the parsed response (undefined if failed)
*/
/**
* Send GET Request to SteamAPI with details
* @param apiInterface (String) - Interface name
* @param version (String) - Interface version (v1 or v2 depending on interface)
* @param method (String) - method to access
* @param options - Data to attach to request
* @param callbackRequestAPI -
*/
BotAccount.prototype.getRequestAPI = function (apiInterface, version, method, options, callbackRequestAPI) {
var self = this;
var string = '?';
var x = 0
for (var option in options)
string += option + "=" + options[option] + (x++ < Object.keys(options).length - 1 ? "&" : '');
self.logger.log('debug', "Sending GET request to " + string);
self.community.request({
url: 'http://api.steampowered.com/' + apiInterface + '/' + method + '/' + version + '/' + string,
method: "GET",
json: true,
}, function (err, response, body) {
callbackRequestAPI(err, body);
});
}
BotAccount.prototype.getFriendsSummariesNonAPI = function (friends, atCount, friendsCompiled, callback) {
var self = this;
var steamids = ""
var maxCount = atCount + 100;
if (atCount + 100 > friends.length)
maxCount = friends.length;
for (var x = 0 + atCount; x < (maxCount); x++)
steamids += friends[x].steamid + (x < maxCount - 1 ? ',' : "");
self.getRequestAPI('ISteamUser', 'v2', 'GetPlayerSummaries', {
key: self.settings.api_key,
steamids: steamids
}, function (err, body) {
if (err)
return callback(err, friendsCompiled);
var compiledFriends = body.response.players;
if (maxCount < friends.length) {
self.getFriendsSummaries(friends, atCount + 100, friendsCompiled.concat(compiledFriends), function (err, friendsSummaries) {
return callback(undefined, compiled);
});
}
else
return callback(undefined, friendsCompiled.concat(compiledFriends));
})
};
BotAccount.prototype.getFriendsSummaries = function (friends, atCount, friendsCompiled, callback) {
var self = this;
var steamids = ""
var maxCount = atCount + 100;
if (atCount + 100 > friends.length)
maxCount = friends.length;
for (var x = 0 + atCount; x < (maxCount); x++)
steamids += friends[x].steamid + (x < maxCount - 1 ? ',' : "");
self.getRequestAPI('ISteamUser', 'v2', 'GetPlayerSummaries', {
key: self.settings.api_key,
steamids: steamids
}, function (err, body) {
if (err)
return callback(err, friendsCompiled);
var compiledFriends = body.response.players;
if (maxCount < friends.length) {
self.getFriendsSummaries(friends, atCount + 100, friendsCompiled.concat(compiledFriends), function (err, friendsSummaries) {
return callback(undefined, compiled);
});
}
else
return callback(undefined, friendsCompiled.concat(compiledFriends));
})
};
BotAccount.prototype.getFriends = function (callback) {
var self = this;
var onlineFriendsList = [];
self.logger.log('debug', "Getting friends list");
if (self.cachedFriendsList && (typeof self.cachedFriendsList == 'object') && ((new Date().getTime() / 1000) - (self.cachedFriendsList.cacheTime)) < (60 * 10)) {
onlineFriendsList = self.cachedFriendsList.friendsList.slice();
self.logger.log('debug', "Used cached friendslist");
return callback(undefined, onlineFriendsList);
} else {
// Due to the fact that we must submit an API call everytime we need friends list, we will cach the data for 5 minutes. Clear cach on force.
if (!self.loggedIn) {
self.logger.log('debug', "Queued getFriends method until login.");
self.addToQueue('login', self.getFriends, [callback]);
}
else {
self.logger.log('debug', "Getting a fresh list of friends");
self.getRequestAPI('ISteamUser', 'v1', 'GetFriendList', {
key: self.settings.api_key,
relationship: 'friend',
steamid: self.community.steamID
}, function (err, body) {
if (err)
return callback(err, undefined);
if (body.hasOwnProperty("friendslist")) {
var friends = body.friendslist.friends;
self.getFriendsSummaries(friends, 0, [], function (err, friendsSummaries) {
// We need to convert SteamID to names... To do that, we need SteamCommunity package.
for (var id in friendsSummaries) {
onlineFriendsList.push({
username: friendsSummaries[id].personaname,
accountSid: friendsSummaries[id].steamid
});
}
self.cachedFriendsList = {
friendsList: onlineFriendsList,
cacheTime: new Date().getTime() / 1000
};
return callback(undefined, onlineFriendsList.slice());
});
} else {
self.logger.log('debug', body);
self.logger.log('debug', "Failed to fetch friends - API call failed");
return callback(undefined, onlineFriendsList.slice());
}
})
}
}
};
/**
* This is a private method - but incase you would like to edit it for your own usage...
* @param cookies - Cookies sent by Steam when logged in
* @param sessionID - Session ID as sent by Steam
* @param {loginCallback} loginCallback - Login details (refer to loginCallback for more info.)
*/
BotAccount.prototype.loggedInAccount = function (cookies, sessionID, loginCallback) {
var self = this;
self.chatLogon(500, 'web');
self.logger.log('debug', 'Logged into %j', self.getAccountName());
if (self.sessionID != sessionID || self.cookies != cookies) {
self.sessionID = sessionID;
self.cookies = cookies;
delete self.twoFactorCode;
}
self.emit('loggedIn', self);
if (self.cookies) {
self.community.setCookies(cookies);
self.store.setCookies(cookies);
self.TradeOfferManager.setCookies(cookies, function (err) {
if (err) {
self.logger.log("debug", "Failed to get API Key - TradeOverflowChecking disabled for %j & getOffers call disabled.", self.getAccountName(), err.Error);
if (err.Error == "Access Denied")
self.api_access = false;
}
else
self.api_access = true;
self.TradeManager.setAPIAccess(self.api_access);
});
}
self.loggedIn = true;
self.processQueue('login', function (err) {
if (err) {
self.logger.log('error', err);
return loginCallback(err);
}
self.community.on('chatTyping', function (senderID) {
self.emit('chatTyping', senderID);
});
self.community.on('chatLoggedOff', function () {
self.emit('chatLoggedOff');
});
self.community.on('chatMessage', function (senderID, message) {
if (self.currentChatting != undefined && senderID == self.currentChatting.sid) {
console.log(("\n" + self.currentChatting.username + ": " + message).green);
}
/**
* Emitted when a friend message or chat room message is received.
*
* @event BotAccount#friendOrChatMessage
* @type {object}
* @property {SteamID} senderID - The message sender, as a SteamID object
* @property {String} message - The message text
* @property {SteamID} room - The room to which the message was sent. This is the user's SteamID if it was a friend message
*/
self.emit('chatMessage', senderID, message);
});
self.community.on('sessionExpired', function (err) {
self.logger.log('debug', "Login session expired due to " + err);
self.emit('sessionExpired', err);
});
self.TradeOfferManager.on('sentOfferChanged', function (offer, oldState) {
/**
* Emitted when a trade offer changes state (Ex. accepted, pending, escrow, etc...)
*
* @event BotAccount#offerChanged
* @type {object}
* @property {TradeOffer} offer - The new offer's details
* @property {TradeOffer} oldState - The old offer's details
*/
self.emit('offerChanged', offer, oldState);
});
self.TradeOfferManager.on('receivedOfferChanged', function (offer, oldState) {
self.emit('receivedOfferChanged', offer, oldState);
});
self.TradeOfferManager.on('offerList', function (filter, sent, received) {
self.emit('offerList', filter, sent, received);
});
self.TradeOfferManager.on('newOffer', function (offer) {
/**
* Emitted when we receive a new trade offer
*
* @event BotAccount#newOffer
* @type {object}
* @property {TradeOffer} offer - The offer's details
*/
self.emit('newOffer', offer);
});
self.TradeOfferManager.on('sentOfferChanged', function (offer) {
/**
* Emitted when we receive a new trade offer notification (only provides amount of offers and no other details)
*
* @event BotAccount#tradeOffers
* @type {object}
* @property {Integer} count - The amount of active trade offers (can be 0).
*/
self.emit('sentOfferChanged', offer);
});
self.TradeOfferManager.on('realTimeTradeConfirmationRequired', function (offer) {
/**
* Emitted when a trade offer is cancelled
*
* @event BotAccount#tradeOffers
* @type {object}
* @property {Integer} count - The amount of active trade offers (can be 0).
*/
self.emit('realTimeTradeConfirmationRequired', offer);
});
self.TradeOfferManager.on('realTimeTradeCompleted', function (offer) {
/**
* Emitted when a trade offer is cancelled
*
* @event BotAccount#tradeOffers
* @type {object}
* @property {Integer} count - The amount of active trade offers (can be 0).
*/
self.emit('realTimeTradeCompleted', offer);
});
self.TradeOfferManager.on('sentOfferCanceled', function (offer) {
/**
* Emitted when a trade offer is cancelled
*
* @event BotAccount#tradeOffers
* @type {object}
* @property {Integer} count - The amount of active trade offers (can be 0).
*/
self.emit('sentOfferCanceled', offer);
});
/**
* Emitted when we fully sign into Steam and all functions are usable.
*
* @event BotAccount#loggedIn
*/
return loginCallback(undefined);
});
}
BotAccount.prototype.hasPhone = function (callback) {
var self = this;
self.store.hasPhone(function (err, hasPhone, lastDigits) {
callback(err, hasPhone, lastDigits);
});
};
BotAccount.prototype.getStateName = function (state) {
return TradeOfferManager.getStateName(state);
};
BotAccount.prototype.setSetting = function (settingName, tempSettingValusettingName) {
var self = this;
self.settings[tempSetting] = tempSettingValue;
};
BotAccount.prototype.getSetting = function (tempSetting) {
var self = this;
if (self.settings.hasOwnProperty(tempSetting))
return self.settings[tempSetting];
return undefined;
};
BotAccount.prototype.deleteSetting = function (tempSetting) {
var self = this;
if (self.settings.hasOwnProperty(tempSetting))
delete self.settings[tempSetting];
};
BotAccount.prototype.chatLogon = function (interval, uiMode) {
var self = this;
if (interval == undefined)
interval = 500;
if (uiMode == undefined)
uiMode = 'web';
self.logger.log('debug', 'Logged on to chat on %j', self.getAccountName());
self.community.chatLogon(interval, uiMode);
};
BotAccount.prototype.logoutAccount = function () {
var self = this;
self.community = new SteamCommunity();
self.client = new SteamUser();
self.TradeOfferManager = new TradeOfferManager({
"steam": self.client,
"community": self.community,
"cancelTime": self.settings.tradeCancelTime, // Keep offers upto 1 day, and then just cancel them.
"pendingCancelTime": self.settings.tradePendingCancelTime, // Keep offers upto 30 mins, and then cancel them if they still need confirmation
"cancelOfferCount": self.settings.tradeCancelOfferCount,// Cancel offers once we hit 7 day threshold
"cancelOfferCountMinAge": self.settings.tradeCancelOfferCountMinAge,// Keep offers until 7 days old
"language": self.settings.language, // We want English item descriptions
"pollInterval": 5000 // We want to poll every 5 seconds since we don't have Steam notifying us of offers
});
self.request = self.community.request;
self.store = new SteamStore();
self.loggedIn = false;
};
module.exports = BotAccount;
</code></pre>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2>
<h3>Classes</h3>
<ul>
<li><a href="BotAccount.html">BotAccount</a></li>
<li><a href="BotManager.html">BotManager</a></li>
<li><a href="GUI_Handler.html">GUI_Handler</a></li>
</ul>
<h3>Events</h3>
<ul>
<li><a href="BotAccount.html#event:friendOrChatMessage">friendOrChatMessage</a></li>
<li><a href="BotAccount.html#event:loggedIn">loggedIn</a></li>
<li><a href="BotAccount.html#event:newOffer">newOffer</a></li>
<li><a href="BotAccount.html#event:offerChanged">offerChanged</a></li>
<li><a href="BotAccount.html#event:tradeOffers">tradeOffers</a></li>
</ul>
<h3>Global</h3>
<ul>
<li><a href="global.html#GUI">GUI</a></li>
<li><a href="global.html#Winston">Winston</a></li>
</ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Thu Mar 16 2017 00:46:25
GMT+0400 (Arabian Standard Time)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"></script>
</body>
</html>