Advertisement
Guest User

Untitled

a guest
Jan 18th, 2017
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.36 KB | None | 0 0
  1. var Steam = require("steam");
  2. var SteamUser = require("steam-user");
  3. var SteamApi = require('steam-api');
  4. var dota2 = require('dota2');
  5. var STEAM_API_KEY = "";
  6. var optionalSteamId = '';
  7. var fs = require('fs');
  8. var nodeDotaApi = require('node-dota-api');
  9. var async = require('async');
  10.  
  11.  
  12. var user = new SteamApi.User("", optionalSteamId);
  13. var client = new SteamUser();
  14. var friends = new Steam.SteamFriends(client.client);
  15. var Dota2 = new dota2.Dota2Client(client, true);
  16.  
  17.  
  18.  
  19. //sindeete to bot (OXI TO MAIN ACCOUNT MOU) , kai to dixnei an paizei dota 2
  20. client.on("loggedOn", function (details) {
  21. console.log("logged on to steam ! with the steam id " + client.steamID.getSteam3RenderedID());
  22. client.setPersona(SteamUser.Steam.EPersonaState.Online);
  23. client.gamesPlayed(570);
  24. });
  25.  
  26. client.on("error", e =>console.error(e)); {
  27. console.log("error");
  28.  
  29. };
  30.  
  31. var steamID = '';
  32. var playerID = Dota2.ToAccountID(steamID);
  33. //pernw ta mmr
  34. nodeDotaApi.playerStats(playerID, function (res) {
  35. if (res) return (console.log(JSON.stringify(res)));
  36.  
  37. });
  38.  
  39. function myFriendListIds(optionalSteamId,callback){
  40.  
  41. user.GetFriendList(optionalRelationship = 'all', optionalSteamId).done(function (result) { //to api call pou pernei tis plirofories apo to friendlist tou main acc mou
  42.  
  43. var ArrayWithId = [];
  44.  
  45.  
  46. for (i in result) {
  47. ArrayWithId.push(result[i]['steamId']); //pinakas me ta steam id tou main acc pou trexei to API CALL tis valve
  48. }
  49. return user
  50. .GetFriendList(optionalRelationship = 'all', optionalSteamId)
  51. .then(result => result.map(user => user.streamId))
  52. });
  53. }
  54. //kalw to function pou ekana apo panw me callback gia na mporesw na parw to return pou mou dinei!
  55.  
  56. myFriendListIds(optionalSteamId, function (res) {
  57. fs.writeFile('IDS.txt' , res , function (err) {
  58. if(err) throw err;
  59. console.log("Done");
  60.  
  61. })
  62. });
  63.  
  64.  
  65. var text = fs.readFileSync('IDS.txt', 'utf8');
  66. var friendsids = [];
  67. var txt = JSON.parse(text);
  68. for (var i in txt) {
  69. friendsids.push(txt[i]);
  70. }
  71. console.log(friendsids);
  72.  
  73.  
  74.  
  75. for(let i = 0; i < 100; i++) {
  76. setTimeout(function() {
  77. user.GetFriendList(optionalRelationship = 'all', friendsids[i]).done(function (res) {
  78. console.log(res);
  79. console.log(i);
  80. });
  81.  
  82. }, 10000);
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement