Advertisement
Guest User

Untitled

a guest
Jan 31st, 2019
738
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const SteamUser = require('steam-user');
  2. const SteamTotp = require('steam-totp');
  3. const SteamCommunity = require('steamcommunity');
  4. const TradeOfferManager = require('steam-tradeoffer-manager');
  5. const config = require('./config.json');
  6.  
  7. const client = new SteamUser();
  8. const community = new SteamCommunity();
  9. const manager = new TradeOfferManager ({
  10.     steam: client,
  11.     community: community,
  12.     language: 'en'
  13. });
  14.  
  15. const logOnOptions = {
  16.     accountName: config.username,
  17.     password: config.password,
  18.     twoFactorCode: SteamTotp.generateAuthCode(config.sharedSecret)
  19. };
  20.  
  21. client.logOn(logOnOptions);
  22.  
  23. client.on('loggedOn', () => {
  24.     console.log('succesfully logged on.');
  25. });
  26.  
  27. client.on('webSession', (sessionid, cookies) => {
  28.     manager.setCookies(cookies);
  29.  
  30.     community.setCookies(cookies);
  31.     community.startConfirmationChecker(10000, config.identitySecret);
  32. });
  33.  
  34. function acceptOffer(offer) {
  35.     offer.accept((err) => {
  36.         community.checkConfirmations();
  37.         console.log("We Accepted an offer");
  38.         if (err) console.log("There was an error accepting the offer.");
  39.     });
  40. }
  41.  
  42. function declineOffer(offer) {
  43.     offer.decline((err) => {
  44.         console.log("We Declined an offer");
  45.         if (err) console.log("There was an error declining the offer.");
  46.     });
  47. }
  48.  
  49. client.setOption("promptSteamGuardCode", false);
  50.  
  51. manager.on('newOffer', (offer) => {
  52.     if (offer.partner.getSteamID64() === 'my_account_id') {
  53.         acceptOffer(offer);
  54.     } else {
  55.     declineOffer(offer);
  56.     }
  57.      
  58. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement