Advertisement
Guest User

Untitled

a guest
Dec 7th, 2016
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.44 KB | None | 0 0
  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 fs = require('fs');
  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: 'accountname', //put your steam username here within the quotes
  17. password: 'password', //put your steam password here within the quotes
  18. twoFactorCode: SteamTotp.generateAuthCode('sharedsecret') //put your steam shared secret here within the quotes
  19. };
  20.  
  21. client.logOn(logOnOptions);
  22.  
  23. client.on('loggedOn', () => {
  24. console.log('Logged into Steam with the account name of : ' + logOnOptions.accountName);
  25.  
  26. let tf2 = 440;
  27. let csgo = 730;
  28.  
  29. client.setPersona(SteamUser.Steam.EPersonaState.Online);
  30. client.gamesPlayed(csgo); //here you can put csgo or tf2
  31. });
  32.  
  33. client.on('webSession', (sessionid, cookies) => {
  34. manager.setCookies(cookies);
  35.  
  36. community.setCookies(cookies);
  37. community.startConfirmationChecker(10000, 'identitysecret');
  38.  
  39. console.log('Connected with the api key');
  40. });
  41.  
  42. manager.on('newOffer', (offer) => {
  43.  
  44. console.log("New offer #" + offer.id + " from " + offer.partner);
  45.  
  46. if (offer.itemsToGive.length === 0) {
  47.  
  48. let donation = {
  49. keys: 0,
  50. scrap: 0,
  51. ref: 0,
  52. rec: 0,
  53. tot: 0
  54. }
  55.  
  56. for (var i = 0; i < offer.itemsToReceive.length; i++) {
  57.  
  58. let item = offer.itemsToReceive[i];
  59.  
  60. if(item.name.indexOf('Supply Crate Key')){
  61. donation.keys++;
  62. } else if (item.name.indexOf('Refined Metal')){
  63. donation.ref++;
  64. } else if (item.name.indexOf('Reclaimed Metal')){
  65. donation.rec++;
  66. } else if (item.name.indexOf('Scrap Metal')){
  67. donation.scrap++;
  68. }
  69.  
  70. }
  71.  
  72. donation.tot = (donation.keys * 3) + (donation.scrap * 2) + (donation.ref * 3) + (donation.rec * 4);
  73.  
  74. fs.writeFile('donations.txt', 'User: ' + offer.partner.getSteamID64() + ' has a total of : ' + donation.tot + ' tickets', (err) => {
  75.  
  76. if(err) {
  77. console.log(err);
  78. } else {
  79.  
  80. console.log('The donation file was updated');
  81.  
  82. offer.accept((err, status) => {
  83. if (err) {
  84. console.log(err);
  85. } else {
  86. console.log(`Donation accepted. Status: ${status}.`)
  87. }
  88. });
  89.  
  90. }
  91.  
  92. });
  93.  
  94. }
  95.  
  96. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement