Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module.exports = {
- bot: function(username, password, sharedSecret, identitySecret) {
- const SteamUser = require('steam-user');
- const TradeOfferManager = require('steam-tradeoffer-manager');
- const SteamTotp = require('steam-totp');
- const SteamCommunity = require('steamcommunity');
- const SteamID = require('steamid');
- const config = require('./config.json');
- const acceptedCases = ["Operation Breakout Weapon Case", "Chroma 2 Case", "Chroma 3 Case", "Operation Wildfire Case", "Gamma Case", "Shadow Case", "Gamma 2 Case", "Spectrum Case"];
- const acceptedKeys = ["Shadow Case Key"]
- const community = new SteamCommunity();
- const client = new SteamUser();
- const manager = new TradeOfferManager({
- steam: client,
- domain: 'example.com',
- language: 'en'
- });
- const logOnOptions = {
- accountName: username,
- password: password,
- twoFactorCode: SteamTotp.generateAuthCode(sharedSecret)
- };
- client.logOn(logOnOptions);
- client.on('loggedOn', function(details) {
- console.log(`Logged into Steam as ${client.steamID.getSteam3RenderedID()}`); //online then play tf2
- client.setPersona(SteamUser.Steam.EPersonaState.Online);
- client.gamesPlayed([440])
- });
- client.on('webSession', function(sessionID, cookies) {
- manager.setCookies(cookies, function(err) {
- if (err) return console.log(err);
- console.log(`Got API key: ${manager.apiKey}`);
- });
- community.setCookies(cookies);
- community.startConfirmationChecker(4000, identitySecret);
- });
- function keyAmountGood(keyAmount) {
- if (Math.floor(1000 / config.casesForKey) < keyAmount) {
- return false;
- }
- }
- function loadInv(steamID) {
- return new Promise((resolve, reject) => {
- manager.loadUserInventory(steamID, 730, 2, true, (err, inv) => {
- if (err) {
- console.log(err.message)
- return reject(err.message)
- }
- resolve(inv);
- })
- })
- }
- function GetCaseStock() {
- let cases = 0;
- console.log(cases);
- for (var i = 0; i < config.storageBotIds.length; i++) {
- loadInv(config.storageBotIds[i]).then(inv => {
- for (var i = 0; i < inv.length; i++) {
- if (acceptedCases.includes(inv[i].market_hash_name)) {
- cases++;
- console.log(cases);
- }
- }
- });
- }
- }
- function makeOffer(steamID, neededCases, keyAmount) {
- var offer = manager.createOffer(steamID);
- let ourCases = [];
- let thereKeys = [];
- loadInv(steamID).then(thereInv => {
- loadInv(config.mainBot64).then(myInv => {
- for (let i = 0; i < myInv.length; i++) {
- if (acceptedCases.includes(myInv[i].market_hash_name) && neededCases > ourCases.length) {
- ourCases.push(myInv[i].assetid);
- }
- }
- for (var i = 0; i < thereInv.length; i++) {
- if (acceptedKeys.includes(myInv[i].market_hash_name) && neededCases > ourCases.length) {
- thereKeys.push(thereInv[i].assetid);
- }
- }
- if (thereKeys < keyAmount) {
- client.chatMessage(steamID, "oh no it appears you do not have enough keys, you have " + thereKeys.length + " keys and you need " + keyAmount + " keys sorry");
- return;
- }
- });
- });
- }
- client.on('friendMessage', (steamID, message) => {
- let keyAmount = parseInt(message.split("!buy")[1])
- if (keyAmountGood(keyAmount) == false) {
- client.chatMessage(steamID, "oh no your trying to trade to many keys, we can only trade " + Math.floor(1000 / config.casesForKey) + " keys at a time!");
- } else {
- let neededCases = keyAmount * config.casesForKey;
- var offer = manager.createOffer(steamID);
- let ourCases = [];
- let thereKeys = [];
- loadInv(steamID).then(thereInv => {
- loadInv(config.mainBot64).then(myInv => {
- for (let i = 0; i < myInv.length; i++) {
- if (acceptedCases.includes(myInv[i].market_hash_name) && neededCases > ourCases.length) {
- ourCases.push(myInv[i].assetid);
- }
- }
- for (var i = 0; i < thereInv.length; i++) {
- if (acceptedKeys.includes(myInv[i].market_hash_name) && neededCases > ourCases.length) {
- thereKeys.push(thereInv[i].assetid);
- }
- }
- if (thereKeys < keyAmount) {
- client.chatMessage(steamID, "oh no it appears you do not have enough keys, you have " + thereKeys.length + " keys and you need " + keyAmount + " keys sorry");
- return;
- }
- });
- });
- if (GetCaseStock() <= neededCases) {
- }
- }
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement