Advertisement
Guest User

Untitled

a guest
Mar 21st, 2016
544
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.83 KB | None | 0 0
  1. var site = '81.2.249.92';
  2. var apiKey = '';
  3. var shared_secret = '';
  4. var botID = '1';
  5. var identity_secret = '';
  6. var accountName = '';
  7. var accountPassword = '';
  8. var sitePassword = '';
  9.  
  10. var crypto = require('crypto');
  11. var market = require('steam-market-pricing');
  12. var hash = crypto.createHash('sha1');
  13. hash.update(Math.random().toString());
  14. hash = hash.digest('hex');
  15. var device_id = 'android:' + hash;
  16.  
  17. var SteamUser = require('steam-user');
  18. var TradeOfferManager = require('steam-tradeoffer-manager');
  19. var SteamTradeOffers = require('steam-tradeoffers');
  20. var fs = require('fs');
  21. var request = require('request');
  22. var SteamTotp = require('steam-totp');
  23. var code = SteamTotp.generateAuthCode(shared_secret);
  24. var SteamcommunityMobileConfirmations = require('steamcommunity-mobile-confirmations');
  25. var steamcommunityMobileConfirmations = null;
  26.  
  27. var client = new SteamUser();
  28. var offers = new SteamTradeOffers();
  29. var manager = new TradeOfferManager({
  30. "steam": client,
  31. "domain": "81.2.249.92",
  32. "language": "en"
  33. });
  34.  
  35. manager.apiKey = apiKey;
  36.  
  37. var logOnOptions = {
  38. "accountName": accountName,
  39. "password": accountPassword,
  40. "twoFactorCode": code
  41. };
  42.  
  43. client.setSentry(fs.readFileSync('sentry'));
  44.  
  45. client.logOn(logOnOptions);
  46.  
  47. client.on('loggedOn', function() {
  48. client.setPersona(SteamUser.Steam.EPersonaState.Online);
  49. });
  50.  
  51. client.on('webSession', function(sessionID, cookies) {
  52.  
  53. steamcommunityMobileConfirmations = new SteamcommunityMobileConfirmations(
  54. {
  55. steamid: botID,
  56. identity_secret: identity_secret,
  57. device_id: device_id.toString(),
  58. webCookie: cookies
  59. });
  60.  
  61. mobileConfirm();
  62.  
  63. offers.setup({
  64. sessionID: sessionID,
  65. webCookie: cookies
  66. });
  67.  
  68. manager.setCookies(cookies, function(err) {
  69. if(err) {
  70. console.log(err);
  71. process.exit(1);
  72. return;
  73. }
  74. console.log("Logged in");
  75. });
  76. });
  77.  
  78. client.on("tradeOffers", function(count){
  79. if(count > 0){
  80. handleOffer();
  81. }
  82. });
  83.  
  84. /*--------------------------
  85. * MY FUNCTIONS START
  86. --------------------------*/
  87. function getSHA1(bytes) {
  88. var shasum = crypto.createHash('sha1');
  89. shasum.end(bytes);
  90. return shasum.read();
  91. }
  92. function reAuth(){
  93. client.logOff();
  94. var code = SteamTotp.generateAuthCode(shared_secret);
  95. var logOnOptions = {
  96. "accountName": accountName,
  97. "password": accountPassword,
  98. "twoFactorCode": code
  99. };
  100. client.logOn(logOnOptions);
  101. client.webLogOn();
  102. }
  103. function mobileConfirm(){
  104. steamcommunityMobileConfirmations.FetchConfirmations((function (err, confirmations)
  105. {
  106. if (err)
  107. {
  108. console.log(err);
  109. return;
  110. }
  111. if (!confirmations.length)
  112. {
  113. return;
  114. }
  115. confirmations.forEach(function(confirmation) {
  116. steamcommunityMobileConfirmations.AcceptConfirmation(confirmation, (function (err, result)
  117. {
  118. if (err)
  119. {
  120. console.log(err);
  121. return;
  122. }
  123. console.log('Mobile Confirmation: ' + result);
  124. }));
  125. });
  126. }));
  127. }
  128.  
  129. function price(classid,steamid){
  130. steamid = steamid.toString();
  131. classid = classid.toString();
  132. var countIteration = 0;
  133. var nameUrl = "http://api.steampowered.com/ISteamEconomy/GetAssetClassInfo/v0001?key="+apiKey+"&format=json&language=ru&appid=730&class_count=2&classid0=0&classid1="+classid;
  134. request(nameUrl, function (error, response, body)
  135. {
  136. if(countIteration != 0){
  137. return;
  138. }
  139. countIteration++;
  140. var countIteration2 = 0;
  141. if (!error && response.statusCode == 200) {
  142. var json = JSON.parse(body);
  143. if(json['result'][classid]['tradable'] != "")
  144. {
  145. var market_hash_name = json['result'][classid]['market_hash_name'].toString();
  146. market.getItemPrice(730, market_hash_name, function(err, data)
  147. {
  148. if(!err)
  149. {
  150. if(countIteration2 != 0)
  151. {
  152. return;
  153. }
  154. countIteration2++;
  155. var cost = data;
  156. cost = cost['lowest_price'].replace(',','.');
  157. cost = cost.replace('$','');
  158. cost = parseFloat(cost);
  159. cost = (cost*100);
  160. var postData=
  161. {
  162. steamid: steamid,
  163. sum: cost,
  164. password: sitePassword
  165. };
  166. request.post(
  167. {
  168. headers: {'content-type' : 'application/x-www-form-urlencoded'},
  169. url: site+'balance',
  170. body: require('querystring').stringify(postData)
  171. }, function(error, response, body)
  172. {
  173. if (!error && response.statusCode == 200) {
  174. console.log("Sent money to "+ steamid);
  175. }
  176. });
  177. }
  178. });
  179. };
  180. }
  181. });
  182. }
  183.  
  184. function handleOffer(){
  185. manager.getOffers(1, function(err, sent, received){
  186. if(err){
  187. reAuth();
  188. }
  189. received.forEach(function(offer) {
  190.  
  191. var itemToRecieve = offer.itemsToReceive;
  192.  
  193. if(itemToRecieve === undefined || itemToRecieve === null){
  194. offer.decline();
  195. return;
  196. }
  197.  
  198. for(var i = 0; i < itemToRecieve.length; i++)
  199. {
  200. if(itemToRecieve[i].appid != "730")
  201. {
  202. offer.decline();
  203. return;
  204. }
  205. }
  206.  
  207. if (offer.itemsToGive.length == 0) {
  208. offer.getEscrowDuration(function(err, daysTheirEscrow, daysMyEscrow){
  209. if(daysTheirEscrow == 0 || daysTheirEscrow == undefined){
  210. if(offer.state == 11){
  211. return;
  212. }
  213. console.log("New offer #" + offer.id + " from " + offer.partner);
  214. offer.accept(function(err) {
  215. if(err) {
  216. console.log("Unable to accept offer: " + err.message);
  217. reAuth();
  218. return;
  219. } else {
  220. console.log("Offer accepted");
  221. var items = offer.itemsToReceive;
  222. var steamid = offer.partner;
  223. for(var x = 0; x < items.length; x++) {
  224. price(items[x].classid, steamid);
  225. }
  226. request(site+'updateItems', function (error, response, body){
  227. if(!error && response.statusCode == 200) {
  228.  
  229. }
  230. });
  231. }
  232. });
  233. }else{
  234. if(offer.state == 11){
  235. return;
  236. }else{
  237. console.log("New offer #" + offer.id + " from " + offer.partner);
  238. offer.decline();
  239. console.log("Escrow");
  240. }
  241. }
  242. });
  243.  
  244. }else {
  245. offer.decline();
  246. console.log("I don't accept this shit!");
  247. }
  248. });
  249. });
  250. };
  251.  
  252. function sendoffers(){
  253. request(site+"winner", function (error, response, body) {
  254. if(!error && response.statusCode == 200) {
  255. var str = body.toString();
  256. var winner = JSON.parse(str);
  257. if(winner === null || winner === undefined){
  258. return;
  259. }
  260. var gameid = winner['id'];
  261. var sendItem = winner['items'];
  262. var item=[], num = 0;
  263. var detected2 = false;
  264. manager.loadInventory(730, 2, false, function(err, items, currencies) {
  265. if(err){
  266. reAuth();
  267. }
  268. itemscopy = items;
  269. for (var x = 0; x < itemscopy.length; x++) {
  270. if (itemscopy[x].tradable && itemscopy[x].classid == sendItem) {
  271. itemscopy[x].market_name = "fgdfgdfgdfgdfgfswfewefewrfewrewrewr";
  272. item[0] = {
  273. appid: 730,
  274. contextid: 2,
  275. amount: 1,
  276. assetid: itemscopy[x].id
  277. }
  278. num++;
  279. }
  280. }
  281. if (num > 0) {
  282. var gamenum = winner['id'];
  283. offers.makeOffer({
  284. partnerSteamId: winner['usersteamid'].toString(),
  285. itemsFromMe: item,
  286. accessToken: winner['token'].toString(),
  287. itemsFromThem: []
  288. }, function(err, response){
  289. if (err){
  290. console.log(err);
  291. reAuth();
  292. return;
  293. }
  294. var postData={
  295. id: gamenum,
  296. password: sitePassword
  297. };
  298. request.post({
  299. headers: {'content-type' : 'application/x-www-form-urlencoded'},
  300. url: site+'delivery',
  301. body: require('querystring').stringify(postData)
  302. });
  303. console.log('Trade offer for queue '+gamenum+' sent!');
  304. mobileConfirm();
  305. });
  306. }
  307. });
  308. }
  309. });
  310. }
  311. setInterval(function(){sendoffers()}, 13000);
  312. /*--------------------------
  313. * MY FUNCTIONS END
  314. --------------------------*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement