Advertisement
Guest User

Untitled

a guest
Feb 12th, 2017
1,099
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 27.60 KB | None | 0 0
  1. Steam = require('steam');
  2. var SteamUser = require('steam-user');
  3. var TradeOfferManager = require('steam-tradeoffer-manager');
  4. var client = new SteamUser();
  5. var fs = require("fs");
  6. var SteamTotp = require('steam-totp');
  7. var request = require('request');
  8. var SteamCommunity = require('steamcommunity');
  9. var community = new SteamCommunity(steamClient);
  10. var steamClient = new Steam.SteamClient();
  11. var steamUser = new Steam.SteamUser(steamClient);
  12. var steamFriends = new Steam.SteamFriends(steamClient);
  13. var colors = require('colors');
  14. var identity_secret;
  15. var config;
  16.  
  17.  
  18.  
  19. function updateconfig() {
  20. try {
  21. config = JSON.parse(fs.readFileSync('./config.json'));
  22. } catch (err) {
  23. console.log("Error: unable to parse config.json.");
  24. console.log(err);
  25. process.exit(1);
  26. }
  27. }
  28. updateconfig();
  29.  
  30. var manager = new TradeOfferManager({
  31. "community": community,
  32. "pollInterval": config.polltimeinseconds,
  33. "cancelTime": config.timebeforetradeiscancelled
  34. });
  35.  
  36. const logOnOptions = {
  37. accountName: 'your_steam_username',
  38. password: 'your_steam_password',
  39. twoFactorCode: SteamTotp.generateAuthCode('your_steam_shared_secret')
  40. };
  41.  
  42. client.logOn(logOnOptions);
  43.  
  44. client.on('loggedOn', () => {
  45. console.log('Logged into Steam');
  46.  
  47. client.setPersona(SteamUser.Steam.EPersonaState.Online);
  48. client.gamesPlayed(440);
  49. });
  50.  
  51. client.on("webSession", function(steamID, cookies) {
  52. manager.setCookies(cookies);
  53. community.setCookies(cookies);
  54. SteamTotp.steamID = steamID;
  55. community.startConfirmationChecker(5000, config.identitySecret);
  56. });
  57.  
  58. client.on('error', function(e) {
  59. console.log(e);
  60. });
  61.  
  62. const friends = new Steam.SteamFriends(client.client);
  63.  
  64. friends.on("friend", function(steamID, relationship) {
  65. console.log(relationship);
  66. if (relationship == Steam.EFriendRelationship.RequestRecipient) {
  67. console.log("New Friend request from " + steamID);
  68. friends.addFriend(steamID);
  69. friends.sendMessage(steamID, "Hello! I am a Banking Bot! Type !help to get started.);
  70. }
  71. });
  72.  
  73. friends.on('relationships', function() {
  74. var friendcount = 0;
  75. // For every friend we have...
  76. for (steamID in friends.friends) {
  77. friendcount++;
  78. // If the status is a new friend request...
  79. if (friends.friends[steamID] === Steam.EFriendRelationship.RequestRecipient) {
  80. console.log("Friend request while offline from: " + steamID);
  81. // Accept friend requests from when we were offline
  82. friends.addFriend(steamID);
  83. }
  84. }
  85.  
  86. if (friendcount > 200) {
  87. // We might be able to find old friends after using friends.requestFriendData([steamids])
  88. // but seishun will have to add support for it. Right now you can't see how long you've been friends through SteamFriends.
  89. // This is the only data available using requestFriendData function:
  90. // https://github.com/SteamRE/SteamKit/blob/master/Resources/Protobufs/steamclient/steammessages_clientserver.proto#L446-L469
  91. console.log("We're approaching the default friends limit. Maybe we need to purge old friends?");
  92. }
  93. });
  94. friends.on("friendMsg", function(user, msg, types) {
  95. msg = msg.toLowerCase();
  96. if (types == Steam.EChatEntryType.ChatMsg) {
  97. manager.getEscrowDuration(user, function(err, their, ours) {
  98. if (err) {
  99. return;
  100. }
  101. if (their != 0) {
  102. friends.sendMessage(user, "You have a trade hold, therefore i cannot trade with you. If you would like to remove this, check out this video: https://www.youtube.com/watch?v=2CUeUmeVBgs")
  103. return;
  104. }
  105. if (msg.startsWith("buykey")) {
  106. var reqkeyCount = 1;
  107. reqkeyCount = parseInt(msg.split(" ")[1]);
  108. if (isNaN(reqkeyCount)) {
  109. reqkeyCount = 1;
  110. }
  111. console.log("Incoming Request: User wants to buy " + reqkeyCount + " Key(s)")
  112. friends.sendMessage(user, "Please wait while I process your offer...");
  113.  
  114. var offer = manager.createOffer(user);
  115. manager.loadInventory(440, 2, true, function(err, myItems) {
  116. if (err) {
  117. console.log(err);
  118. return;
  119. }
  120.  
  121. offer.loadPartnerInventory(440, 2, function(err, theirItems) {
  122. if (err) {
  123. console.log(err);
  124. return;
  125. }
  126. var amount = reqkeyCount;
  127. for (i in myItems) {
  128. var item = myItems[i]
  129. if (amount <= 0) continue;
  130. if (item.market_name === "Mann Co. Supply Crate Key") {
  131. offer.addMyItem(item);
  132. amount -= 1;
  133. }
  134. }
  135. // Change logic if not enough keys to sell what we have!
  136. if (amount != 0) {
  137. friends.sendMessage(user, "Out of Keys! Check back later!");
  138. return;
  139. }
  140. var currencyRequired = reqkeyCount * config.keysellprice;
  141. var count = 0;
  142. for (i in theirItems) {
  143. var item = theirItems[i];
  144. if (item.market_name == "Refined Metal") {
  145. if (currencyRequired - 1 >= 0) {
  146. offer.addTheirItem(item);
  147. currencyRequired -= 1;
  148. count++;
  149. }
  150. }
  151. }
  152. for (i in theirItems) {
  153. var item = theirItems[i]
  154. if (item.market_name == "Reclaimed Metal") {
  155. if (currencyRequired - 1 / 3 >= 0) {
  156. offer.addTheirItem(item);
  157. currencyRequired -= 1 / 3;
  158. }
  159. }
  160. }
  161. for (i in theirItems) {
  162. var item = theirItems[i]
  163. if (item.market_name == "Scrap Metal") {
  164. if (toUpper(currencyRequired - 1 / 9) >= 0) {
  165. offer.addTheirItem(item);
  166. currencyRequired -= 1 / 9;
  167. }
  168. }
  169. }
  170. if (toLower(currencyRequired) > 0) {
  171. friends.sendMessage(user, "Failed To Send Offer: Could not find required metal to complete the transaction.");
  172. console.log("Underpay")
  173. return;
  174.  
  175. }
  176. friends.sendMessage(user, "Confirming Offer...");
  177. var uuid = code()
  178. friends.sendMessage(user, "Your trade offer will arrive within 10 seconds. You will have 2 minutes to accept. Make sure your transaction ID is " + uuid + "!");
  179. offer.send("Transaction ID: " + uuid + ". Thanks for using " + config.ownername + "'s Trading Bot!");
  180. community.getSteamUser(user, function(err, cmt) {
  181. //cmt.comment(config.profilecomment)
  182.  
  183. });
  184. });
  185. });
  186.  
  187.  
  188. } else
  189. if (msg.startsWith("sellkey")) {
  190. var reqkeyCount = 1;
  191.  
  192. reqkeyCount = parseInt(msg.split(" ")[1]);
  193. console.log("Incoming Request: User wants to sell us " + reqkeyCount + " keys")
  194. friends.sendMessage(user, "Please wait while I process your offer...");
  195.  
  196. var offer = manager.createOffer(user);
  197. manager.loadInventory(440, 2, true, function(err, theirItems) {
  198. if (err) {
  199. console.log(err);
  200. return;
  201. }
  202. offer.loadPartnerInventory(440, 2, function(err, myItems) {
  203. if (err) {
  204. console.log(err);
  205. return;
  206. }
  207. var amount = reqkeyCount;
  208. for (i in myItems) {
  209. var item = myItems[i]
  210. if (amount <= 0) continue;
  211. if (item.market_name === "Mann Co. Supply Crate Key") {
  212. offer.addTheirItem(item);
  213. amount -= 1;
  214. }
  215. }
  216. if (amount != 0) {
  217. friends.sendMessage(user, "Failed To Send Offer: Failed to find the Keys in your inventory. This may be due to the TF2 API.");
  218. return;
  219. }
  220. var currencyRequired = reqkeyCount * config.keybuyprice;
  221. var count = 0;
  222. for (i in theirItems) {
  223. var item = theirItems[i];
  224. if (item.market_name == "Refined Metal") {
  225. if (currencyRequired - 1 >= 0) {
  226. offer.addMyItem(item);
  227. currencyRequired -= 1;
  228. count++;
  229. }
  230. }
  231. }
  232. for (i in theirItems) {
  233. var item = theirItems[i]
  234. if (item.market_name == "Reclaimed Metal") {
  235. if (currencyRequired - 1 / 3 >= 0) {
  236. offer.addMyItem(item);
  237. currencyRequired -= 1 / 3;
  238. }
  239. }
  240. }
  241. for (i in theirItems) {
  242. var item = theirItems[i]
  243. if (item.market_name == "Scrap Metal") {
  244. if (toUpper(currencyRequired - 1 / 9) >= 0) {
  245. offer.addMyItem(item);
  246. currencyRequired -= 1 / 9;
  247. }
  248. }
  249. }
  250. if (toLower(currencyRequired) > 0) {
  251. friends.sendMessage(user, "Out of metal. Check back later.");
  252. console.log("Out of metal.")
  253. return;
  254.  
  255. }
  256. friends.sendMessage(user, "Confirming Offer...");
  257. var uuid = code()
  258. friends.sendMessage(user, "Your trade offer will arrive within 10 seconds. You will have 2 minutes to accept. Make sure your transaction ID is " + uuid + "!");
  259. offer.send("Transaction ID: " + uuid + ". Thanks for using " + config.ownername + "'s Trading Bot!");
  260. community.getSteamUser(user, function(err, cmt) {
  261.  
  262. // cmt.comment(config.profilecomment)
  263. });
  264. });
  265. });
  266. }
  267. });
  268. }
  269. });
  270.  
  271. function getPersonaName(steamID, callback) {
  272. var url = "http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=" + config.steamapikey + "&steamids=" + steamID;
  273. request(url, function(error, response, body) {
  274. if (!error && response.statusCode == 200) {
  275. var name = JSON.parse(body).response.players[0].personaname;
  276. callback(name);
  277. }
  278. });
  279. }
  280.  
  281. manager.on("newOffer", function(offer) {
  282. // offer.accept();
  283. });
  284.  
  285. function currentTimeMillis() {
  286. var d = new Date();
  287. return d.getTime();
  288. }
  289.  
  290. function getCurrencyValue(thing) {
  291. if (thing == "Mann Co. Supply Crate Key") {
  292. return 0;
  293. } else if (thing == "Refined Metal") {
  294. return 1;
  295. } else if (thing == "Reclaimed Metal") {
  296. return 1 / 3;
  297. } else if (thing == "Scrap Metal") {
  298. return 1 / 9;
  299. } else {
  300. return 0;
  301. }
  302. }
  303.  
  304. friends.on("friendMsg", function(user, msg, types) {
  305. msg = msg.toLowerCase();
  306. if (types == Steam.EChatEntryType.ChatMsg) {
  307. manager.getEscrowDuration(user, function(err, their, ours) {
  308. if (err) {
  309. return;
  310. }
  311. if (their != 0) {
  312. friends.sendMessage(user, "You have a trade hold, therefore i cannot trade with you. If you would like to remove this, check out this video: https://www.youtube.com/watch?v=2CUeUmeVBgs")
  313. return;
  314. }
  315.  
  316. if (msg.startsWith("buytod")) {
  317. var reqtodCount = 1;
  318. console.log("Incoming Request: User wants to buy " + reqtodCount + " ticket(s)")
  319. friends.sendMessage(user, "Please wait while I process your offer...");
  320.  
  321.  
  322. reqtodCount = parseInt(msg.split(" ")[1]);
  323.  
  324. var offer = manager.createOffer(user);
  325. manager.loadInventory(440, 2, true, function(err, myItems) {
  326. if (err) {
  327. console.log(err);
  328. return;
  329. }
  330.  
  331. offer.loadPartnerInventory(440, 2, function(err, theirItems) {
  332. if (err) {
  333. console.log(err);
  334. return;
  335. }
  336. var amount = reqtodCount;
  337. for (i in myItems) {
  338. var item = myItems[i]
  339. if (amount <= 0) continue;
  340. if (item.market_name === "Tour of Duty Ticket") {
  341. offer.addMyItem(item);
  342. amount -= 1;
  343. }
  344. }
  345. if (amount != 0) {
  346. friends.sendMessage(user, "Out of Tickets! Check back later!");
  347. return;
  348. }
  349. var currencyRequired = reqtodCount * config.todsellprice;
  350. var count = 0;
  351. for (i in theirItems) {
  352. var item = theirItems[i];
  353. if (item.market_name == "Refined Metal") {
  354. if (currencyRequired - 1 >= 0) {
  355. offer.addTheirItem(item);
  356. currencyRequired -= 1;
  357. count++;
  358. }
  359. }
  360. }
  361. for (i in theirItems) {
  362. var item = theirItems[i]
  363. if (item.market_name == "Reclaimed Metal") {
  364. if (currencyRequired - 1 / 3 >= 0) {
  365. offer.addTheirItem(item);
  366. currencyRequired -= 1 / 3;
  367. }
  368. }
  369. }
  370. for (i in theirItems) {
  371. var item = theirItems[i]
  372. if (item.market_name == "Scrap Metal") {
  373. if (toUpper(currencyRequired - 1 / 9) >= 0) {
  374. offer.addTheirItem(item);
  375. currencyRequired -= 1 / 9;
  376. }
  377. }
  378. }
  379. if (toLower(currencyRequired) > 0) {
  380. friends.sendMessage(user, "Failed To Send Offer: Could not find required metal to complete the trade offer.");
  381. console.log("Underpay")
  382. return;
  383.  
  384. }
  385. friends.sendMessage(user, "Confirming Offer...");
  386. var uuid = code()
  387. friends.sendMessage(user, "Your trade offer will arrive within 10 seconds. You will have 2 minutes to accept. Make sure your transaction ID is " + uuid + "!");
  388. offer.send("Transaction ID: " + uuid + ". Thanks for using " + config.ownername + "'s Trading Bot!");
  389. community.getSteamUser(user, function(err, cmt) {
  390.  
  391. // cmt.comment(config.profilecomment)
  392. });
  393. });
  394. });
  395.  
  396.  
  397. } else
  398. // Command to display stock levels
  399. if (msg.startsWith("stock")) {
  400. friends.sendMessage(user, "Checking Stock Levels...");
  401. console.log("Stock command received.");
  402.  
  403. var no_key=0;
  404. var no_rec=0;
  405. var no_scrap=0;
  406. var no_ref=0;
  407. var no_tod=0;
  408.  
  409. manager.loadInventory(440, 2, true, function(err, myItems) {
  410. if (err) {
  411. console.log(err);
  412. return;
  413. }
  414. for (i in myItems) {
  415. var item = myItems[i]
  416. if (item.market_name == "Mann Co. Supply Crate Key") {
  417. no_key++;
  418. } else
  419. if (item.market_name == "Reclaimed Metal") {
  420. no_rec++;
  421. } else
  422. if (item.market_name == "Scrap Metal") {
  423. no_scrap++;
  424. } else
  425. if (item.market_name == "Refined Metal") {
  426. no_ref++;
  427. } else
  428. if (item.market_name == "Tour of Duty Ticket") {
  429. no_tod++;
  430. }
  431. }
  432. var msguser = "Current Stock:"
  433. if (no_key >0) {
  434. msguser = msguser+"\r\nKeys: "+no_key
  435. }
  436. if (no_tod >0) {
  437. msguser = msguser+"\r\nTod: "+no_tod
  438. }
  439. if (no_ref >0) {
  440. msguser = msguser+"\r\nRef: "+no_ref
  441. }
  442. if (no_rec >0) {
  443. msguser = msguser+"\r\nRec: "+no_rec
  444. }
  445. if (no_scrap >0) {
  446. msguser = msguser+"\r\nScrap: "+no_scrap
  447. }
  448. console.log(msguser);
  449. friends.sendMessage(user, msguser);
  450. });
  451.  
  452.  
  453. } else
  454. if (msg.startsWith("selltod")) {
  455. var reqtodCount = 1;
  456. reqtodCount = parseInt(msg.split(" ")[1]);
  457. console.log("Incoming Request: User wants to sell us " + reqtodCount + " ticket(s)")
  458. friends.sendMessage(user, "Please wait while I process your offer...");
  459. var offer = manager.createOffer(user);
  460. manager.loadInventory(440, 2, true, function(err, theirItems) {
  461. if (err) {
  462. console.log(err);
  463. return;
  464. }
  465. offer.loadPartnerInventory(440, 2, function(err, myItems) {
  466. if (err) {
  467. console.log(err);
  468. return;
  469. }
  470. var amount = reqtodCount;
  471. for (i in myItems) {
  472. var item = myItems[i]
  473. if (amount <= 0) continue;
  474. if (item.market_name === "Tour of Duty Ticket") {
  475. offer.addTheirItem(item);
  476. amount -= 1;
  477. }
  478. }
  479. if (amount != 0) {
  480. friends.sendMessage(user, "Failed To Send Offer: Failed to find the Tickets in your inventory. This could also be due to the TF2 API.");
  481. return;
  482. }
  483. var currencyRequired = reqtodCount * config.todbuyprice;
  484. var count = 0;
  485. for (i in theirItems) {
  486. var item = theirItems[i];
  487. if (item.market_name == "Refined Metal") {
  488. if (currencyRequired - 1 >= 0) {
  489. offer.addMyItem(item);
  490. currencyRequired -= 1;
  491. count++;
  492. }
  493. }
  494. }
  495. for (i in theirItems) {
  496. var item = theirItems[i]
  497. if (item.market_name == "Reclaimed Metal") {
  498. if (currencyRequired - 1 / 3 >= 0) {
  499. offer.addMyItem(item);
  500. currencyRequired -= 1 / 3;
  501. }
  502. }
  503. }
  504. for (i in theirItems) {
  505. var item = theirItems[i]
  506. if (item.market_name == "Scrap Metal") {
  507. if (toUpper(currencyRequired - 1 / 9) >= 0) {
  508. offer.addMyItem(item);
  509. currencyRequired -= 1 / 9;
  510. }
  511. }
  512. }
  513. if (toLower(currencyRequired) > 0) {
  514. friends.sendMessage(user, "Out of metal. Check back later.");
  515. console.log("Out of metal. Possible that you have no change.")
  516. return;
  517.  
  518. }
  519. friends.sendMessage(user, "Confirming Offer...");
  520. var uuid = code()
  521. friends.sendMessage(user, "Your trade offer will arrive within 10 seconds. You will have 2 minutes to accept. Make sure your transaction ID is " + uuid + "!");
  522. offer.send("Transaction ID: " + uuid + ". Thanks for using " + config.ownername + "'s Trading Bot!");
  523. });
  524. });
  525. }
  526. });
  527. }
  528. });
  529.  
  530. function getPersonaName(steamID, callback) {
  531. var url = "http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?tod=" + config.steamapitod + "&steamids=" + steamID;
  532. request(url, function(error, response, body) {
  533. if (!error && response.statusCode == 200) {
  534. var name = JSON.parse(body).response.players[0].personaname;
  535. callback(name);
  536. }
  537. });
  538. }
  539.  
  540. manager.on("newOffer", function(offer) {
  541. // offer.accept();
  542. });
  543.  
  544. function currentTimeMillis() {
  545. var d = new Date();
  546. return d.getTime();
  547. }
  548.  
  549. function getCurrencyValue(thing) {
  550. if (thing == "Tour of Duty Ticket") {
  551. return 0;
  552. } else if (thing == "Refined Metal") {
  553. return 1;
  554. } else if (thing == "Reclaimed Metal") {
  555. return 1 / 3;
  556. } else if (thing == "Scrap Metal") {
  557. return 1 / 9;
  558. } else {
  559. return 0;
  560. }
  561. }
  562.  
  563.  
  564. function toLower(num) {
  565. return Math.floor(num * 10) / 10
  566.  
  567. }
  568.  
  569. function toUpper(num) {
  570. return Math.ceil(num * 10) / 10
  571.  
  572. }
  573.  
  574. friends.on("friendMsg", function(user, msg, types) {
  575. msg = msg.toLowerCase();
  576. if (types == Steam.EChatEntryType.ChatMsg) {
  577. if (msg == "help") {
  578. friends.sendMessage(user, "Commands: \nbuykey <number of keys you want to buy> \nbuytod <number of TOD you want to buy> \nsellkey <number of keys you want to sell> \nselltod <number of TOD you want to sell> \nE.G: buykey 1 or selltod 2 \nprices: Prices bot buys/sells items for. \nstock: List of available items \ngroup: Link to the steam group. \nowner: Link to the owner's profile.");
  579. return;
  580. }
  581. }
  582. });
  583.  
  584. friends.on("friendMsg", function(user, msg, types) {
  585. msg = msg.toLowerCase();
  586. if (types == Steam.EChatEntryType.ChatMsg) {
  587. if (msg == "price") {
  588. friends.sendMessage(user, "Current prices: \nBuying Keys for " + config.keybuyprice + ". \nSelling keys for " + config.keysellprice + ". \nBuying TOD Tickets for " + config.todbuyprice + ". \nSelling TOD Tickets for " + config.todsellprice + ". \nFor more useful commands type help.");
  589. return;
  590. }
  591. }
  592. });
  593.  
  594. friends.on("friendMsg", function(user, msg, types) {
  595. msg = msg.toLowerCase();
  596. if (types == Steam.EChatEntryType.ChatMsg) {
  597. if (msg == "prices") {
  598. friends.sendMessage(user, "Current prices: \nBuying Keys for " + config.keybuyprice + ". \nSelling keys for " + config.keysellprice + ". \nBuying TOD Tickets for " + config.todbuyprice + ". \nSelling TOD Tickets for " + config.todsellprice + ". \nFor more useful commands type help.");
  599. return;
  600. }
  601. }
  602. });
  603.  
  604. friends.on("friendMsg", function(user, msg, types) {
  605. msg = msg.toLowerCase();
  606. if (types == Steam.EChatEntryType.ChatMsg) {
  607. if (msg == "group") {
  608. friends.sendMessage(user, "Join the group for updates: " + "http://steamcommunity.com/groups/W3bb0sBots"+ " For more useful commands type help.");
  609. return;
  610. }
  611. }
  612. });
  613.  
  614. friends.on("friendMsg", function(user, msg, types) {
  615. msg = msg.toLowerCase();
  616. if (types == Steam.EChatEntryType.ChatMsg) {
  617. if (msg == "owner") {
  618. friends.sendMessage(user, "Having problems? Add the owner of this bot here: " + config.ownerurl + " For more useful commands type help.");
  619. return;
  620. }
  621. }
  622. });
  623.  
  624.  
  625. community.on('confKeyNeeded', function(tag, callback) {
  626. var time = Math.floor(Date.now() / 1000);
  627. callback(null, time, SteamTotp.getConfirmationKey(config.identitysecret, time, tag));
  628. });
  629.  
  630. community.on('newConfirmation', function(conf) {
  631. conf.respond(Math.floor(Date.now() / 1000), SteamTotp.getConfirmationKey(config.identitysecret, Math.floor(Date.now() / 1000), "allow"), true, function(err) {
  632. if (err) {
  633. console.log("Confirmation failed: " + err);
  634. return;
  635. }
  636. console.log("Sucessfully sent the trade. Waiting for User to accept...");
  637. console.log(colors.rainbow("=============================="));
  638. });
  639.  
  640. });
  641.  
  642. var token = config.bptftoken;
  643.  
  644. var yes = setInterval(function() {
  645. console.log("Bot is still alive.");
  646. }, 1000 * 60 * 10);
  647.  
  648. var no = setInterval(function() {
  649. if (client.steamID && token != "" && token != "optional") {
  650. heartbeat(client.steamID.toString(), config.bptftoken)
  651. }
  652. }, 1000 * 60 * 5);
  653.  
  654. function heartbeat(sid, token) {
  655. if (!token) {
  656. return;
  657. }
  658. request.post({
  659. "uri": "https://backpack.tf/api/IAutomatic/IHeartBeat/",
  660. "form": {
  661. "method": "alive",
  662. "version": "1.2.4",
  663. "steamid": sid,
  664. "token": token
  665. },
  666. "json": true
  667. }, function(err, response, body) {
  668. if (err || response.statusCode != 200) {
  669. console.log("Error occurred contacting backpack.tf (" + (err ? err.message : "HTTP error " + response.statusCode) + "), trying again in 60 seconds");
  670. } else if (!body.success) {
  671. console.log(body.message || "Invalid backpack.tf token");
  672. } else {
  673. console.log("Heartbeat sent to backpack.tf." + (body.bumped ? " " + body.bumped + " listing" + (body.bumped == 1 ? '' : 's') + " bumped." : ""));
  674. }
  675. });
  676. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement