From c235820e9d560d932ba42581601cf46f6ad7cbce Mon Sep 17 00:00:00 2001 From: Vaibhav Barot Date: Tue, 19 Oct 2021 14:27:14 +0530 Subject: [PATCH 1/2] Changing badge logic Change logic for comparing bot sets with badge page for people with too many badges. --- app/app.js | 218 +++++++++++++++++++++++++++++++---------------------- 1 file changed, 129 insertions(+), 89 deletions(-) diff --git a/app/app.js b/app/app.js index 3c7b779..26ccfdf 100644 --- a/app/app.js +++ b/app/app.js @@ -16,7 +16,7 @@ * Donations: Crypto: https://refloow.com/cdonate - Steam: https://steamcommunity.com/tradeoffer/new/?partner=994828078&token=XEUdbqp6 + Steam: https://steamcommunity.com/tradeoffer/new/?partner=392773011&token=CncehZti --------------------------------------------------------------------------------------------*/ /* @@ -196,7 +196,7 @@ refloow.on("webSession", (sessionID, cookies) => { totalBotSets = botNSets; let playThis = CONFIG.PLAYGAMES; if (CONFIG.PLAYGAMES && typeof(CONFIG.PLAYGAMES) == "string") { - playThis = parseString(playThis, totalBotSets); + playThis = parseString(playThis, totalBotSets,CONFIG.CARDS.BUY1KEYFORAMOUNTOFSETS,CONFIG.CARDS.BUY1KEYFORAMOUNTOFSETSTF2,CONFIG.CARDS.BUY1GEMSFORAMOUNTOFSETS); } refloow.gamesPlayed(playThis); logcolors.true(`| [Start] |: Successfully checked for offline friend requests.`) @@ -250,7 +250,8 @@ refloow.on("friendRelationship", (SENDER, REL) => { } } if(method.SendingWelcomeMessage()) { - refloow.chatMessage(SENDER, CONFIG.WELCOME); + console.log(SENDER); + refloow.chatMessage(SENDER, CONFIG.WELCOME.replace("%sender%", SENDER)); } } }); @@ -549,21 +550,23 @@ if (MSG.toUpperCase() == "!OWNER") { else if(MSG.toUpperCase() == "!PRICE" || MSG.toUpperCase() == "!PRICES" || MSG.toUpperCase() == "!RATE") { - refloow.chatMessage(SENDER, `/code The current prices are:\n` + - "________________________\n"+ - "|____ME___|_____YOU_____|\n"+ - "| " + CONFIG.CARDS.BUY1KEYFORAMOUNTOFSETS + ` sets ` + "|" + ` 1 CSGO key ` + " |\n" + - "| " + CONFIG.CARDS.BUY1KEYFORAMOUNTOFSETSHYDRA + ` sets ` + "|" + ` 1 Hydra key ` + "|\n" + - "| " + CONFIG.CARDS.BUY1KEYFORAMOUNTOFSETSTF2 + ` sets ` + "|" + ` 1 TF 2 key ` + " |\n" + - "| " + `01 set ⠀` + "| " + CONFIG.CARDS.BUY1GEMSFORAMOUNTOFSETS+ ` gems ` + " |\n\n" + + let message = `/code The current prices are:\n` + message+= "________________________\n" + message+= "|____ME___|_____YOU_____|\n" + + if(method.UserBuyingWithCSGO) { message+= "| " + CONFIG.CARDS.BUY1KEYFORAMOUNTOFSETS + ` sets ` + "|" + ` 1 CSGO key ` + " |\n" } + if(method.UserBuyingWithHydra) { message+= "| " + CONFIG.CARDS.BUY1KEYFORAMOUNTOFSETSHYDRA + ` sets ` + "|" + ` 1 Hydra key ` + "|\n" } + if(method.UserBuyingWithTF2) { message+= "| " + CONFIG.CARDS.BUY1KEYFORAMOUNTOFSETSTF2 + ` sets ` + "|" + ` 1 TF 2 key ` + " |\n" } + if(method.UserBuyingWithGems) { message+= "| " + `01 set ⠀` + "| " + CONFIG.CARDS.BUY1GEMSFORAMOUNTOFSETS+ ` gems ` + " |\n\n" } - "_________________________\n"+ - "|___YOU___|_____ME______|\n"+ + message+= "_________________________\n" + message+= "|___YOU___|_____ME______|\n" - "| " + CONFIG.CARDS.GIVE1KEYPERAMOUNTOFSETS + ` sets ` + "|" + ` 1 CSGO key ` + " |\n" + - "| " + CONFIG.CARDS.GIVE1KEYPERAMOUNTOFSETSHYDRA + ` sets ` + "|" + ` 1 Hydra key ` + "|\n" + - "| " + CONFIG.CARDS.GIVE1KEYPERAMOUNTOFSETSTF2 + ` sets ` + "|" + ` 1 TF 2 key ` + " |\n"+ - "| " + `01 set ⠀` + "| " + CONFIG.CARDS.GIVE1GEMSFORAMOUNTOFSETSGEMS+ ` gems ` + " |\n" ); + if(method.UserSellingWithCSGO) { message+= "| " + CONFIG.CARDS.GIVE1KEYPERAMOUNTOFSETS + ` sets ` + "|" + ` 1 CSGO key ` + " |\n" } + if(method.UserSellingWithHydra) { message+= "| " + CONFIG.CARDS.GIVE1KEYPERAMOUNTOFSETSHYDRA + ` sets ` + "|" + ` 1 Hydra key ` + "|\n" } + if(method.UserSellingWithTF2) { message+= "| " + CONFIG.CARDS.GIVE1KEYPERAMOUNTOFSETSTF2 + ` sets ` + "|" + ` 1 TF 2 key ` + " |\n" } + if(method.UserSellingWithGems) { message+= "| " + `01 set ⠀` + "| " + CONFIG.CARDS.GIVE1GEMSFORAMOUNTOFSETSGEMS+ ` gems ` + " |\n" } + refloow.chatMessage(SENDER,message); } @@ -1458,8 +1461,7 @@ else if (MSG.toUpperCase().indexOf("!LEVEL") >= 0) { } } - } else if (MSG.toUpperCase().indexOf("!BUYGEMS") >= 0) { - if (botSets) { + } else if (MSG.toUpperCase().indexOf("!BUYGEMS") >= 0) {if (botSets) { let n = MSG.toUpperCase().replace("!BUYGEMS ", ""), amountofgems = parseInt(n) * CONFIG.CARDS.BUY1GEMSFORAMOUNTOFSETS; if(method.UserBuyingWithGems()) { @@ -1490,63 +1492,49 @@ else if (MSG.toUpperCase().indexOf("!LEVEL") >= 0) { refloow.chatMessage(SENDER.getSteamID64(),"/pre ⚠️ Looks like your inventory doesn't have any gems at all. Please try after you have them."); } else{ - - if (INV[0].amount < amountofgems) { - logcolors.fail("| [Debug] |: User does not have enough gems." ); - refloow.chatMessage(SENDER, "/pre ⚠️ Please make sure you have enough unpacked gems."); + let total=amountofgems; + for( let i=0;i=total) + { + INV[i].amount=total.toString(); + total-=total; + theirGems.push(INV[i]); + break; + } + else + { + theirGems.push(INV[i]); + total=total-INV[i].amount; + } + } + if (total > 0) { + logcolors.fail("| [Debug] |: User does not have enough gems." ); + refloow.chatMessage(SENDER, "/pre ⚠️ Please make sure you have enough unpacked gems."); - } + } - else { - INV[0].amount=amountofgems.toString(); - theirGems.push(INV[0]); + else { + Utils.getBadges(SENDER.getSteamID64(), (ERR, DATA) => { if (!ERR) { logcolors.info("| [Debug] |: DEBUG#BADGE LOADED"); if (!ERR) { let b = {}; // List with badges that CAN still be crafted - if (DATA) { - for (let i = 0; i < Object.keys(DATA).length; i++) { - if (DATA[Object.keys(DATA)[i]] < 6) { - b[Object.keys(DATA)[i]] = 5 - DATA[Object.keys(DATA)[i]]; - } - } - } else { - refloow.chatMessage(SENDER.getSteamID64(), "/pre Your badges are empty, sending an offer without checking badges."); - } - - - - // TODO: COUNT AMOUNT OF SETS BOT CAN GIVE HIM - // 1: GET BOTS CARDS. DONE - // 2: GET PLAYER's BADGES. DONE - // 3: MAGIC - let hisMaxSets = 0, - botNSets = 0; - // Loop for sets he has partially completed - - for (let i = 0; i < Object.keys(b).length; i++) { - - if (botSets[Object.keys(b)[i]] && Object.values(b)[i]>0) { - hisMaxSets += Math.min(5,botSets[Object.keys(b)[i]].length,Object.values(b)[i]); - - } - } - // Loop for sets he has never crafted - for (let i = 0; i < Object.keys(botSets).length; i++) { - - if (Object.keys(b).indexOf(Object.keys(botSets)[i]) < 0) { - if (botSets[Object.keys(botSets)[i]].length >= 5) { - hisMaxSets += 5; - } else { - hisMaxSets += botSets[Object.keys(botSets)[i]].length; - } - } - botNSets += botSets[Object.keys(botSets)[i]].length; - } - //console.log("Number of sets:"+n); - //console.log("His max sets:"+hisMaxSets); - //logcolors.info("| [Debug] |: Number of sets:"+n "); + let hisMaxSets=0; + let botNSets=0; + if(!DATA) console.log("/pre Your badges are empty, sending an offer without checking badges."); + + for(let i=0; i 0) + { + let setsLeft = 5 - DATA[Object.keys(botSets)[i]]; + if(setsLeft > 0 ) hisMaxSets+= Math.min(setsLeft,botSets[Object.keys(botSets)[i]].length) + } + else hisMaxSets+= Math.min(5,botSets[Object.keys(botSets)[i]].length); + botNSets += botSets[Object.keys(botSets)[i]].length; + } logcolors.info("| [Debug] |: Loop 2 DONE"); // HERE if (n <= hisMaxSets) { @@ -1557,50 +1545,55 @@ else if (MSG.toUpperCase().indexOf("!LEVEL") >= 0) { logcolors.info("| [Debug] |: Sets Sorted"); firstLoop: for (let i = 0; i < DATA.length; i++) { - if (b[DATA[i]] == 0) { + //DATA values = appids , eg DATA[i] = 730 + if (b[DATA[i]] >= 5) { + continue firstLoop; } else { + logcolors.info("| [Debug] |: DEBUG#" + i); logcolors.info("| [Debug] |: DEBUG FOR LOOP ITEMS"); if (hisMaxSets > 0) { logcolors.info("| [Debug] |: DEBUG# MAXSETSMORETHAN1"); - if (b[DATA[i]] && botSets[DATA[i]].length >= b[DATA[i]]) { + if (b[DATA[i]] && botSets[DATA[i]].length >= 5 - b[DATA[i]]) { // BOT HAS ENOUGH SETS OF THIS KIND logcolors.info("| [Debug] |: Loop 1"); - sLoop: for (let j = 0; j < b[DATA[i]]; j++) { - if(hisMaxSets>0){ + sLoop: for (let j = 0; j < 5-b[DATA[i]]; j++) { + if(hisMaxSets>0) + { logcolors.info("| [Debug] |: loop #1 CONTINUE: ITEM ADD"); logcolors.info("| [Debug] |: DEBUG#LOOP #1: " + botSets[DATA[i]][j]); t.addMyItems(botSets[DATA[i]][j]); hisMaxSets--; - } + } } - } else if (b[DATA[i]] && botSets[DATA[i]].length < b[DATA[i]]) { + } else if (b[DATA[i]] && botSets[DATA[i]].length < 5-b[DATA[i]]) { // BOT DOESNT HAVE ENOUGH SETS OF THIS KIND + + sLoop: for (let j = 0; j < botSets[DATA[i]].length; j++) { - if(hisMaxSets>0){ + if(hisMaxSets>0){ logcolors.info("| [Debug] |: loop #1 CONTINUE: ITEM ADD"); logcolors.info("| [Debug] |: DEBUG#LOOP #1: " + botSets[DATA[i]][j]); t.addMyItems(botSets[DATA[i]][j]); hisMaxSets--; - } + } } // * } else if (!b[DATA[i]]) { // TODO NOT FOR LOOP WITH BOTSETS. IT SENDS ALL // BOT HAS ENOUGH SETS AND USER NEVER CRAFTED THIS bLoop: for (let j = 0; j < Math.min(5,botSets[DATA[i]].length); j++) { - if (botSets[DATA[i]][j] && hisMaxSets > 0) { + if(botSets[DATA[i]][j] && hisMaxSets>0) + { t.addMyItems(botSets[DATA[i]][j]); logcolors.info("| [Debug] |: loop #2 CONTINUE: ITEM ADD"); hisMaxSets--; - } else { - logcolors.info("| [Debug] |: loop #2 CONTINUE: RETURN"); - continue firstLoop; - } + } + } } @@ -1608,12 +1601,12 @@ else if (MSG.toUpperCase().indexOf("!LEVEL") >= 0) { logcolors.info("| [Debug] |: RETURN"); break firstLoop; } - } + } } if (hisMaxSets > 0) { - refloow.chatMessage(SENDER, "/pre ⚠️ There are not enough sets. Please try again later."); + refloow.chatMessage(SENDER,"/pre ⚠️ There are not enough sets. Please try again later."); } else { - logcolors.info("| [Debug] |: -SENDING"); + logcolors.info("| [Debug] |: -SENDING"); t.addTheirItems(theirGems); t.data("commandused", MSG); t.data("quantity", amountofgems); @@ -1631,6 +1624,7 @@ else if (MSG.toUpperCase().indexOf("!LEVEL") >= 0) { } }); } + }); } else { refloow.chatMessage(SENDER, "/pre ⚠️ There are currently not enough sets that you have not used in stock for this amount of Gems."); @@ -1657,7 +1651,7 @@ else if (MSG.toUpperCase().indexOf("!LEVEL") >= 0) { } }); } else { - refloow.chatMessage(SENDER, "/pre ⚠️ Please try a lower amount of Gems."); + refloow.chatMessage(SENDER, "/pre ⚠️ Please try a lower amount of sets. This bot only sells " + CONFIG.MAXBUY + " sets a time."); } } else { refloow.chatMessage(SENDER, "/pre ⚠️ Please provide a valid amount of Sets."); @@ -2032,7 +2026,7 @@ else if (MSG.toUpperCase().indexOf("!LEVEL") >= 0) { // Withdraw command - else if (MSG.toUpperCase() == "!WITHDRAW") { + else if (MSG.toUpperCase() == "!WITHDRAWTF") { let t = manager.createOffer(SENDER.getSteamID64()); manager.getInventoryContents(440, 2, true, (ERR, INV, CURR) => { if (ERR) { @@ -2053,6 +2047,48 @@ else if (MSG.toUpperCase().indexOf("!LEVEL") >= 0) { } }); } + + else if(MSG.toUpperCase() == "!WITHDRAWSETS") + { + let t = manager.createOffer(SENDER.getSteamID64()); + t.getUserDetails((ERR,ME,THEM) =>{ + if(ERR) + { + logcolors.fail("| [Debug] |: An error occurred while getting trade holds: " + ERR); + refloow.chatMessage(SENDER,"/pre ⚠️ An error occurred while getting your trade holds. Please try again"); + } + else if(ME.escrowDays == 0 && THEM.escrowDays == 0){ + sortSetsByAmount(botSets, (DATA) => { + for(let i=0; i { + if (ERR) { + refloow.chatMessage(SENDER,"/pre ⚠️ An error occurred while sending your trade. Steam Trades could be down. Please try again later."); + logcolors.fail("| [Steam] |: An error occurred while sending trade: " + ERR); + + } else { + refloow.chatMessage(SENDER, "/me ✔️ Trade Sent! Confirming it..."); + logcolors.info("| [Steam] |: Trade offer sent!"); + } + + }); + } + else{ + refloow.chatMessage(SENDER,"/pre ⚠️ Please make sure you don't have a trade hold!"); + } + }); + } @@ -2203,7 +2239,7 @@ manager.on("sentOfferChanged", (OFFER, OLDSTATE) => { totalBotSets = botNSets; let playThis = CONFIG.PLAYGAMES; if (CONFIG.PLAYGAMES && typeof(CONFIG.PLAYGAMES) == "string") { - playThis = parseString(playThis, totalBotSets); + playThis = parseString(playThis, totalBotSets,CONFIG.CARDS.BUY1KEYFORAMOUNTOFSETS,CONFIG.CARDS.BUY1KEYFORAMOUNTOFSETSTF2,CONFIG.CARDS.BUY1GEMSFORAMOUNTOFSETS); } refloow.gamesPlayed(playThis); }); @@ -2304,8 +2340,12 @@ function sortSetsByAmountB(SETS, callback) { } -function parseString(INPUT, SETS) { - return INPUT.replace(":sets:", SETS); +function parseString(INPUT, SETS, CS, TF, GEM) { + INPUT = INPUT.replace(":csgo:",CS); + INPUT = INPUT.replace(":tf2:",TF); + INPUT = INPUT.replace(":gems:",GEM); + INPUT = INPUT.replace(":sets:", SETS); + return INPUT; } From 58cd914fd8769a6e8304b0a3f3f6e6cd3084133c Mon Sep 17 00:00:00 2001 From: Vaibhav Barot Date: Tue, 19 Oct 2021 14:33:01 +0530 Subject: [PATCH 2/2] Change logic for checking badge --- app/functions.js | 385 ++++++++++++++++++++++------------------------- 1 file changed, 179 insertions(+), 206 deletions(-) diff --git a/app/functions.js b/app/functions.js index 8e583a3..9582c61 100644 --- a/app/functions.js +++ b/app/functions.js @@ -16,7 +16,7 @@ * Donations: Crypto: https://refloow.com/cdonate - Steam: https://steamcommunity.com/tradeoffer/new/?partner=994828078&token=XEUdbqp6 + Steam: https://steamcommunity.com/tradeoffer/new/?partner=392773011&token=CncehZti --------------------------------------------------------------------------------------------*/ /* @@ -91,237 +91,210 @@ Utils.getBadges(SENDER.getSteamID64(), (ERR, DATA, CURRENTLEVEL, XPNEEDED) => { }; f.MaxSets = (DATA,botSets,callback) => { - var response=""; - let b = {}; // List with badges that CAN still be crafted - if (DATA) { - for (let i = 0; i < Object.keys(DATA).length; i++) { - - if (DATA[Object.keys(DATA)[i]] < 6) { - b[Object.keys(DATA)[i]] = 5 - DATA[Object.keys(DATA)[i]]; - } - } - - } else { - console.log("/pre Your badges are empty, sending an offer without checking badges."); - } - // console.log(b); - // TODO: COUNT AMOUNT OF SETS BOT CAN GIVE HIM - // 1: GET BOTS CARDS. DONE - // 2: GET PLAYER's BADGES. DONE - // 3: MAGIC - let hisMaxSets = 0, - botNSets = 0; - // Loop for sets he has partially completed + hisMaxSets=0; + botNSets=0; + if(!DATA) console.log("/pre Your badges are empty, sending an offer without checking badges."); + + for(let i=0; i 0) + { + let setsLeft = 5 - DATA[Object.keys(botSets)[i]]; + if(setsLeft > 0 ) hisMaxSets+= Math.min(setsLeft,botSets[Object.keys(botSets)[i]].length) + } + else hisMaxSets+= Math.min(5,botSets[Object.keys(botSets)[i]].length); + botNSets += botSets[Object.keys(botSets)[i]].length; + } + + callback(hisMaxSets,botNSets,DATA); - for (let i = 0; i < Object.keys(b).length; i++) { - - if (botSets[Object.keys(b)[i]] && Object.values(b)[i]>0) { - hisMaxSets += Math.min(5,botSets[Object.keys(b)[i]].length,Object.values(b)[i]); - - } - } - // Loop for sets he has never crafted - for (let i = 0; i < Object.keys(botSets).length; i++) { - - if (Object.keys(b).indexOf(Object.keys(botSets)[i]) < 0) { - if (botSets[Object.keys(botSets)[i]].length >= 5) { - hisMaxSets += 5; - } else { - hisMaxSets += botSets[Object.keys(botSets)[i]].length; - } - } - botNSets += botSets[Object.keys(botSets)[i]].length; - } - callback(hisMaxSets,botNSets,b); - - - }; f.getHisKeys = (n,manager,SENDER,appid,contextid,botSets,amountofsets,setsThatShouldntBeSent,refloow,marketName,MSG,callback) => { let response; if (!isNaN(n) && parseInt(n) > 0) { - if (n <= CONFIG.MAXBUY) { - let t = manager.createOffer(SENDER.getSteamID64()); - t.getUserDetails((ERR, ME, THEM) => { + if (n <= CONFIG.MAXBUY) { + let t = manager.createOffer(SENDER.getSteamID64()); + t.getUserDetails((ERR, ME, THEM) => { + if (ERR) { + logcolors.fail("| [Debug] |: An error occurred while getting trade holds: " + ERR); + refloow.chatMessage(SENDER,"/pre ⚠️ An error occurred while getting your trade holds. Please try again"); + } else if (ME.escrowDays == 0 && THEM.escrowDays == 0) { + n = parseInt(n); + + logcolors.true('| [Refloow] |: Processing of request'); + refloow.chatMessage(SENDER,"/me Processing your request."); + manager.getUserInventoryContents(SENDER.getSteamID64(), appid, contextid, true, (ERR, INV, CURR) => { + + let theirKeys = []; + + if (ERR) { - logcolors.fail("| [Debug] |: An error occurred while getting trade holds: " + ERR); - refloow.chatMessage(SENDER,"/pre ⚠️ An error occurred while getting your trade holds. Please try again"); - } else if (ME.escrowDays == 0 && THEM.escrowDays == 0) { - n = parseInt(n); - - logcolors.true('| [Refloow] |: Processing of request'); - refloow.chatMessage(SENDER,"/me Processing your request."); - manager.getUserInventoryContents(SENDER.getSteamID64(), appid, contextid, true, (ERR, INV, CURR) => { - - let theirKeys = []; - - - if (ERR) { - logcolors.fail("| [Inventory] |: An error occurred while getting inventory: " + ERR); - refloow.chatMessage(SENDER,"/pre ⚠️ An error occurred while loading your inventory. Please try later"); + logcolors.fail("| [Inventory] |: An error occurred while getting inventory: " + ERR); + refloow.chatMessage(SENDER,"/pre ⚠️ An error occurred while loading your inventory. Please try later"); + } else { + logcolors.info("| [Debug] |: Inventory Loaded"); + if (!ERR) { + logcolors.info("| [Debug] |: Inventory Loaded 2"); + for (let i = 0; i < INV.length; i++) { + if (theirKeys.length < n && marketName.indexOf(INV[i].market_hash_name) >= 0) { + theirKeys.push(INV[i]); + } + } + if (theirKeys.length != n) { + refloow.chatMessage(SENDER,"/pre ⚠️ You do not have enough keys."); } else { - logcolors.info("| [Debug] |: Inventory Loaded"); - if (!ERR) { - logcolors.info("| [Debug] |: Inventory Loaded 2"); - for (let i = 0; i < INV.length; i++) { - if (theirKeys.length < n && marketName.indexOf(INV[i].market_hash_name) >= 0) { - theirKeys.push(INV[i]); - } - } - if (theirKeys.length != n) { - refloow.chatMessage(SENDER,"/pre ⚠️ You do not have enough keys."); - } else { - Utils.getBadges(SENDER.getSteamID64(), (ERR, DATA) => { - if (!ERR) { - logcolors.info("| [Debug] |: DEBUG#BADGE LOADED"); - if (!ERR) { - f.MaxSets(DATA,botSets, (hisMaxSets,botNSets,b) => - { - logcolors.info("| [Debug] |: Loop 2 DONE"); - // HERE - if (amountofsets <= hisMaxSets) { - hisMaxSets = amountofsets; - logcolors.info("| [Debug] |: Trade Created"); - sortSetsByAmount(botSets, (DATA) => { - logcolors.info("| [Debug] |:" + DATA); - logcolors.info("| [Debug] |: Sets Sorted"); - firstLoop: for (let i = 0; i < DATA.length; i++) { - - //DATA values = appids , eg DATA[i] = 730 - if (b[DATA[i]] == 0) { - - continue firstLoop; - } else { - - logcolors.info("| [Debug] |: DEBUG#" + i); - logcolors.info("| [Debug] |: DEBUG FOR LOOP ITEMS"); - if (hisMaxSets > 0) { - logcolors.info("| [Debug] |: DEBUG# MAXSETSMORETHAN1"); - if (b[DATA[i]] && botSets[DATA[i]].length >= b[DATA[i]]) { - - // BOT HAS ENOUGH SETS OF THIS KIND - logcolors.info("| [Debug] |: Loop 1"); - sLoop: for (let j = 0; j < b[DATA[i]]; j++) { - if(hisMaxSets>0) - { - logcolors.info("| [Debug] |: loop #1 CONTINUE: ITEM ADD"); - logcolors.info("| [Debug] |: DEBUG#LOOP #1: " + botSets[DATA[i]][j]); - t.addMyItems(botSets[DATA[i]][j]); - hisMaxSets--; - } - - - } - } else if (b[DATA[i]] && botSets[DATA[i]].length < b[DATA[i]]) { - // BOT DOESNT HAVE ENOUGH SETS OF THIS KIND - - - sLoop: for (let j = 0; j < botSets[DATA[i]].length; j++) { - if(hisMaxSets>0){ - logcolors.info("| [Debug] |: loop #1 CONTINUE: ITEM ADD"); - logcolors.info("| [Debug] |: DEBUG#LOOP #1: " + botSets[DATA[i]][j]); - t.addMyItems(botSets[DATA[i]][j]); - hisMaxSets--; - } - - } // * - } else if (!b[DATA[i]]) { // TODO NOT FOR LOOP WITH BOTSETS. IT SENDS ALL - // BOT HAS ENOUGH SETS AND USER NEVER CRAFTED THIS - - bLoop: for (let j = 0; j < Math.min(5,botSets[DATA[i]].length); j++) { - if(botSets[DATA[i]][j] && hisMaxSets>0) - { - t.addMyItems(botSets[DATA[i]][j]); - logcolors.info("| [Debug] |: loop #2 CONTINUE: ITEM ADD"); - hisMaxSets--; - } - + Utils.getBadges(SENDER.getSteamID64(), (ERR, DATA) => { + if (!ERR) { + logcolors.info("| [Debug] |: DEBUG#BADGE LOADED"); + if (!ERR) { + f.MaxSets(DATA,botSets, (hisMaxSets,botNSets,b) => + { + logcolors.info("| [Debug] |: Loop 2 DONE"); + // HERE + if (amountofsets <= hisMaxSets) { + hisMaxSets = amountofsets; + logcolors.info("| [Debug] |: Trade Created"); + sortSetsByAmount(botSets, (DATA) => { + logcolors.info("| [Debug] |:" + DATA); + logcolors.info("| [Debug] |: Sets Sorted"); + firstLoop: for (let i = 0; i < DATA.length; i++) { + + //DATA values = appids , eg DATA[i] = 730 + if (b[DATA[i]] >= 5) { + + continue firstLoop; + } else { + + logcolors.info("| [Debug] |: DEBUG#" + i); + logcolors.info("| [Debug] |: DEBUG FOR LOOP ITEMS"); + if (hisMaxSets > 0) { + logcolors.info("| [Debug] |: DEBUG# MAXSETSMORETHAN1"); + if (b[DATA[i]] && botSets[DATA[i]].length >= 5 - b[DATA[i]]) { + + // BOT HAS ENOUGH SETS OF THIS KIND + logcolors.info("| [Debug] |: Loop 1"); + sLoop: for (let j = 0; j < 5-b[DATA[i]]; j++) { + if(hisMaxSets>0) + { + logcolors.info("| [Debug] |: loop #1 CONTINUE: ITEM ADD"); + logcolors.info("| [Debug] |: DEBUG#LOOP #1: " + botSets[DATA[i]][j]); + t.addMyItems(botSets[DATA[i]][j]); + hisMaxSets--; } - } + + + } + } else if (b[DATA[i]] && botSets[DATA[i]].length < 5-b[DATA[i]]) { + // BOT DOESNT HAVE ENOUGH SETS OF THIS KIND + + + sLoop: for (let j = 0; j < botSets[DATA[i]].length; j++) { + if(hisMaxSets>0){ + logcolors.info("| [Debug] |: loop #1 CONTINUE: ITEM ADD"); + logcolors.info("| [Debug] |: DEBUG#LOOP #1: " + botSets[DATA[i]][j]); + t.addMyItems(botSets[DATA[i]][j]); + hisMaxSets--; + } + + } // * + } else if (!b[DATA[i]]) { // TODO NOT FOR LOOP WITH BOTSETS. IT SENDS ALL + // BOT HAS ENOUGH SETS AND USER NEVER CRAFTED THIS + + bLoop: for (let j = 0; j < Math.min(5,botSets[DATA[i]].length); j++) { + if(botSets[DATA[i]][j] && hisMaxSets>0) + { + t.addMyItems(botSets[DATA[i]][j]); + logcolors.info("| [Debug] |: loop #2 CONTINUE: ITEM ADD"); + hisMaxSets--; + } - } else { - logcolors.info("| [Debug] |: RETURN"); - break firstLoop; } } + + } else { + logcolors.info("| [Debug] |: RETURN"); + break firstLoop; } - if (hisMaxSets > 0) { - refloow.chatMessage(SENDER,"/pre ⚠️ There are not enough sets. Please try again later."); + } + } + if (hisMaxSets > 0) { + refloow.chatMessage(SENDER,"/pre ⚠️ There are not enough sets. Please try again later."); + } else { + logcolors.info("| [Debug] |: -SENDING"); + t.addTheirItems(theirKeys); + t.data("commandused", MSG); + t.data("quantity", n); + t.data("amountofsets", amountofsets.toString()); + t.data("index", setsThatShouldntBeSent.length); + setsThatShouldntBeSent.push(t.itemsToGive); + t.send((ERR, STATUS) => { + if (ERR) { + refloow.chatMessage(SENDER,"/pre ⚠️ An error occurred while sending your trade. Steam Trades could be down. Please try again later."); + logcolors.fail("| [Steam] |: An error occurred while sending trade: " + ERR); + } else { - logcolors.info("| [Debug] |: -SENDING"); - t.addTheirItems(theirKeys); - t.data("commandused", MSG); - t.data("quantity", n); - t.data("amountofsets", amountofsets.toString()); - t.data("index", setsThatShouldntBeSent.length); - setsThatShouldntBeSent.push(t.itemsToGive); - t.send((ERR, STATUS) => { - if (ERR) { - refloow.chatMessage(SENDER,"/pre ⚠️ An error occurred while sending your trade. Steam Trades could be down. Please try again later."); - logcolors.fail("| [Steam] |: An error occurred while sending trade: " + ERR); - - } else { - refloow.chatMessage(SENDER, "/me ✔️ Trade Sent! Confirming it..."); - logcolors.info("| [Steam] |: Trade offer sent!"); - logcolors.summary("| [Summary] |: Bot sent "+ amountofsets + " set(s) for their " + n +" key(s)"); - - } - - }); + refloow.chatMessage(SENDER, "/me ✔️ Trade Sent! Confirming it..."); + logcolors.info("| [Steam] |: Trade offer sent!"); + logcolors.summary("| [Summary] |: Bot sent "+ amountofsets + " set(s) for their " + n +" key(s)"); + } - + }); - } else { - - refloow.chatMessage(SENDER,"/pre ⚠️ There are currently not enough sets that you have not used in stock for this amount of keys."); - - } - }); // TO HERE - } else { - logcolors.fail(SENDER, "| [Steam] |: An error occurred while getting badges: " + ERR); - - } + + }); } else { - refloow.chatMessage(SENDER,"/pre ⚠️ An error occurred while getting your badges. Please try again."); - logcolors.fail(SENDER, "| [Steam] |: An error occurred while loading badges: " + ERR); - - + + refloow.chatMessage(SENDER,"/pre ⚠️ There are currently not enough sets that you have not used in stock for this amount of keys."); + + } - - }); + }); // TO HERE + } else { + logcolors.fail(SENDER, "| [Steam] |: An error occurred while getting badges: " + ERR); + + } + } else { + refloow.chatMessage(SENDER,"/pre ⚠️ An error occurred while getting your badges. Please try again."); + logcolors.fail(SENDER, "| [Steam] |: An error occurred while loading badges: " + ERR); + + } - } - - else { - logcolors.fail("| [Inventory] |: An error occurred while getting inventory: " + ERR); - response= "/pre ⚠️ An error occurred while loading your inventory, please make sure it's set to public."; - } + + }); } - - }); - } else { - refloow.chatMessage(SENDER,"/pre ⚠️ Please make sure you don't have a trade hold!"); - + } + + else { + logcolors.fail("| [Inventory] |: An error occurred while getting inventory: " + ERR); + response= "/pre ⚠️ An error occurred while loading your inventory, please make sure it's set to public."; + } } + }); - - } - - else { - refloow.chatMessage(SENDER,"/pre ⚠️ Please try a lower amount of keys."); - + } else { + refloow.chatMessage(SENDER,"/pre ⚠️ Please make sure you don't have a trade hold!"); + } - - } else { - refloow.chatMessage(SENDER,"/pre ⚠️ Please provide a valid amount of keys."); - - + }); + } - - + + else { + refloow.chatMessage(SENDER,"/pre ⚠️ Please try a lower amount of keys. This bot only sells " + CONFIG.MAXBUY + " keys at a time."); + + } + + } else { + refloow.chatMessage(SENDER,"/pre ⚠️ Please provide a valid amount of keys."); + + + } + callback(null); + + }; f.getHisSets = (n,manager,SENDER,appid,contextid,botSets,amountofsets,setsThatShouldntBeSent,refloow,marketName,community,allCards,MSG,callback) =>