Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let SteamUser = require("steam-user"),
- TradeOfferManager = require("steam-tradeoffer-manager"),
- SteamCommunity = require("steamcommunity"),
- SteamTotp = require("steam-totp"),
- BOTS = require("./SETTINGS/BOTS.js"),
- CONFIG = require("./SETTINGS/CONFIG.js"),
- TRADES = require("./SETTINGS/TRADES.js");
- class BotConstructor {
- constructor(name) {
- this.CLIENT = new SteamUser();
- this.TRADES = new TradeOfferManager({
- "steam": this.CLIENT,
- "language": "en",
- "pollInterval": "10000"
- });
- this.COMMUNITY = new SteamCommunity();
- this.AUTH = SteamTotp;
- this.NAME = name;
- }
- }
- let BOT = [];
- for (let i = 0; i < Object.keys(BOTS).length; i++) {
- BOT.push(new BotConstructor(Object.keys(BOTS)[i]));
- console.log(Object.keys(BOTS)[i] + " added to the bot list!");
- }
- for (let i = 0; i < BOT.length; i++) {
- BOT[i].CLIENT.logOn({
- accountName: BOTS[Object.keys(BOTS)[i]]["USERNAME"],
- password: BOTS[Object.keys(BOTS)[i]]["PASSWORD"],
- twoFactorCode: BOT[i].AUTH.getAuthCode(BOTS[Object.keys(BOTS)[i]]["SHAREDSECRET"])
- });
- BOT[i].CLIENT.on("loggedOn", (DETAILS, PARENTAL) => {
- console.log(BOT[i].NAME + ": Logged in. [" + BOT[i].CLIENT.steamID.getSteamID64() + "]");
- BOT[i].CLIENT.setPersona(SteamUser.Steam.EPersonaState.Online, BOTS[Object.keys(BOTS)[i]]["NAME"]);
- BOT[i].CLIENT.gamesPlayed(CONFIG.GAMESPLAYED);
- });
- BOT[i].CLIENT.on("webSession", (SESSIONID, COOKIES) => {
- BOT[i].TRADES.setCookies(COOKIES, (ERR) => {
- if (ERR) {
- console.log(BOT[i].NAME + ": An error occured while setting cookies: " + ERR);
- } else {
- console.log(BOT[i].NAME + ": Websession created and cookies set.");
- }
- });
- BOT[i].COMMUNITY.setCookies(COOKIES);
- BOT[i].COMMUNITY.startConfirmationChecker(10000, BOTS[Object.keys(BOTS)[i]]["IDENTITYSECRET"]);
- // BOT[i].COMMUNITY.getMarketItem(730, "P250 | Sand Dune (Factory New)", (ERR, ITEM) => { console.log(ITEM.medianSalePrices[0]);console.log(ITEM.medianSalePrices[ITEM.medianSalePrices.length-1]) });
- });
- BOT[i].COMMUNITY.on("sessionExpired", (ERR) => {
- BOT[i].COMMUNITY.startConfirmationChecker();
- console.log(BOT[i].NAME + ": Session Expired, relogging.");
- BOT[i].CLIENT.webLogOn();
- });
- BOT[i].CLIENT.on('friendRelationship', (steamid, relationship) => {
- if (relationship === 2) {
- BOT[i].CLIENT.addFriend(steamid);
- console.log(+ steamid.getSteamID64() + ` added the bot!`);
- BOT[i].CLIENT.chatMessage(steamid, `Welcome to my trade bot! You can send me a trade at ` +BOTS[Object.keys(BOTS)[i]]["URL"]); // optional, these can be removed/edited
- BOT[i].CLIENT.chatMessage(steamid, `If you have any questions contact my owner, King Ali, at http://steamcommunity.com/profiles/76561198110713513/`); // optional, these can be removed/edited
- } else if (relationship === 3) {
- if ("103582791460010606") {
- BOT[i].CLIENT.inviteToGroup(steamid, "103582791460010606");
- }
- BOT[i].CLIENT.chatMessage(steamid, "I invited you to our steam group! Feel free to join!");
- console.log( + steamid.getSteamID64() + ` Was invited to the steam group!`)
- }
- });
- BOT[i].TRADES.on("newOffer", (OFFER) => {
- OFFER.itemsToReceive.forEach(function(item) {
- console.log(BOT[i].NAME + ` : New trade offer from ` + OFFER.partner.getSteamID64() + `. Sending : ` + item.market_hash_name);
- });
- OFFER.itemsToGive.forEach(function(item) {
- console.log(BOT[i].NAME + ` : New trade offer from ` + OFFER.partner.getSteamID64() + `. Giving : ` + item.market_hash_name);
- });
- OFFER.getUserDetails((ERR, ME, THEM) => {
- if (ME.escrowDays !== 0 || THEM.escrowDays !== 0) {
- OFFER.decline((ERR) => {
- if (ERR) {
- console.log(BOT[i].NAME + ": An error occured while declining error: " + ERR);
- } else {
- console.log(BOT[i].NAME + `: Trade Declined from ` + OFFER.partner.getSteamID64() + ` because he doesn't have Mobile Auth.`);
- }
- });
- if (ERR) {
- console.log(BOT[i].NAME + ": There was an error getting user details: " + ERR);
- } else {
- if (CONFIG.ADMINS.indexOf(OFFER.partner.getSteamID64()) >= 0) {
- OFFER.accept((ERR) => {
- if (ERR) {
- console.log(BOT[i].NAME + ": An error occured while accepting error: " + ERR);
- } else {
- console.log(`[!] THIS IS AN ADMIN TRADE [!] `+ BOT[i].NAME + `: Trade Accepted from ` + OFFER.partner.getSteamID64() + `.`);
- }
- });
- } else if (OFFER.itemsToGive.length == 0) {
- OFFER.accept((ERR) => {
- if (ERR) {
- console.log(BOT[i].NAME + ": An error occured while accepting error: " + ERR);
- } else {
- console.log(BOT[i].NAME + `: Donation Accepted from ` + OFFER.partner.getSteamID64() + `.`);
- }
- });
- } else {
- // Trade
- let OFFERDETAILS = {
- THEM: {
- ITEMWORTHINKEYS: 0,
- KEYS: 0,
- DONE: false
- },
- ME: {
- ITEMWORTHINKEYS: 0,
- KEYS: 0,
- DONE: false
- },
- VALID: true
- };
- for (let j = 0; j < OFFER.itemsToReceive.length; j++) {
- if (Object.keys(TRADES).indexOf(OFFER.itemsToReceive[j]["market_hash_name"]) >= 0) {
- BOT[i].COMMUNITY.getMarketItem(OFFER.itemsToReceive[j]["appid"], OFFER.itemsToReceive[j]["market_hash_name"], (ERR, ITEM) => {
- if (ERR) {
- console.log("## An error occured while getting item price: " + ERR);
- } else {
- console.log(ITEM.medianSalePrices[ITEM.medianSalePrices.length - 1 - 168].price + " PRICE WEEK AGO");
- console.log(ITEM.medianSalePrices[ITEM.medianSalePrices.length - 1].price + " PRICE NOW");
- console.log(TRADES[OFFER.itemsToReceive[j]["market_hash_name"]]["buyForKeys"] + " PRICE SET");
- if (ITEM.medianSalePrices[ITEM.medianSalePrices.length - 1 - 168].price * 1 - (CONFIG.INFLUENCEPERCENTAGE / 100) >= ((ITEM.medianSalePrices[ITEM.medianSalePrices.length - 1].price + ITEM.medianSalePrices[ITEM.medianSalePrices.length - 1].price) / 2)) {
- console.log("+" + TRADES[OFFER.itemsToReceive[j]["market_hash_name"]]["buyForKeys"]);
- OFFERDETAILS.THEM.ITEMWORTHINKEYS += TRADES[OFFER.itemsToReceive[j]["market_hash_name"]]["buyForKeys"];
- } else {
- console.log("## Item is currently being influenced. Marking it worthless.");
- }
- }
- if (j == OFFER.itemsToReceive.length - 1) {
- OFFERDETAILS.THEM.DONE = true;
- }
- });
- } else if (CONFIG.ACCEPTEDKEYS.indexOf(OFFER.itemsToReceive[j]["market_hash_name"]) >= 0) {
- OFFERDETAILS.THEM.KEYS++;
- } else {
- OFFERDETAILS.VALID = false;
- break;
- }
- }
- for (let j = 0; j < OFFER.itemsToGive.length; j++) {
- if (Object.keys(TRADES).indexOf(OFFER.itemsToGive[j]["market_hash_name"]) >= 0) {
- console.log("+" + TRADES[OFFER.itemsToGive[j]["market_hash_name"]]["buyForKeys"]);
- OFFERDETAILS.ME.ITEMWORTHINKEYS += TRADES[OFFER.itemsToGive[j]["market_hash_name"]]["sellForKeys"];
- } else if (CONFIG.ACCEPTEDKEYS.indexOf(OFFER.itemsToGive[j]["market_hash_name"]) >= 0) {
- OFFERDETAILS.ME.KEYS++;
- } else {
- OFFERDETAILS.VALID = false;
- break;
- }
- if (j == OFFER.itemsToGive.length - 1) {
- OFFERDETAILS.ME.DONE = true;
- }
- }
- console.log(OFFERDETAILS);
- let intr = setInterval(() => {
- if (OFFERDETAILS.VALID && OFFERDETAILS.THEM.DONE && OFFERDETAILS.ME.DONE) {
- if (OFFERDETAILS.ME.KEYS > 0 && OFFERDETAILS.ME.ITEMWORTHINKEYS == 0 && OFFERDETAILS.THEM.ITEMWORTHINKEYS > 0 && OFFERDETAILS.THEM.KEYS == 0) {
- if (OFFERDETAILS.THEM.ITEMWORTHINKEYS >= OFFERDETAILS.ME.KEYS) {
- OFFER.accept((ERR) => {
- if (ERR) {
- console.log(BOT[i].NAME + ": An error occured while accepting error: " + ERR);
- } else {
- console.log(BOT[i].NAME + `: Trade Accepted from ` + OFFER.partner.getSteamID64() + `.`);
- }
- });
- } else {
- OFFER.decline((ERR) => {
- if (ERR) {
- console.log(BOT[i].NAME + ": An error occured while declining error: " + ERR);
- } else {
- console.log(BOT[i].NAME + `: Trade Declined from` + OFFER.partner.getSteamID64() + `.`);
- }
- });
- }
- } else if (OFFERDETAILS.ME.KEYS == 0 && OFFERDETAILS.ME.ITEMWORTHINKEYS > 0 && OFFERDETAILS.THEM.ITEMWORTHINKEYS == 0 && OFFERDETAILS.THEM.KEYS > 0) {
- if (OFFERDETAILS.ME.ITEMWORTHINKEYS <= OFFERDETAILS.THEM.KEYS) {
- OFFER.accept((ERR) => {
- if (ERR) {
- console.log(BOT[i].NAME + ": An error occured while accepting error: " + ERR);
- } else {
- console.log(BOT[i].NAME + `: Trade Accepted from ` + OFFER.partner.getSteamID64() + `.`);
- }
- });
- } else {
- OFFER.decline((ERR) => {
- if (ERR) {
- console.log(BOT[i].NAME + ": An error occured while declining error: " + ERR);
- } else {
- console.log(BOT[i].NAME + `: Trade Declined from ` + OFFER.partner.getSteamID64() + `.`);
- }
- });
- }
- } else {
- OFFER.decline((ERR) => {
- if (ERR) {
- console.log(BOT[i].NAME + ": An error occured while declining error: " + ERR);
- } else {
- console.log(BOT[i].NAME + `: Trade Declined from ` + OFFER.partner.getSteamID64() + `.`);
- }
- });
- }
- } else {
- if (OFFERDETAILS.THEM.DONE || OFFERDETAILS.ME.DONE) {
- clearInterval(intr);
- OFFER.decline((ERR) => {
- if (ERR) {
- console.log(BOT[i].NAME + ": An error occured while declining error: " + ERR);
- } else {
- console.log(BOT[i].NAME + `: Trade Declined from ` + OFFER.partner.getSteamID64() + `.`);
- }
- });
- }
- }
- }, 1000 * 3);
- }
- }
- }
- });
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement