derogs Posted March 15, 2018 Report Share Posted March 15, 2018 Hello, dear community,I am currently trying to manage multiple bots. I have made a bot.js where I am declaring how the object of the bot has to be. In the app.js I am making, for every steam account I have, a bot object and starting each bot synchronously after the bot before has been successfully logged in before. Now my problem:Let's say I have 10 steam accounts, every account owns Counter Strike and has a minimum spent of $5 in market.If I now start all bot instances, all steam accounts are shown as 'Currently In-Game Counter-Strike: Global Offensive' as far as good.But if I now send a trade offer to one of these bots, whatever bot I send the trade offer to it never gets accepted plus in the log files it says always: "Bot #10: Accepted offer. Status: pending"(Strange because the offer wasn't accepted!).So whatever bot I send the offer to, it's always bot #10 (the last bot) that tries to accept the offer. bot.js var SteamUser = require('steam-user'); var SteamTotp = require('steam-totp'); var SteamCommunity = require('steamcommunity'); var TradeOfferManager = require('steam-tradeoffer-manager'); var client; var community; var manager; var logOnOptions; function Bot(options, loggedIn){ //loggedIn -> Callback function, fires when client logs in successfully. client = new SteamUser(); community = new SteamCommunity(); manager = new TradeOfferManager({ steam: client, community: community, language: 'en' }); logOnOptions = { accountName : options.accountName, password : options.password, twoFactorCode : SteamTotp.generateAuthCode(options.shared_secret) }; client.logOn(logOnOptions); client.on('loggedOn', () => { console.log('Bot #'+options.id+' is running...'); client.setPersona(SteamUser.Steam.EPersonaState.Online); client.gamesPlayed(730); loggedIn(); }); client.on('webSession', (sessionid, cookies) => { manager.setCookies(cookies); community.setCookies(cookies); community.startConfirmationChecker(10000, options.identity_secret); }); manager.on('newOffer', offer => { if (offer.partner.getSteamID64() === '76561198100124418') { offer.accept((err, status) => { if (err) { console.log('Bot #'+options.id+': Error while accepting. '+err); } else { console.log('Bot #'+options.id+': Accepted offer. Status: '+status); } }); } else { offer.decline(err => { if (err) { console.log(err); } else { console.log('Bot #'+options.id+': Canceled offer: No trusted SteamID.'); } }); } }); } module.exports = Bot; app.js var Bot = require('./bot.js'); var config = require('./config.json'); var bots = []; var x = 0; var loopArray = function(arr) { startBot(arr[x],function(){ x++; if(x < arr.length) { loopArray(arr); } }); } function startBot(options,loggedIn) { console.log("Starting Bot "+options.id); var bot = new Bot(options, ()=>{ bots.push(bot); loggedIn(); }); } loopArray(config); I hope someone can help me ^^ Thank you in advance for any answers!-degs Quote Link to comment Share on other sites More sharing options...
Dr. McKay Posted March 16, 2018 Report Share Posted March 16, 2018 Move your client, community, manager, logOnOptions declarations inside of the Bot function. derogs 1 Quote Link to comment Share on other sites More sharing options...
derogs Posted March 17, 2018 Author Report Share Posted March 17, 2018 Yep, that did the trick!I guess my mistake was, that I was using for each new bot the same global variables that I just rewrote each time while creating a new instance, right? Thanks a lot! Quote Link to comment Share on other sites More sharing options...
Dr. McKay Posted March 17, 2018 Report Share Posted March 17, 2018 Yup. derogs 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.