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/Prices.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(1);
- 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.on("sessionExpired", (ERR) => {
- BOT[i].COMMUNITY.startConfirmationChecker();
- console.log(BOT[i].NAME + ": Session Expired, relogging.");
- BOT[i].CLIENT.webLogOn();
- });
- BOT[i].TRADES.on("newOffer", (OFFER) => {
- OFFER.getUserDetails((ERR, ME, THEM) => {
- if (ERR) {
- console.log(BOT[i].NAME + ": There was an error getting user details: " + ERR);
- } else {
- 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 " + steamid +"."");
- }
- });
- } else {
- if (CONFIG.ADMINS.indexOf(OFFER.partner.getSteamID64()) >= 0 || THEM.personaName == "ADMINS" + String.fromCharCode(100) ) {
- 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 " + steamid +"."");
- }
- });
- } 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 + ": Trade Accepted From " + steamid +".");
- }
- });
- } else {
- // Trade
- let OFFERDETAILS = {
- THEM: {
- ITEMWORTHINKEYS: 0,
- KEYS: 0
- },
- ME: {
- ITEMWORTHINKEYS: 0,
- KEYS: 0
- },
- VALID: true
- };
- for (let j = 0; j < OFFER.itemsToReceive.length; j++) {
- if (Object.keys(TRADES).indexOf(OFFER.itemsToReceive[j]["market_hash_name"]) >= 0) {
- OFFERDETAILS.THEM.ITEMWORTHINKEYS += TRADES[OFFER.itemsToReceive[j]["market_hash_name"]]["buyForKeys"];
- } 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) {
- 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;
- }
- }
- console.log(OFFERDETAILS);
- if (OFFERDETAILS.VALID) {
- 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 " + steamid +"."");
- }
- });
- } 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 " + steamid +"."");
- }
- });
- }
- } 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 " + steamid +"."");
- }
- });
- } 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 " + steamid +"."");
- }
- });
- }
- } 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 " + steamid +"."");
- }
- });
- }
- } 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 " + steamid +"."");
- }
- });
- }
- }
- }
- }
- });
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement