Advertisement
Guest User

Untitled

a guest
Mar 3rd, 2017
1,264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.53 KB | None | 0 0
  1. /**
  2. * Steam access.
  3. *
  4. * 1. Logs in to Steam using account credentials.
  5. * 2. Goes online for friends.
  6. * 3. Launches Team Fortress 2.
  7. */
  8.  
  9. var fs = require('fs');
  10.  
  11. var dotenv = require('dotenv');
  12. var SteamUser = require('steam-user');
  13. var client = new SteamUser();
  14.  
  15. dotenv.config();
  16.  
  17. console.log(Object.keys(client.myFriends));
  18.  
  19. client.logOn({
  20. accountName: process.env.STEAM_USERNAME,
  21. password: process.env.STEAM_PASSWORD
  22. });
  23.  
  24. client.on('loggedOn', details => {
  25. console.log(`Logged in to Steam as user ID: ${client.steamID.getSteam3RenderedID()}`);
  26.  
  27. console.log(details);
  28.  
  29. client.setPersona(SteamUser.EPersonaState.Online);
  30. client.setUIMode(SteamUser.EClientUIMode.BigPicture);
  31. // client.gamesPlayed(440);
  32.  
  33. client.getProductInfo([440, 730], [], function(apps, packages, unknownApps, unknownPackages) {
  34. console.log("Got app info, writing to files");
  35.  
  36. // for (var appid in apps) {
  37. // fs.writeFileSync(appid + '.json', JSON.stringify(apps[appid].appinfo, null, "\t"));
  38. // }
  39.  
  40. // 448280
  41.  
  42. // console.log("Logging off of Steam");
  43. // client.logOff();
  44. });
  45. });
  46.  
  47. client.on('error', err => {
  48. // Some error occurred during login.
  49. console.log(err);
  50. });
  51.  
  52. client.on('webSession', (sessionID, cookies) => {
  53. console.log('Got web session');
  54. // Do something with these cookies if you wish.
  55. });
  56.  
  57. client.on('newItems', count => {
  58. console.log(`%s new item${count === 1 ? '' : 's'} in our inventory`, count);
  59. });
  60.  
  61. client.on('emailInfo', (address, validated) => {
  62. console.log('Email address %s: %s',
  63. validated ? 'validated' : 'not validated',
  64. address);
  65. });
  66.  
  67. client.on('wallet', (hasWallet, currency, balance) => {
  68. console.log('Wallet balance: %s', SteamUser.formatCurrency(balance, currency));
  69. });
  70.  
  71. client.on('accountLimitations', (limited, communityBanned, locked, canInviteFriends) => {
  72. var limitations = [];
  73.  
  74. if (limited) {
  75. limitations.push('LIMITED');
  76. }
  77.  
  78. if (communityBanned) {
  79. limitations.push('COMMUNITY BANNED');
  80. }
  81.  
  82. if (locked) {
  83. limitations.push('LOCKED');
  84. }
  85.  
  86. if (limitations.length === 0) {
  87. console.log('Our account has no limitations');
  88. } else {
  89. console.log(`Our account is ${limitations.join(', ')}`);
  90. }
  91.  
  92. if (canInviteFriends) {
  93. console.log('Our account can invite friends');
  94. }
  95. });
  96.  
  97. client.on('vacBans', (numBans, appids) => {
  98. console.log(`We have ${numBans} VAC ban${numBans === 1 ? '' : 's'}`);
  99. if (appids.length > 0) {
  100. console.log(`We are VAC-banned from these apps: ${appids.join(', ')}`);
  101. }
  102. });
  103.  
  104. client.on('licenses', licenses => {
  105. console.log(`Our account owns ${licenses.length} license${licenses.length === 1 ? '' : 's'}`);
  106. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement