Advertisement
Guest User

Untitled

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